# General integer solution for $x^2+y^2-z^2=\pm 1$

How to find general solution (in terms of parameters) for diophantine equations $x^2+y^2-z^2=1$ and $x^2+y^2-z^2=-1$?

It's easy to find such solutions for $x^2+y^2-z^2=0$ or $x^2+y^2-z^2-w^2=0$ or $x^2+y^2+z^2-w^2=0$, but for these ones I cannot find anything relevant.

-

I think that the solutions to $x^2+y^2-z^2=-1$ are $x=RT-SU,y=RU+ST$ where $R^2+S^2-T^2-U^2=2$ then $z=R^2+S^2-1=T^2+U^2+1$ On the surface this looks similar to the solutions to the $+1$ case. However these are quite a bit rarer and depend on the locations of the primes.

As we know, an integer can be uniquely written as $n=ab^2$ where $a$ (the squarefree part of $n$) is a product of distinct primes. $n$ can be written as a sum of two squares $n=j^2+k^2$ precisely when $a$ has no prime divisors of the form $4m+3$ (and we know in how many ways this can be done as well.) So the solutions depend on when we have 2 consecutive even numbers of this form.

For example $292=73\cdot4^2$ and $290=2\cdot5\cdot329$ thus we know that there are expressions as a sum of two squares: $$292=6^2+16^2$$ $$290=1^2+17^2=11^2+13^2.$$ Running through the various possiblities gives these solutions for $R,S,T,U,x,y$ with $x^2+y^2-291^2=-1:$

• 6, 16, 17, 1, 86, 278
• 16, 6, 11, 13, 98, 274
• 16, 6, 17, 1, 266, 118
• 16, 6, 13, 11, 142, 254

Certain families of solutions can be given. One is $x,y,z=2p,2p^2,2p^2+1.$

-
Thank you. I like this answer too. – Victor Kuliamin Jun 15 '11 at 9:51

I believe the general solution to $x^2+y^2-z^2=1$ is $x=(rs+tu)/2$, $y=(rt-su)/2$, $z=(rs-tu)/2$, where $rt+su=2$.

EDIT: Solutions to $x^2+y^2+1=z^2$ can be obtained by choosing $a$, $b$, $c$, $d$ such that $ad-bc=1$ and then letting $x=(a^2+b^2-c^2-d^2)/2$, $y=ac+bd$, $z=(a^2+b^2+c^2+d^2)/2$, though I'm not sure you get all the integer solutions this way.

The rational solutions are a bit easier. $(0,0,1)$ is a (rational) point on the surface. The line $(0,0,1)+t(a,b,c)$ through that point intersects the surface again at $x=2ac/(a^2+b^2-c^2)$, $y=2bc/(a^2+b^2-c^2)$, $z=(a^2+b^2+c^2)/(a^2+b^2-c^2)$, giving all the rational points on the surface.

-
Looks good. One way of getting there is setting $a:=x+z, b:=x-y$ to obtain $ab=(1+y)(1-y)$, so that there must be $r,s,t,u$ with $rs=a,tu=b,1+y=rt,1-y=su$. – Klaus Draeger May 25 '11 at 13:35
Nice! but You mean $b=x-z$ – Aaron Meyerowitz May 25 '11 at 17:02
oops - yes, of course. Thanks! – Klaus Draeger May 25 '11 at 18:20
Thank you very much. – Victor Kuliamin Jun 15 '11 at 9:49

The question is the same as looking for points of norm 1 or -1 in the unimodular Lorentzian lattice $Z^{1,2}$. This has an infinite group of automorphisms, with an index 2 subgroup that is a Coxeter group generated by 3 reflections. This group acts transitively on the vectors of norm 1 and -1 if I remember correctly, so all solutions can be obtained from 1 particular solution by acting with this group.

-

Let´s take any $x>3$ and choose a,b such that $a<b$,$a-b$ even and $ab=x^2-1$. Then with $y=(b-a)/2$, $z=(b+a)/2$ we have $x^2 + y^2 = z^2 + 1$. Particular cases∶ if $x$ even then $x^2 + ((x^2-2)/2)^2 = (x^2/2)^2 + 1$; if $x$ odd then $x^2 + ((x^2-5)/4)^2 = ((x^2+3)/4)^2 + 1$.

-

Of course for the equation $X^2+Y^2=Z^2+t$

There is a particular solution:

$X=1\pm{b}$

$Y=\frac{(b^2-t\pm{2b})}{2}$

$Z=\frac{(b^2+2-t\pm{2b})}{2}$

But interessuet is another solution:

$X^2+Y^2=Z^2+1$

If you use the solution of Pell's equation: $p^2-2s^2=\pm1$ Making formula has the form:

$X=2s(p+s)L+p^2+2ps+2s^2=aL+c$

$Y=(p^2+2ps)L+p^2+2ps+2s^2=bL+c$

$Z=(p^2+2ps+2s^2)L+p^2+4ps+2s^2=cL+q$

number $L$ and any given us. The most interesting thing here is that the numbers $a,b,c$ it Pythagorean triple.

$a^2+b^2=c^2$

This formula is remarkable in that it allows using the equation $p^2-2s^2=\pm{k}$ Allows you to find Pythagorean triples with a given difference.

$a=2s(p+s)$

$b=p(p+2s)$

$c=p^2+2ps+2s^2$

$b-a=\pm{k}$

Pretty is not expected relationship between the solutions of Pell's equation and Pythagorean triples.

-