Pythagorean Triples

We wish to solve $ x^2 + y^2 = z^2 $ over the integers. Without loss of generality assume $x,y,z$ have no common factor. This implies that $z$ is odd (consider the equation modulo 4).

First we move to $\mathbb{Z}[i]$:

\[ (x+y i)(x-y i) = z^2 \]

Claim: $x + y i = u a^2$ where $u$ is a unit and $a \in \mathbb{Z}[i]$.

Proof: Suppose a prime $p$ divides $x + y i$. Then $p$ divides $z$, thus $p^2$ must divide both sides. If $p$ also divides $x - y i$, then it must also divide their sum $2x$. But $2x$ and $z$ are coprime, implying $p$ is a unit, which is a contradiction.

Hence we may write $x + y i = u (m + n i)^2$, from which we obtain all solutions

\[ \{x,y,z\} = \{ \pm(m^2 -n^2), \pm 2m n , \pm (m^2 + n^2) \} \]