Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

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

I note that the Diophantine equation, $x^2 + y^2 = z^2$, with $x, y, z \in \mathbb{N}$, has infinitely many solutions. Indeed, $(x, y, z) = (3,4,5)$ provides a solution, and for any $k \in \mathbb{N}$ : $(kx, ky, kz ) = (3k, 4k, 5k)$ provides a solution.

However, assuming $x, y, z \in \mathbb{N}$ with $x, y > 1$, is the same true for the Diophantine equations,

$x^2 +y^2 = z^2 + 1$,

$x^2 + y^2 = z^2 + 2$,

$x^2 + y^2 = z^2 + 3$

and more generally, for $x^2 + y^2 = z^2 + n$, for any $n \in \mathbb{N}$?

In particular, are there infinitely-many triples $(x, y, z) \in \mathbb{N}^3$ for which $x^2 + y^2 = z^2 + n$ is true for infinitely-many values of $n \in \mathbb{N}$?

share|cite|improve this question
A related question that asked for something stronger (the density of the set of solutions) :…. The answer to your question seems to be that for any $n$ there will be infinitely many solutions to $x^2+y^2 = z^2+n$ – mercio Feb 8 '13 at 14:24
For $x^2+y^2=z^2+1$ note that $2x^2=z^2+1$ is known to have infinitely many solutions eg $(x,z)=(1,1),(5,7),(29,41) \dots$. – Mark Bennet Feb 8 '13 at 14:25
Note also that $(2n+1)^2+(2n^2+2n-1)^2=[2n(n+1)]^2+2$ – Mark Bennet Feb 8 '13 at 14:33
up vote 9 down vote accepted

$x^2+y^2 = z^2+n$ is equivalent to $x^2-n = (z-y)(z+y)$.

Any composite odd number can be written as $(z-y)(z+y)$ for some integers $z$ and $y$, so it is enough to show that $x^2-n$ contains infinitely many composite odd numbers.

If $n$ is odd, then you can simply pick $x = 2kn$ for any $k$. Then $x^2-n$ is a multiple of $n$ and odd, which gives you two integers $y$ and $z$ satisfying the equation. You end up with the family of solutions $(2kn, 2k^2n-(n+1)/2, 2k^2n-(n-1)/2)$

If $n$ is even, then you can simply pick $x=2k(n-1)+1$ for any $k$. Then $x^2-n \equiv 1^2-1 = 0 \pmod {n-1}$, and it is odd so again this gives you two integers $y$ and $z$ satisfying the equation. You end up with the family of solutions $(2k(n-1)+1,2k^2(n-1)+2k-n/2,2k^2(n-1)+2k-1+n/2)$

share|cite|improve this answer
In your solution for odd values of $n$, I think you must mean the triple $(2kn, 2k^2 n - (n + 1)/2, 2 k^2 n + (n - 1)/2$, else we do not get $x^2 + y^2 = z^2 + n$. – Harry Williams Feb 10 '13 at 17:14
I am still not clear how you found $y$ and $z$. Is it just a parameterisation that happens to work, or is there some method in finding it? – Harry Williams Feb 10 '13 at 17:18
@HarryWilliams : if $a$ and $b$ are odd numbers, then $ab = (z-y)(z+y)$ where $z=(a+b)/2$ and $y=(a-b)/2$. So for the case where $n$ is odd, I just wrote $x^2-n = n(4k^2n-1)$ and used that factorization to find some $y$ and $z$. And yes, I made a sign error. – mercio Feb 13 '13 at 14:30
That's brilliant. Thank you very much. – Harry Williams May 6 '13 at 23:28

EDIT: I can't quite parse the final question in the original post. However, given any integer $N,$ there are infinitely many triples $(x,y,z)$ that solve $$ x^2 + y^2 - z^2 = N^2 $$ using the process below. A "seed" triple may be taken with any $x=z, \; y = N.$ If we just take $\gcd(x,N) = 1$ as well, we get primitive triples.

ORIGINAL:Actually, the group of automorphs of $x^2 + y^2 - z^2$ is known. It is infinite, and generated by three matrices, along with negating any of $x,y,z$ if that is necessary, not sure. I am trying to find a question that shows the matrices, no luck so far. However, what is means is that, if there is a single solution to $x^2 + y^2 = z^2 + k$ for some integer $k,$ positive or negative or zero, then there are infinitely many, and we can travel among them by matrix multiplication of the column vectors $(x,y,z)^T.$

I think it was some question here or on MO more likely, about the structure of Pythagorean triples. Note that the expert on this is named Ian Agol. There is just a comment by him at this one:

Here we go,
these matrices due to F. J. M. Barning (1963)

$$ A = \; \left( \begin{array}{rrr} 1 & -2 & 2 \\ 2 & -1 & 2 \\ 2 & -2 & 3 \end{array} \right) \; \; B = \; \left( \begin{array}{rrr} 1 & 2 & 2 \\ 2 & 1 & 2 \\ 2 & 2 & 3 \end{array} \right) \; \; C = \; \left( \begin{array}{rrr} -1 & 2 & 2 \\ -2 & 1 & 2 \\ -2 & 2 & 3 \end{array} \right) $$

share|cite|improve this answer
I knew this but it didn't enter my mind when working on that other question. I wonder if it helps. – mercio Feb 8 '13 at 20:53
@mercio, it does not give a two-parameter recipe, which may be unlikely as ciceksiz has suggested. But it does take you from any single point on $x^2 + y^2 - z^2 = k,$ which we need to find somehow, to any other such point. I would also expect a doubled or trebled ternary tree for any of these problems, as derived solutions may not have all positive entries. Worth trying to draw some trees, some for positive $k,$ some for negative, see how well it works out and what adjustments to the original picture may be required. Certainly "primitive" solutions will be the norm. – Will Jagy Feb 8 '13 at 21:06

I think the answer to your question is no. There may be infinitely many solutions to the diophantine equations you have stated, however you cannot classify them as in the $x^2+y^2=z^2$ case. What I mean is that in the equations $x^2+y^2=z^2+n$, if you have a solution $(x_1,y_1,z_1)$, you cannot generalize this solution as to $(kx_1,ky_1,kz_1)$, since you have the factor n. For instance let us say we have the equation $x^2+y^2=z^2+12$. (5,6,7) is a solution of this equation, however when you plugin the values (10,12,14) the quation does not hold. So what I am saying is that you cannot find infinitely many solutions to the diaphontine equations $x^2+y^2=z^2+n$ with the same method you have applied in the phytogaros equation. Nevertheless, you may find infinitely many solutions using other parametrizations. Hope this helps you!

share|cite|improve this answer

For the special case when the number of is a square and is given us. That is, in the equation:


where the number of $q$ - given us.

Then the solutions of the equation can be written ospolzovavshis Pell: $p^2-2k(k-1)s^2=\pm{q}$

$k$ - given us can be anything.




If we use the solutions of Pell's equation: $p^2-2s^2=\pm1$ Solutions have the form:




share|cite|improve this answer

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.