I want to solve the following quadratic Diophantine equation:

$$\frac{x(x-1)}{y(y-1)}=\frac{p}{q} \hspace{5 mm}, \hspace{5 mm}p\le q$$ For $p=1$ and $q=2$, it is easy to solve.

Let $y=x+z$. Then after some simplification we get


For integral solution, the discriminant of this equation must be a whole square. Hence


Now it is a standard Pell's equation which can easily be solved. But for arbitrary $p$ and $q$, using similar approach I get


I am stuck here. Can someone help me?

  • $\begingroup$ It is still a quadratic in $z$, and the earlier approach should work for any specific $p,q$. If you are looking for a general expression for the solutions in terms of $p,q$ I doubt you'll get it though. $\endgroup$ – Macavity Aug 30 '15 at 15:01
  • $\begingroup$ In earlier case I managed to get the standard Pell's equation of form $x^2-dy^2=1$. How can I approach for any $p$ and $q$. Yes, closed form is not possible in terms of $p$ and $q$, but there might be some other method. $\endgroup$ – guest123456 Aug 30 '15 at 15:09
  • $\begingroup$ You may want to take a look at math.stackexchange.com/questions/490617/… $\endgroup$ – Macavity Aug 30 '15 at 15:58
  • $\begingroup$ @guest123456: Actually, a closed-form is possible. $\endgroup$ – Tito Piezas III Aug 31 '15 at 4:45

Here's a broad solution in integers. Given,


All you do is directly solve $(1)$ as a quadratic in $x$ and make its discriminant a square. After some manipulation, I find,

$$x = pv(u+qv)$$

$$y = qv(u+pv)$$

and $u,v$ solve,

$$u^2-pqv^2 = \color{red}-1\tag2$$


$$x = pv(u+qv)+1$$

$$y = qv(u+pv)+1$$

and $u,v$ solve,

$$u^2-pqv^2 = 1\tag3$$

  • $\begingroup$ It seems that you missed $+1$ at the end of both the expression of $x$ and $y$. $\endgroup$ – guest123456 Aug 31 '15 at 13:14
  • 1
    $\begingroup$ @guest123456: Oh, you're right. The first solution is for the negative Pell equation. I've edited, and also got rid of the unnecessary factor of 2. Thanks. :) $\endgroup$ – Tito Piezas III Aug 31 '15 at 13:36
  • 1
    $\begingroup$ Your method does not give the complete set of solutions. For example if $p=1$ and $q=2$, then your method gives $x=15$ and $y=21$, which is correct but not the smallest solution. Smallest solution is $x=3$ and $y=4$. $\endgroup$ – guest123456 Aug 31 '15 at 13:50
  • $\begingroup$ @guest123456: Yes, I know. That's why I carefully started with "Here's a broad..." Nowhere in your post did you ask for the complete solution. :) $\endgroup$ – Tito Piezas III Aug 31 '15 at 13:58
  • 1
    $\begingroup$ @guest123456: Using the negative Pell, it does give the smallest solution. Let $p,q=1,2$, and $u^2-2v^2 =-1$, so $u,v = 1,1$, and the formula yields $x,y = 3,4$. $\endgroup$ – Tito Piezas III Aug 31 '15 at 14:12

I stopped at,


After further simplification,




which is the standard Pell's equation. Now it can easily be solved.

  • $\begingroup$ How did you get from $(2)$ to $(3)$? $\endgroup$ – Tito Piezas III Aug 31 '15 at 11:31
  • 1
    $\begingroup$ Thanks for pointing out the mistake. $\endgroup$ – guest123456 Aug 31 '15 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.