An earlier post I made makes mention of relating Pell's equation to Pythagorean triples, and it turns out that you can just solve for Pythagorean triples using solutions from certain Pell's equations:
Given x2 - Dy2 = 1, and x = 1 mod D or x = -1 mod D, from the prior post I reference above I have that
(D-1)j2 + (j+1)2 = (x+y)2
(D-1)j2 + (j-1)2 = (x+y)2
j = ((x+Dy)-1)/D or j = ((x+Dy)+1)/D
which gives a Pythagorean triple whenever D-1 is a square, for instance with D=2, I have a solution with x=17, y=12, as 172 - 2(12)2 = 1, so
j = ((17+2(12))-1)/2 = 20 is a solution giving:
202 + 212 = 292
Notice that different types of Pythagorean triples are included as D increases in size, as for instance, with D=5, you have triples of the form:
(2j)2 + (j+/-1)2 = (x+y)2
(where I use "+/-" as an OR as above as it's less tedious)
so given a solution to x2 - 5y2 = 1, you have solutions.
e.g. x=9, y = 4, works as 92 - 5(4)2 = 1, so j = (9 + 5(4) + 1)/5 = 6 is a solution. And then
122 + 52 = 132.
Notice too that when D-1 is not a square you get integer solutions to ellipses, and you also get the result that with a natural number n, there are always an infinity of integer, non-zero solutions to the equation: nu2 + v2 = w2
The question now arises, can you go in the other direction and solve for a Pell's equation using a Pythagorean triple?
The answer is, yes. Consider, 242 + 72 = 252.
If 7 is j+/-1, I can try j = 6 or 8, and find D=17 or D=10.
With j=6, D=17, I have j = ((x+Dy) -/+1)/D, so
17(6) = x+17y -/+ 1, so x+17y = 17(6)+/-1, and x+y = 25, so
16y = 17(6)+/-1 - 25, which doesn't give an integer y.
But trying j=8, D=10:
x+10y = 10(8)+/-1, so 9y = 10(8)+/-1 - 25, gives y = 6 as a solution, so x = 19, and
192 - 10(6)2 = 1.
So you can go in either direction.
Which then proves an infinite number of solutions to the more general form of Pell's Equation.