I am looking for a method to generate Pythagorean Triples $(a,b,c)$. There are many methods listed on Wikipedia but I have a unique constraint that I can't seem to integrate into any of the listed methods.
I need to generate Pythagorean Triples $(a,b,c)$ such that:
$$a^2 + b^2 = c^2$$ $$a\lt b\lt c \,; \quad a,b,c \in \Bbb Z^+$$ $$and $$ $$b=a+1$$
Is there a way to modify one of the listed methods to include this constraint?
We give a way to obtain all solutions. It is not closely connected to the listed methods. However, the recurrence we give at the end can be expressed in matrix form, so has a structural connection with some methods in your linked list.
We want $2a^2+2a+1$ to be a perfect square $z^2$. Equivalently, we want $4a^2+4a+2=2z^2$, that is $(2a+1)^2-2z^2=-1$.
This is a Pell equation. One can give a recurrence for the solutions. One can also give a closed form that has a similar shape to the Binet closed form for the Fibonacci numbers.
Added: We can for example get all solutions by expressing $(1+\sqrt{2})^{2n+1}$, where $n$ is an integer, in the form $s+t\sqrt{2}$, where $s$ and $t$ are integers. Then $z=t$ and $2a+1=s$.
One can get a closed form from this by noting that $(1-\sqrt{2})^{2n+1}=s-t\sqrt{2}$. That gives us $$s=\frac{(1+\sqrt{2})^{2n+1} + (1-\sqrt{2})^{2n+1}}{2}.$$ There is a similar formula for $t$.
Remark: The following recurrence is probably more useful than the closed form.
If $(1+\sqrt{2})^{2n+1}=s_n+t_n\sqrt{2}$, then $(1+\sqrt{2})^{2n+3}=s_{n+1}+t_{n+1}\sqrt{2}$, where $$s_{n+1}=3s_n+4t_n,\qquad t_{n+1}=2s_n+3t_n.$$
This will let you quickly compute the first dozen or so solutions (the numbers grow fast). We start with $n=0$, which gives a degenerate triangle. For $n=1$, we get $s_1=7$, $t_1=5$, which gives the $(3,4,5)$ triangle. We get $s_2=41, t_2=29$, giving the triple $(20,21,29)$. And so on.