Subsubsection 3.4.2.1 Preliminaries
First, it turns out we really only need to worry about the case when
\(x,y,z\) are mutually relatively prime (
Definition 2.4.9).
Definition 3.4.3.
A Pythagorean triple with \(x,y,z\) mutually relatively prime is called a primitive Pythagorean triple.
Proposition 3.4.4.
Any Pythagorean triple with two numbers sharing a factor can be reduced to a primitive triple.
Proof.
If \(x=x'a\) and \(y=y'a\text{,}\) for instance, then
\begin{equation*}
x^2+y^2=(x')^2a^2+(y')^2a^2=z^2
\end{equation*}
which means that
\(a^2\mid z^2\text{,}\) and hence that
\(a\mid z\) as well. The other cases are similar. (One can prove the last statement with the gcd and Bezout as well, but I trust you believe it for now. See below in
Proposition 3.7.1.)
So let’s consider just the case of primitive triples. In just a little while we will discover we have the proof of a result,
Theorem 3.4.6.
We can start with very elementary considerations of even and odd. By the previous proposition, \(x\) and \(y\) can’t both be even.
I claim they can’t both be odd, either. For if they were, we would have \(x=2k+1\) and \(y=2\ell+1\) for some integers \(k,\ell\text{,}\) and then
\begin{equation*}
(2k+1)^2+(2\ell+1)^2=4\left(k^2+\ell^2+k+\ell\right)+2
\end{equation*}
But this contradicts
Proposition 2.1.4 with respect to the remainder of a perfect square when divided by four.
So we may assume without loss of generality that \(x\) is odd and \(y\) is even, (which means \(z\) is odd).
Subsubsection 3.4.2.2 An intricate argument
We have now reduced our investigation to the following case: we assume that \(\gcd(x,y,z)=1\text{,}\) that \(x,z\) are odd, and that \(y\) is even. Now we will do a somewhat intricate, but familiar, type of argument about factorization and divisibility.
Let’s rewrite our situation as
\begin{equation*}
y^2=z^2-x^2\text{.}
\end{equation*}
The right-hand side factors as
\begin{equation*}
z^2-x^2=(z-x)(z+x)\text{.}
\end{equation*}
Certainly \(z-x\) and \(z+x\) are both even, so that \(z-x=2m\) and \(z+x=2n\) for integer \(m,n\text{.}\) But since their product is a square (\(y^2\)), then that product \(2m\cdot 2n=4mn\) is also a perfect square. Since \(y\) is even, \(y=2j\) for some \(j\in\mathbb{Z}\) and \(y^2=4j^2\text{,}\) so \(mn=j^2\) is a perfect square.
Let’s look at these mysterious factors \(m=\frac{z-x}{2}\) and \(n=\frac{z+x}{2}\text{.}\) Are they relatively prime? Well, if they shared a factor, then \(x=n-m\) and \(z=m+n\) also share that factor. But \(\gcd(x,z)=1\text{,}\) so there are no such factors and
\begin{equation*}
\gcd\left(\frac{z-x}{2},\frac{z+x}{2}\right)=\gcd(m,n)=1\text{.}
\end{equation*}
As a result, not only do we have \(j^2=mn\text{,}\) but actually \(m\) and \(n\) are relatively prime!
At this point we need what may seem to be an intuitive fact about squares and division; if coprime integers make a square when multiplied, then they are each a perfect square. (See
Proposition 3.7.2.) So
\(m=p^2\) and
\(n=q^2\) for some integers (obviously coprime)
\(p\) and
\(q\text{.}\)
This clearly implies that \(j^2=p^2q^2\text{,}\) so \(y=2pq\text{.}\) In addition, if we go back to the definitions of \(m,n\) above, we obtain \(z-x=2p^2\) and \(z+x=2q^2\text{.}\)
Subsubsection 3.4.2.3 The punch line
Now we can put everything together. We begin with a useful definition.
Definition 3.4.5.
We say two integers \(p,q\) have opposite parity if one is even and the other is odd, and we say they have the same parity otherwise.
Theorem 3.4.6. Characterization of primitive Pythagorean triples.
For a primitive triple \(x,y,z\text{,}\) where \(x\) is odd, there exist integers \(p,q\) such that
\begin{equation*}
z=p^2+q^2,\; x=q^2-p^2,\; \text{ and }y=2pq\text{.}
\end{equation*}
Further, \(p\) and \(q\) must have opposite parity as well as be coprime.
Algorithm 3.4.7.
We can find
all primitive Pythagorean triples by finding coprime integers
\(p\) and
\(q\) which have opposite parity, and then using the formula in
Theorem 3.4.6. We can obtain
all Pythagorean triples by multiplying primitive triples by an integer greater than one.
It’s really worth trying to find these by hand; it gives one a very good sense of how this all works.
Of course, you could generate some by computer as well …