# Monday Math: Pythagorean Triples, cont.

Time to finish what we started last week.

We saw that if a, b, c was a primitive Pythagorean triple, then at least one of a and b is even and one is odd. Let us declare, then, that we will use a to denote the odd length and b to denote the even one. By rearranging the Pythagorean equation and factoring we get:

$a^2=c^2-b^2=(c+b)(c-b).$

Let’s try this out for a few specific triples:

$3^2=(5+4)(5-4)=(9)(1)$

$5^2=(13+12)(13-12)=(25)(1)$

$15^2=(17+8)(17-8)=(25)(9)$

$45^2=(53+28)(53-28)=(81)(25)$

In each case we find that c+b and c-b are both perfect squares. Even more important, they are relatively prime. Let’s see if we can prove that.

We begin by noting that, since b is even and c is odd, we have that c+b and c-b are both odd.

Now suppose that d is some number that divides both of them. We want to show that d has to be one. Since d divides both c+b and c-b, we must also have that d divides their sum and their difference. That is, d divides:

$(c+b)+(c-b)=2c \phantom{xxx} \textrm{and} \phantom{xxx} (c+b)-(c-b)=2b$

Recall, though, that we are discussing primitive Pythagorean triples. That means that b and c are relatively prime. It follows that d must divide 2, meaning that d=1 or d=2.

Having already established that c+b and c-b are both odd, we know that d is not two. We conclude that d=1 as desired.

This is significant for the following reason: If the product of two relatively prime numbers is a perfect square, then the numbers must themselves be perfect squares. I won’t stop to prove that here, though it is straightforward if you think in terms of prime factorizations.

We can now write

$c+b=s^2 \phantom{xxx} \textrm{and} \phantom{xxx} c-b=t^2,$

where s and t are odd, relatively prime integers. But now we can solve for b and c to obtain

$c= \frac{s^2+t^2}{2} \phantom{xxxx} \textrm{and} \phantom{xxxx} b=\frac{s^2-t^2}{2},$

from which it follows that

$a=st.$

And we’re done! So long as s and t are odd and relatively prime, these formulas will give you a primitive Pythagorean triple. Moreover, all such triples can be produced in this way. For example, choosing s=3 and t=1 gives you (3,4,5) and choosing s=5 and t=1 gives you (5,12,13).

As was pointed out in the comments to last week’s post, we could also take a purely geometric approach to this problem. Notice that if (a,b,c) is a Pythagorean triple, then we have

$\left( \frac{a}{c} \right)^2 + \left( \frac{b}{c} \right)^2 =1,$

meaning that any such triple corresponds to a rational point on the curve

$x^2+y^2=1$

That’s the equation for the unit circle. Imagine now that we draw a line, with rational slope m, through the point (-1,0). If you remember your elementary algebra you will see that the equation for this line is

$y=m(x+1)$

This line will hit the unit circle in exactly one other point, as shown below:

It is now a straightforward algebraic exercise to solve our equations simultaneously to work out the coordinates of the second point of intersection, which will be a rational point on the circle. When that is done, you quickly recover our formulas for producing Pythagorean triples. Very nice!

1. #1 Jon Wharf
January 24, 2011

Nice. I like the way you can clearly only get a prime leg when the even leg is within 1 of the hypoteneuse (a split-the-square triple).

Here’s my different derivation of a two parameter formula:

For a primitive pythagorean triple (p,q,r), p^2 + q^2 = r^2
Set p=r-m, q=r-n
(r-m)^2 + (r-n)^2 = r^2
Then r^2 – 2(m+n)r + (m^2+n^2) = 0
r = m + n + sqrt(2mn)
=> if m and n have a common factor then r also has that factor and (p,q,r) is not primitive
=> m,n coprime
sqrt(2mn) is integer => m, n are an odd square and half an even square.
Set m odd, => m=x^2 and n=y^2/2
For any coprime x odd and y even, (p,q,r)
p = y^2/2 + xy
q = x^2 + xy
r = x^2 + y^2/2 + xy
is a primitive pythagorean triple. I think t=x and s=x+y is the mapping to your solution.

Incidentally I was wrong, last week, that x & y can be uniquely extracted from any natural number. So it remains a two-parameter formula.

2. #2 joemac53
January 24, 2011

My elementary algebra students got a kick out of breaking up odd perfect squares to make a pythagorean triple. The odd prime r^2, in the form 2n +1, could be broken into n and n+1. Those two and r made the triple.

Those freshman tortured the upperclassmen for a few days. I would teach them math parlor tricks, saying it would make them very popular at parties. They refused to believe me.

January 24, 2011

You can also note that every square is the sum of odd numbers Σ(n=0 to k) 2n+1=k^2 That means that every odd square (2k+1)^2 forms a primitive triple of the form [(2k+1), (2k^2+2k), (2k^2+2k+1)]. This generates an infinite number of primitive triples.

4. #4 David Winfrey
January 25, 2011

Here’s a similar question; I’m not sure how closely it’s related, or whether it has a solution.

For y = ax**2 – bx + c, where the coefficients are positive integers, is there any way to find the smallest positive integer x such that y is a square?

This arises out of an attempt to find prime factors of large composites, so it may not be possible.

5. #5 Jon Wharf
January 25, 2011

Also note that my method does not need to “know” in advance whether p,q and r are odd or even, or anything about patterns of squares.

That’s probably why I found it :-).

The other thing I should have noted is that it tells us directly that the difference between the two leg lengths is constrained to be a difference between an odd square and half an even square (that is coprime to the odd square).

6. #6 parisa
February 5, 2011

Hi