<s>[INST] Formulas for calculating pythagorean triples I'm looking for formulas or methods to find pythagorean triples. I only know one formula for calculating a pythagorean triple and that is euclid's which is:
$$\begin{align}
&a = m^2-n^2 \\
&b = 2mn\\
&c = m^2+n^2 
\end{align}$$
With numerous parameters.
So are there other formulas/methods?
 [/INST] Here is the method I use:


*

*Take a number $c >= 1$

*Find all pairs $a, b$ such that $ab = 2c^2$

*For every pair of $a, b$ you get an unique solution $x = a + 2c, y = b + 2c, z = a + b + 2c$. It can be easily proven that $x^2 + y^2 = z^2$ is reduced to $4c^2 = 2ab$ which is satisfied at point 2.


The advantage of this method is that you can get all possible triplets. For example with $c = 3, a = 3, b = 6$ a triplet $9, 12, 15$ is found, which cannot be found with euclid's formula. 
It can be proven that this method give all possible triplets. If there is a pythagorean triplet $x, y, z$ than it can be represented in a form $x = a + 2c, y = b + 2c, z = a + b + 2c$ such that $ab = 2c^2$:


*

*We have $x^2 + y^2 = z^2$

*$a = z - y, b = z - x, c = (x + y - z) / 2$

*Now we have to prove that $ab = 2c^2$

*$ab = (z - y)(z - x) ? 2c^2 = (x + y - z)^2 / 2$

*$z^2 - yz - xz + xy ? (x^2 + y^2 + z^2 + 2xy - 2xz - 2yz) / 2$

*$2z^2 - 2yz - 2xz + 2xy ? x^2 + y^2 + z^2 + 2xy - 2xz - 2yz$

*After removing all repeating parts we get $z^2 ? x^2 + y^2$ which are equal. Done.

</s>