Skip to main content

Section 3.4 Pythagorean Triples

Subsection 3.4.1 Definition

There are a lot of other interesting questions that one can ask about pure integers, and polynomial equations they might satisfy (so-called Diophantine equations). However, answering many of those questions will prove challenging without additional tools, so we will have to take a detour soon. But one such question is truly ancient, and worth exploring more in this chapter.

It is also quite geometric. We just used the Pythagorean Theorem above, but you'll note that we didn't really care whether the hypotenuse was an integer there. Well, when is it? More precisely:

Question 3.4.1.

When are all three sides of a right triangle integers?

Definition 3.4.2.

We call a triple of integers \(x,y,z\) such that \(x^2+y^2=z^2\) a Pythagorean triple.

There isn't necessarily evidence that Pythagoras thought this way about them. However, Euclid certainly did, and so will we. For that matter, we should also think of them as \(x,y,z\) that fit on the quadratic curve \(x^2+y^2=z^2\text{,}\) given \(z\) ahead of time.

Let's try this out for a little bit – on paper or with this applet. When do we get a triple? (Keep in mind that we will always expect the triple \((z,0,z)\) and \((0,z,z)\) where \(0^2+z^2=z^2\text{,}\) but that's not really what we are interested in.)

Subsection 3.4.2 Characterizing Pythagorean triples

When exploring, it can seem quite unpredictable for which \(z\) there exists a Pythagorean triple! (We'll return to that question later.) Let's see what triples are possible overall.

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.

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.

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 …

Remark 3.4.8.

One can find many infinite subfamilies of Pythagorean triples. A nice brief article by Roger Nelsen [E.7.18] shows that there are infinitely many Pythagorean triples giving nearly isosceles triangles (where the smaller sides are just one unit different). What families can you find?

Subsection 3.4.3 Areas of Pythagorean triangles

Subsubsection 3.4.3.1 Which areas are possible?

Historically, one of the big questions one could ask about such Pythagorean integer triangles was about its area. For primitive ones, the legs must have opposite parity (do you remember why?), so the areas will be integers. (For ones which are not primitive, the sides are multiples of sides with opposite parity, so they are certainly also going to have an integer area.)

So what integers work? You all know one such triangle with area 6, and it should be clear that ones with area 1 and 2 can't work (because the sides would be too small and because \(2,1\) doesn't lead to a triple); can you find ones with other areas?

It is worth asking why there are no odd numbers in the list so far. In fact, we can prove quite a bit about these things.

Remember that in a primitive triple, \(x\) and \(y\) can be written as \(x=q^2-p^2\) while \(y=2pq\text{,}\) for relatively prime opposite parity \(q>p\text{.}\) Then the area must be

\begin{equation*} pq(q^2-p^2)=pq(q+p)(q-p)\text{.} \end{equation*}

So can the area be odd? The following proposition helps answer this (Exercise 3.6.15) and many other questions.

We already know that \(p\) and \(q\) are coprime, and that this is the correct formula for the area.

The factors \(p\) and \(p+q\) must also share no factors, since any factor they share is shared by \((p+q)-p=q\text{,}\) but \(\gcd(p,q)=1\text{.}\) The same argument will work in showing that \(p\) and \(q-p\) are, as well as \(q\) and either sum.

If \(q+p\) and \(q-p\) share a factor, since they are odd it must be odd, and it must be a factor of their sum and difference \(2q\) and \(2p\text{.}\) Since the putative factor is odd, it is coprime to \(2\text{,}\) and so we can use Proposition 2.4.10 to say that it is a factor of both \(p\) and \(q\text{,}\) which is impossible unless said factor is \(1\text{.}\)

So one could analyze a number to see if it is possible to write as a product of four relatively prime integers as a starting point. For example, the only way to write \(30\) in such a way (assuming no more than one of them is 1) is \(30=2\cdot 3\cdot 5\cdot 1\text{.}\) Since \(q+p\) must be the biggest, we must set \(q+p=5\text{.}\) Quickly one can see that \(q=3,p=2\) works with this, so there is such a triangle. (A quick exercise is to determine the sides of this triangle.) See Exercise 3.6.16.

Trying to see if an integer is the area of a Pythagorean triangle turns out to be a very deep unsolved problem. This linked news update from the American Institute of Mathematics gives some background on the congruent number problem, which asks the related question of which Pythagorean triangles with rational side lengths give integer areas. This linked page in particular is interesting from our present point of view.

Subsubsection 3.4.3.2 Which areas are square?

But we can ask another question, which led Fermat (see Historical remark 13.0.4) to some of his initial investigations into this theory.

Question 3.4.10.

When is the area of a Pythagorean triple triangle a perfect square?

You'll notice by the empty output that we don't seem to be getting a lot of these. In fact, none. What would we need to do to investigate this?

In the previous section, we noted that each of the factors in the area, \(pq(q^2-p^2)=pq(q+p)(q-p)\text{,}\) are relatively prime to each other. So if the area is also a perfect square, then since the factors are coprime, we use Proposition 3.7.2 again to see they themselves are all perfect squares!

Now we will do something very clever. It is a proof strategy, similar to something the Greeks used occasionally, which Fermat used for many of his proofs, called infinite descent. We are going to take that (hypothetical) triangle, and produce a triangle with strictly smaller sides but otherwise with the same properties – including integer sides and square area! That means we could apply the same argument to our new triangle, and then the next one … But the Well-Ordering Principle (Axiom 1.2.1) won't allow infinite sets of positive integers less than a certain number – which yields the name of the proof technique! Then (by way of contradiction) the original triangle was impossible to begin with.

So let's make that smaller triangle!

We use the same notation as in Proposition 3.4.9. We know that \(q+p\) and \(q-p\) are (odd) squares. Call them \(u^2\) and \(v^2\text{.}\) That means that we can write \(u\) and \(v\) as \(\frac{u+v}{2}+\frac{u-v}{2}\) and \(\frac{u+v}{2}-\frac{u-v}{2}\) (which are integers since \(u\) and \(v\) are odd).

Letting \(a=\frac{u+v}{2}\) and \(b=\frac{u-v}{2}\text{,}\) we have that \(q+p=(a+b)^2\) and \(q-p=(a-b)^2\text{.}\) Then a little algebra (do it slowly if you don't see it right away) shows that \(q=a^2+b^2\) and \(p=2ab\text{.}\) These are both squares, so \(a^2+b^2=q=c^2\) (!), which defines a triangle with area \(\frac{ab}{2}=\frac{2ab}{4}=\frac{p}{4}\text{,}\) another perfect square.

Now let's compare \(c\) and \(z\text{.}\) We have \(z=q^2+p^2=\left(c^2\right)^2+p^2=c^4+p^2\text{,}\) so that unless \(p=0\text{,}\) \(c\) is strictly less than \(z\text{.}\) But \(p=0\) doesn't give a triangle at all! So we have our strictly smaller triangle satisfying the same properties.

If so, we can use the previous proposition infinitely often and violate Axiom 1.2.1, a contradiction.

In the proof of the proposition, we really showed that there is no pair \(p\) and \(q\) of (coprime) squares such that \(q^2-p^2\) is also a perfect square \(t^2\text{;}\) that is what we started with, after all. So, if \(p=u^2\) and \(q=v^2\) we have that

\begin{equation*} v^4-u^4=t^2 \end{equation*}

is impossible.

In Exercise 3.6.17 you will use this to prove the famous first case of Fermat's Last Theorem: There are no three positive integers \(x,y,z\) such that

\begin{equation*} x^4+y^4=z^4\text{.} \end{equation*}

See also Subsection 14.2.2.

See [E.5.9] and nearly any generalist math journal for a lot more information on Pythagorean triples; the search is the reward!