Generating all the Pythagorean triples by factorizing using complex numbers Can anyone help me generate all the triplets solution of the Diophantine equation:  $a^2+b^2=c^2$ by factoring using Complex numbers? thanks.
 A: It's a standard procedure. 
First you reduce to triples in which $\gcd(a, b) = 1$.
Then you prove, arguing modulo $4$, that $a$ and $b$ have different parities.
Now you have $c^{2} = a^{2} + b^{2} = (a + i b) (a - i b)$.
Prove that $\gcd(a + i b, a - i b) = 1$ in the ring of Gaussian integer. (The fact that $a$ and $b$ have different parities will play a role here.)
Deduce that $a \pm i b$ are squares (up to a unit) in the Gaussian integer.
This will give you the required formula.
A: Here’s one way: Consider a $\mathbb Z$-prime $p$ with $p\equiv1\pmod4$, like $13$, which according to a well-known theorem is the sum of two squares, $13=3^2+2^2$. Factor it into $\mathbb Z[i]$-primes, $13=(3+2i)(3-2i)$. Now divide one of these primes by the other, $(3+2i)/(3-2i)=(5+12i)/13$. Note that you see the three numbers of a Pythagorean triple there.
For your amusement, note that $\frac5{13}+\frac{12}{13}i$ is a point on the unit circle with rational coordinates, and that any such gives you a Pythagorean triple. Note also that the set of all such points forms a group under complex multiplication. This is an infinitely-generated commutative group, and when you factor out the units $\{\pm1,\pm i\}$, you get a free $\mathbb Z$-module, whose basis may be taken to be the numbers $z_p=\alpha_p/\,\overline{\alpha_p}$, where $p=\alpha_p\overline{\alpha_p}$ is a factorization of the prime $p\equiv1\pmod4$. This shows that every primitive Pythagorean triple can be gotten by multiplying finitely many of the $z_p$’s together and doing the computation above.
