## Every Primitive Triplet

#### Problem

A Pythagorean triplet, $(a, b, c)$, is defined as a set of positive integers for which $a^2 + b^2 = c^2$. Furthermore, if the set is primitive it means that $a$, $b$, and $c$ share no common factor greater than 1.

Prove that the following identities will generate all primitive Pythagorean triplets and determine the conditions for $m$ and $n$.

$\begin{align}a &= m^2 - n^2\\b &= 2mn\\c &= m^2 + n^2\end{align}$

#### Solution

First we note that it is not sufficient to simply show that following identity holds:

$a^2 + b^2 = (m^2 - n^2)^2 + (2mn)^2 = (m^2 + n^2)^2 = c^2$

Although this is true, and can be verified, it would only demonstrate that the identities will produce Pythagorean triplets. It will not prove that they generate every primitive case. Instead we must analyse the necessary conditions of $a$, $b$, and $c$ to derive these identities deductively.

Clearly $a$ and $b$ cannot both be even, otherwise, $a^2 + b^2 = c^2$ would be even, and as $a$, $b$, and $c$ would all be even and it would not be primitive.

If $a$ and $b$ were both odd then $a^2 + b^2 \equiv 2 \mod 4$, but $c^2 \equiv 0, 1 \mod 4$; that is, the square of any number is either divisible by 4 or has a remainder of 1.

Therefore exactly one of $a$ and $b$ is even, and it follows that $c$ will be odd.

Without loss of generality, let $b$ be even.

$\therefore b^2 = c^2 - a^2 = (c + a)(c - a)$

$\therefore \dfrac{b^2}{4} = \left ( \dfrac{b}{2} \right )^2 = \dfrac{c+a}{2} \dfrac{c-a}{2}$

As $a$ and $c$ are both odd, $c + a$ and $c - a$ will be even, and we know that $\left ( \dfrac{b}{2} \right )^2$, $\dfrac{c + a}{2}$, and $\dfrac{c - a}{2}$ will all be integer.

As the LHS is square, the RHS must be square and as $a$, $b$, and $c$ share no common factor greater than 1, both terms on the right must each be square.

Let $m^2 = \dfrac{c + a}{2}$ and $n^2 = \dfrac{c - a}{2}$.

$\therefore \dfrac{b^2}{4} = m^2 n^2 \implies b^2 = 4m^2 n^2 \implies b = 2mn$

$m^2 + n^2 = \dfrac{c+a}{2} + \dfrac{c-a}{2} = c$

Similarly $m^2 - n^2 = a$.

As we have deduced these identities from first principles we know that all primitve triplets will be derived from them. Let us now consider the conditions for $m$ and $n$.

Clearly $m \gt n$ otherwise $a \le 0$. Also $GCD(m, n) = 1$, otherwise, $a$, $b$, and $c$ would share a common factor greater than 1. If $m$ and $n$ were both odd then $m^2 + n^2$ and $m^2 - n^2$ would be even, and as $b = 2mn$, we would again have a common factor of 2 with $a$, $b$, and $c$.

Hence for every $m \gt n$, $GCD(m, n) = 1$, and $m + n \equiv 1 \mod 2$, $a = m^2 - n^2$, $b = 2mn$, and $c = m^2 + n^2$ will produce a primitive Pythagorean triplet.

NOTE: If we only insist that $m \gt n$, then the identities will produce non-primitive cases also. However, it is a common misconception to believe that this implies that the identities will produce every triplet (primitive and non-primitive cases). As a single example it can be quickly verified that no values of $m$ and $n$ will ever produce the non-primitive case, (9, 12, 15).