## Theorem 30: Pythagorean triples

If I asked you to give a list of mathematical theorems, I suspect that you might well think of Pythagoras‘s theorem pretty early on.  It has the rare distinction of being a theorem that’s commonly discussed (by name) in maths classes in schools today.  It should probably be a theorem of the week in its own right, but for today I’d like to focus on some rather lovely number theory associated with it.

Let’s quickly remind ourselves what Pythagoras’s theorem says.  Here’s a right-angled triangle.

The theorem says that $a^2 + b^2 = c^2$: the square on the hypotenuse is equal to the sum of the squares on the other two sides.  There are a lot of proofs of this, but they’ll have to wait for a future post, I’m afraid!

I think that a lot of people discover, in the course of their studies of Pythagoras’s theorem at school, that there are some particularly nice right-angled triangles.  One has side lengths 3, 4, 5 (quick check: $3^2 + 4^2 = 9 + 16 = 25 = 5^2$).  Another has side lengths 5, 12, 13 (check: $5^2 + 12^2 = 25 + 144 = 169 = 13^2$).  Another has side lengths 6, 8, 10 (check: $6^2 + 8^2 = 36 + 64 = 100 = 10^2$).  Of course, these are particularly nice because the side lengths are all whole numbers (integers).  I’m going to concentrate on such solutions in this post.

This leads to lots of interesting questions.  Are there more solutions (with integer side lengths)?  How many more?  Are there infinitely many?  How can we find more solutions?  Can we find them all?  Are some more interesting than others?  Are there any interesting patterns?  How can we possibly hope to solve a single equation in three variables?  I encourage you to think about these questions before reading on.  (You could, for example, look for more solutions from yourself and see where you can go from there.)  You might also have your own questions that you’d like to consider, of course.

Let’s think about the solutions we’ve seen so far.

I don’t think that 6, 8, 10 is a very interesting solution, because it’s just twice a solution we’d already seen (3, 4, 5).  We could generate infinitely many solutions in this way, just by multiplying by different positive integers.  (If you have doubts, you might like to convince yourself of this algebraically.)  So that would give infinitely many solutions, but it doesn’t feel to me that we should really count them as different.  I’d like to concentrate on solutions (a,b,c) where the side lengths aren’t all divisible by some number (they have no common factor bigger than 1: they are coprime).  These are called primitive solutions.  So I’m interested in (3,4,5) and (5, 12, 13), but I’m going to ignore (6, 8, 10) and (9, 12, 15) and (12, 16, 20) and (10, 24, 26) and so on.

Can we answer any of our questions above, now that we’ve got this extra rule?

Let’s suppose we’ve got a primitive solution, and see what we can say about it.  Perhaps that will help us to learn something useful.  So let’s suppose we’ve got three positive integers $(a,b,c)$ such that $a^2 + b^2 = c^2$, and let’s assume that the highest common factor of $a$, $b$ and $c$ is 1.

Where can we go from here?  In such cases, it’s sometimes helpful to start eliminating possibilities by considering parities (whether numbers are odd or even).  Let’s think about the parities of $a$ and $b$.

If $a$ and $b$ are both even, then $c$ must be even too (using $a^2 + b^2 = c^2$).  But then $a$, $b$ and $c$ have 2 as a common factor, and that contradicts one of our assumptions.  So $a$ and $b$ cannot both be even.

If $a$ and $b$ are both odd, then $a^2 + b^2 \equiv 2$ (mod 4).  But, as we’ve seen before, 2 is not a square (mod 4) (there are no square numbers that leave 2 on division by 4), so there are no solutions to the congruence $c^2 \equiv 2$ (mod 4).  So $a$ and $b$ cannot both be odd.

So one of $a$ and $b$ is odd, and the other even.  Without loss of generality, we can assume that $a$ is odd and $b$ even.  Let’s say that $b = 2b'$, where $b'$ is another positive integer.

We have coprime positive integers $a$, $b'$ and $c$ such that $a^2 + 4b'^2 = c^2$.  Can we say any more?  We have a single equation in three variables, so we can’t possibly expect to find a unique solution (of course, as we know there are multiple solutions — we’ve seen some already!), but we have the extra information that $a$, $b'$ and $c$ are integers, and that might help us to draw conclusions (as it has already done).

My eye was drawn to rearranging this equation to give $c^2 - a^2 = 4b'^2$, because I know that $c^2 - a^2$ is the difference of two squares, and so factorises nicely: $c^2 - a^2 = (c-a)(c+a)$.  So we know that $(c-a)(c+a) = 4b'^2$.  This feels promising to me, because everything in sight is a whole number, so the options are greatly reduced.  In particular, the product $(c-a)(c+a)$ must be divisible by 4.  We know that $a$ is odd; let’s think about the possibilities for $c$.

If $c$ is even, then $c-a$ and $c+a$ are both odd, so their product is odd.  That’s no good.

So $c$ must be odd.  Then $c-a$ and $c+a$ are both even (and their product is divisible by 4).  Let’s say that $c+a = 2m$ and $c-a = 2n$, where $m$ and $n$ are positive integers with $m > n$.  Then $a = m-n$ and $c = m+n$.

That makes our equation into $mn = b'^2$.  Can we draw any conclusions from that?  It might be tempting to suggest that $m$ and $n$ must be squares (since their product is a square).  In general, that isn’t true.  For example, $3 \times 12 = 6^2$.  But in fact it is true in this case, because $m$ and $n$ are coprime.  (If the prime $p$ divides $m$ and $n$, then $p$ divides $a = m-n$ and $c = m+n$, and also $p$ divides $b'$ and so $b$ — but that contradicts our assumption that $a$, $b$ and $c$ are coprime.)  Unique factorisation then allows us to conclude that $m$ and $n$ are squares, say $m = r^2$ and $n = s^2$.

Now we have $a = r^2 - s^2$, $b=2rs$, and $c = r^2 + s^2$.  To recap: if $(a,b,c)$ is a solution, and if $a$, $b$ and $c$ are coprime, then they must be of the form $a=r^2-s^2$, $b = 2rs$, $c = r^2 + s^2$, for some positive integers $r$ and $s$ with $r > s$.  So all the primitive solutions must be of this form.  But does every triple of this form give a solution?

Let’s see.  We can just do the algebra.  We have $a^2 + b^2 = (r^2-s^2)^2 + (2rs)^2 = r^4 - 2r^2s^2+s^4+4r^2s^2=r^4+2r^2s^2+s^4=(r^2+s^2)^2=c^2$, so we do indeed always get a solution.  We do not necessarily get a primitive solution (where the side lengths are coprime), though.  For example, $r=3$ and $s=1$ gives $a=8$, $b=6$, $c=10$.

But let’s be a bit more careful.  We know that with our primitive solution we had $a$ and $c$ odd, so one of $m$ and $n$ must be odd and the other even.  The same must apply to $r$ and $s$  We also saw that we must have $m$ and $n$ coprime, so $r$ and $s$ must be coprime.  If we impose those conditions (which would rule out $r=3$, $s=1$), do we necessarily get a primitive solution?  It turns out that we do.  You might like to check this for yourself (it’s not too hard).  And that gives this week’s theorem.

Theorem A triple of coprime positive integers $(a,b,c)$ is a solution to the equation $a^2+b^2 = c^2$ if and only if it has the form $(r^2-s^2,2rs,r^2+s^2)$ for some coprime positive integers $r$ and $s$, where $r>s$ and exactly one of $r$ and $s$ is even.

Wikipedia reveals that this is a theorem of Euclid.

In particular, this theorem tells us that there are infinitely many primitive solutions, but it tells us much more than that, because it describes all of  them.  It doesn’t get much better than that!

Wikipedia has lots of fascinating facts about Pythagorean triples.  It also gives some other ways to generate such triples.  Solving an equation like this (where the solutions have to be integers) belongs to the study of Diophantine equations, a key branch of number theory (named after Diophantus of Alexandria).  As I’ve previously noted, it was in Bachet‘s translation of Diophantus that Fermat made his marginal note about what has possibly become the most famous Diophantine equation (inspired by Pythagoras’s equation above).
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 120, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}