
Find all integral solutions of $x^2+1= y^2+z^2$. Actually I have to find all integral solution of $a(a+1)=b(b+1)+c(c+1)$. I reduced this in the above form I.e., $ (2a+1)^2+1= (2b+1)^2+(2c+1)^2$ .



[Solution of Diophantine equation](/questions/1842447/solution-of-diophantine-equation)
=======================================================================================



The case where $z^2-x^2=1-y^2=0$ is self-evident.We have $z=\pm x$ and $y=\pm 1$


Now consider the case where $(1-y^2)(z^2-x^2)\neq 0$
$$z^2-x^2=1-y^2$$
$$(z+x)(z-x)=(1+y)(1-y)$$
$$\dfrac{z+x}{1+y}=\dfrac{1-y}{z-x}
=\dfrac{p}{q}$$ with $pq\neq 0$ and $\gcd(p,q)=1$.


It follows:
$$z+x=\dfrac{p}{q}(1+y)$$
$$z-x=\dfrac{q}{p}{(1-y)}$$


Hence, in order to find all the integral solutions, the following restrictions must apply 
$$1-y\equiv 0\pmod p$$
$$1+y\equiv 0\pmod q$$ 


In other words,by alternatively subtracting 1 from 2/ adding 1 and 2 $$qs-pr=2y$$
$$qs+pr=2$$ where $r,s$ are 2 coprime integers.
Since
$$z+x=ps$$
$$z-x=qr$$


we have:
$$z=\dfrac{1}{2}(ps+qr)$$ $$x=\dfrac{1}{2}(ps-qr)$$ $$y=\dfrac{1}{2}(qs-pr)$$where $pr,qs$ have the same parity and $qs+pr=2$.




There is a parametrization, most of the restrictions are to cut down on repetition. I found this by working with an answer by Ted Shifrin, [Rulings of One Sheet Hyperboloid](https://math.stackexchange.com/questions/1648749/rulings-of-one-sheet-hyperboloid)


Take integers $a,b,c,d.$ Allow $b \geq 0,$ then $a,c,d >0.$


Main restriction:
$$ a d - b c = 1. $$
Secondary:
$$ a c > b d. $$
Define
$$ x = a d + b c, $$
$$ y = a c - b d, $$
$$ z = a c + b d.$$
To reduce repetition, when $y$ is odd, demand $x \leq y.$ Notice that $X$ is always odd because $ad+bc \equiv ad-bc \pmod 2.$


This is lightning fast.



```
1  x: 1  y: 1  z: 1      a: 1  b: 0  c: 1  d: 1     1 + z^2 : 2 =  2
2  x: 1  y: 2  z: 2      a: 1  b: 0  c: 2  d: 1     1 + z^2 : 5 =  5
3  x: 1  y: 3  z: 3      a: 1  b: 0  c: 3  d: 1     1 + z^2 : 10 =  2 5
4  x: 1  y: 4  z: 4      a: 1  b: 0  c: 4  d: 1     1 + z^2 : 17 =  17
5  x: 1  y: 5  z: 5      a: 1  b: 0  c: 5  d: 1     1 + z^2 : 26 =  2 13
6  x: 1  y: 6  z: 6      a: 1  b: 0  c: 6  d: 1     1 + z^2 : 37 =  37
7  x: 1  y: 7  z: 7      a: 1  b: 0  c: 7  d: 1     1 + z^2 : 50 =  2 5^2
7  x: 5  y: 5  z: 7      a: 3  b: 1  c: 2  d: 1     1 + z^2 : 50 =  2 5^2
8  x: 1  y: 8  z: 8      a: 1  b: 0  c: 8  d: 1     1 + z^2 : 65 =  5 13
8  x: 7  y: 4  z: 8      a: 2  b: 1  c: 3  d: 2     1 + z^2 : 65 =  5 13
9  x: 1  y: 9  z: 9      a: 1  b: 0  c: 9  d: 1     1 + z^2 : 82 =  2 41
10  x: 1  y: 10  z: 10      a: 1  b: 0  c: 10  d: 1     1 + z^2 : 101 =  101
11  x: 1  y: 11  z: 11      a: 1  b: 0  c: 11  d: 1     1 + z^2 : 122 =  2 61
12  x: 1  y: 12  z: 12      a: 1  b: 0  c: 12  d: 1     1 + z^2 : 145 =  5 29
12  x: 9  y: 8  z: 12      a: 5  b: 2  c: 2  d: 1     1 + z^2 : 145 =  5 29
13  x: 1  y: 13  z: 13      a: 1  b: 0  c: 13  d: 1     1 + z^2 : 170 =  2 5 17
13  x: 7  y: 11  z: 13      a: 4  b: 1  c: 3  d: 1     1 + z^2 : 170 =  2 5 17
14  x: 1  y: 14  z: 14      a: 1  b: 0  c: 14  d: 1     1 + z^2 : 197 =  197
15  x: 1  y: 15  z: 15      a: 1  b: 0  c: 15  d: 1     1 + z^2 : 226 =  2 113
16  x: 1  y: 16  z: 16      a: 1  b: 0  c: 16  d: 1     1 + z^2 : 257 =  257
17  x: 11  y: 13  z: 17      a: 3  b: 1  c: 5  d: 2     1 + z^2 : 290 =  2 5 29
17  x: 1  y: 17  z: 17      a: 1  b: 0  c: 17  d: 1     1 + z^2 : 290 =  2 5 29
18  x: 15  y: 10  z: 18      a: 2  b: 1  c: 7  d: 4     1 + z^2 : 325 =  5^2 13
18  x: 17  y: 6  z: 18      a: 3  b: 2  c: 4  d: 3     1 + z^2 : 325 =  5^2 13
18  x: 1  y: 18  z: 18      a: 1  b: 0  c: 18  d: 1     1 + z^2 : 325 =  5^2 13
19  x: 1  y: 19  z: 19      a: 1  b: 0  c: 19  d: 1     1 + z^2 : 362 =  2 181
20  x: 1  y: 20  z: 20      a: 1  b: 0  c: 20  d: 1     1 + z^2 : 401 =  401
21  x: 1  y: 21  z: 21      a: 1  b: 0  c: 21  d: 1     1 + z^2 : 442 =  2 13 17
21  x: 9  y: 19  z: 21      a: 5  b: 1  c: 4  d: 1     1 + z^2 : 442 =  2 13 17
22  x: 17  y: 14  z: 22      a: 9  b: 4  c: 2  d: 1     1 + z^2 : 485 =  5 97
22  x: 1  y: 22  z: 22      a: 1  b: 0  c: 22  d: 1     1 + z^2 : 485 =  5 97
23  x: 13  y: 19  z: 23      a: 7  b: 2  c: 3  d: 1     1 + z^2 : 530 =  2 5 53
23  x: 1  y: 23  z: 23      a: 1  b: 0  c: 23  d: 1     1 + z^2 : 530 =  2 5 53
24  x: 1  y: 24  z: 24      a: 1  b: 0  c: 24  d: 1     1 + z^2 : 577 =  577
25  x: 1  y: 25  z: 25      a: 1  b: 0  c: 25  d: 1     1 + z^2 : 626 =  2 313
26  x: 1  y: 26  z: 26      a: 1  b: 0  c: 26  d: 1     1 + z^2 : 677 =  677
27  x: 17  y: 21  z: 27      a: 3  b: 1  c: 8  d: 3     1 + z^2 : 730 =  2 5 73
27  x: 1  y: 27  z: 27      a: 1  b: 0  c: 27  d: 1     1 + z^2 : 730 =  2 5 73
28  x: 1  y: 28  z: 28      a: 1  b: 0  c: 28  d: 1     1 + z^2 : 785 =  5 157
28  x: 23  y: 16  z: 28      a: 2  b: 1  c: 11  d: 6     1 + z^2 : 785 =  5 157
29  x: 1  y: 29  z: 29      a: 1  b: 0  c: 29  d: 1     1 + z^2 : 842 =  2 421
30  x: 15  y: 26  z: 30      a: 4  b: 1  c: 7  d: 2     1 + z^2 : 901 =  17 53
30  x: 1  y: 30  z: 30      a: 1  b: 0  c: 30  d: 1     1 + z^2 : 901 =  17 53
31  x: 11  y: 29  z: 31      a: 6  b: 1  c: 5  d: 1     1 + z^2 : 962 =  2 13 37
31  x: 1  y: 31  z: 31      a: 1  b: 0  c: 31  d: 1     1 + z^2 : 962 =  2 13 37
32  x: 1  y: 32  z: 32      a: 1  b: 0  c: 32  d: 1     1 + z^2 : 1025 =  5^2 41
32  x: 25  y: 20  z: 32      a: 13  b: 6  c: 2  d: 1     1 + z^2 : 1025 =  5^2 41
32  x: 31  y: 8  z: 32      a: 4  b: 3  c: 5  d: 4     1 + z^2 : 1025 =  5^2 41
33  x: 19  y: 27  z: 33      a: 10  b: 3  c: 3  d: 1     1 + z^2 : 1090 =  2 5 109
33  x: 1  y: 33  z: 33      a: 1  b: 0  c: 33  d: 1     1 + z^2 : 1090 =  2 5 109
34  x: 1  y: 34  z: 34      a: 1  b: 0  c: 34  d: 1     1 + z^2 : 1157 =  13 89
34  x: 31  y: 14  z: 34      a: 8  b: 5  c: 3  d: 2     1 + z^2 : 1157 =  13 89
35  x: 1  y: 35  z: 35      a: 1  b: 0  c: 35  d: 1     1 + z^2 : 1226 =  2 613
36  x: 1  y: 36  z: 36      a: 1  b: 0  c: 36  d: 1     1 + z^2 : 1297 =  1297
37  x: 1  y: 37  z: 37      a: 1  b: 0  c: 37  d: 1     1 + z^2 : 1370 =  2 5 137
37  x: 23  y: 29  z: 37      a: 3  b: 1  c: 11  d: 4     1 + z^2 : 1370 =  2 5 137
38  x: 17  y: 34  z: 38      a: 9  b: 2  c: 4  d: 1     1 + z^2 : 1445 =  5 17^2
38  x: 1  y: 38  z: 38      a: 1  b: 0  c: 38  d: 1     1 + z^2 : 1445 =  5 17^2
38  x: 31  y: 22  z: 38      a: 2  b: 1  c: 15  d: 8     1 + z^2 : 1445 =  5 17^2
39  x: 1  y: 39  z: 39      a: 1  b: 0  c: 39  d: 1     1 + z^2 : 1522 =  2 761
40  x: 1  y: 40  z: 40      a: 1  b: 0  c: 40  d: 1     1 + z^2 : 1601 =  1601
41  x: 1  y: 41  z: 41      a: 1  b: 0  c: 41  d: 1     1 + z^2 : 1682 =  2 29^2
41  x: 29  y: 29  z: 41      a: 5  b: 2  c: 7  d: 3     1 + z^2 : 1682 =  2 29^2
42  x: 1  y: 42  z: 42      a: 1  b: 0  c: 42  d: 1     1 + z^2 : 1765 =  5 353
42  x: 33  y: 26  z: 42      a: 17  b: 8  c: 2  d: 1     1 + z^2 : 1765 =  5 353
43  x: 13  y: 41  z: 43      a: 7  b: 1  c: 6  d: 1     1 + z^2 : 1850 =  2 5^2 37
43  x: 1  y: 43  z: 43      a: 1  b: 0  c: 43  d: 1     1 + z^2 : 1850 =  2 5^2 37
43  x: 25  y: 35  z: 43      a: 13  b: 4  c: 3  d: 1     1 + z^2 : 1850 =  2 5^2 37
44  x: 1  y: 44  z: 44      a: 1  b: 0  c: 44  d: 1     1 + z^2 : 1937 =  13 149
44  x: 41  y: 16  z: 44      a: 3  b: 2  c: 10  d: 7     1 + z^2 : 1937 =  13 149
45  x: 1  y: 45  z: 45      a: 1  b: 0  c: 45  d: 1     1 + z^2 : 2026 =  2 1013
46  x: 1  y: 46  z: 46      a: 1  b: 0  c: 46  d: 1     1 + z^2 : 2117 =  29 73
46  x: 31  y: 34  z: 46      a: 8  b: 3  c: 5  d: 2     1 + z^2 : 2117 =  29 73
47  x: 19  y: 43  z: 47      a: 5  b: 1  c: 9  d: 2     1 + z^2 : 2210 =  2 5 13 17
47  x: 1  y: 47  z: 47      a: 1  b: 0  c: 47  d: 1     1 + z^2 : 2210 =  2 5 13 17
47  x: 23  y: 41  z: 47      a: 4  b: 1  c: 11  d: 3     1 + z^2 : 2210 =  2 5 13 17
47  x: 29  y: 37  z: 47      a: 3  b: 1  c: 14  d: 5     1 + z^2 : 2210 =  2 5 13 17
48  x: 1  y: 48  z: 48      a: 1  b: 0  c: 48  d: 1     1 + z^2 : 2305 =  5 461
48  x: 39  y: 28  z: 48      a: 2  b: 1  c: 19  d: 10     1 + z^2 : 2305 =  5 461
49  x: 1  y: 49  z: 49      a: 1  b: 0  c: 49  d: 1     1 + z^2 : 2402 =  2 1201
50  x: 1  y: 50  z: 50      a: 1  b: 0  c: 50  d: 1     1 + z^2 : 2501 =  41 61
50  x: 49  y: 10  z: 50      a: 5  b: 4  c: 6  d: 5     1 + z^2 : 2501 =  41 61

```

It is also easy enough to find all rational solutions by stereographic projection around a given rational solution.


