Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How would one determine solutions to the following quadratic Diophantine equation in three variables:

$$x^2 + n^2y^2 \pm n^2y = z^2$$

where n is a known integer and $x$, $y$, and $z$ are unknown positive integers to be solved. Ideally there would be a parametric solution for $x$, $y$, and $z$.

[Note that the expression $y^2 + y$ must be an integer from the series {2, 6, 12, 20, 30, 42 ...} and so can be written as either $y^2 + y$ or $y^2 - y$ (e.g., 12 = $3^2 + 3$ and 12 = $4^2 - 4$). So I have written this as +/- in the equation above.]


share|cite|improve this question
up vote 3 down vote accepted

Considering this as a quadratic in $y$, it is sufficient (and necessary) that

$n^4 - 4n^2(x^2-z^2)$ is a perfect square.


$n^2 - 4(x^2 - z^2)$ is a perfect square, say $q^2$.

Rewriting gives us

$(n-q)(n+q) = 4 (x^2 - z^2)$

If $n=2k$ is even, then $q$ needs to be even too (say $2m$) and

$(k-m)(k+m) = (x-z)(x+z)$

If $n=2k+1$ is odd, then $q$ needs to be odd too (say $2m+1$) and

$(k-m)(k+m+1) = (x-z)(x+z)$

Thus you can pick any $m$, and try to factor the left hand side above (choosing the right one depending on the parity of $n$) into two terms of the same parity.

share|cite|improve this answer
Not sure of a parametric solution. It sort of depends on $n$. – Aryabhata Mar 7 '12 at 15:08

We will consider the more general equation:


Then, if we use the solutions of Pell's equation: $p^2-(q+1)s^2=1$

Solutions can be written in this ideal:




And more:




$L$ - integer and given us.

share|cite|improve this answer

For the case when the equation: $X^2+qY^2+qY=Z^2$

factor $q$ - is not a square, then solutions can yrazit using Pell's equation: $p^2-qs^2=1$

Then there is another solution:




share|cite|improve this answer

This is a good problem as it requires to write the (Diophantine) parametric representations of the variables.

This method can be extended to n variables; one way of stating this result is to say there is an algorithm to construct a n variable quadratic system and if our equation fits this construction then the solutions are read off trivial.

I will explain this later.

share|cite|improve this answer
So now is later... – Thomas Sep 15 '12 at 21:34
Is it "later" yet? :) – Ricket Sep 28 '14 at 3:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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