The Math Forum

Ask Dr. Math: FAQ

   Pythagorean Triples   

Dr. Math FAQ || Classic Problems || Formulas || Search Dr. Math || Dr. Math Home

What is a Pythagorean triple? What do Pythagorean triples have to do with Fermat's Last Theorem?

A Pythagorean triple is a set of three positive whole numbers a, b, and c that are the lengths of the sides of a right triangle. This means that a, b, and c satisfy the equation from the Pythagorean Theorem, namely

a2 + b2 = c2.

The smallest example is a = 3, b = 4, and c = 5. You can check that

32 + 42 = 9 + 16 = 25 = 52.

Sometimes we use the notation (a,b,c) to denote such a triple.

Notice that the greatest common divisor of the three numbers 3, 4, and 5 is 1. Pythagorean triples with this property are called primitive. From primitive Pythagorean triples, you can get other, imprimitive ones, by multiplying each of a, b, and c by any positive whole number d > 1. This is because

a2 + b2 = c2   if and only if   (da)2 + (db)2 = (dc)2.

Thus (a,b,c) is a Pythagorean triple if and only if (da,db,dc) is. For example, (6,8,10) and (9,12,15) are imprimitive Pythagorean triples.

Formulas for Primitive Pythagorean Triples and Their Derivation

Suppose that we start with a primitive Pythagorean triple (a,b,c). If any two of a,b,c shared a common divisor d, then, using the equation

a2 + b2 = c2,

we could see that the d2 would have to divide the square of the remaining one, so that d would have to divide all three. This would contradict the assumption that our triple was primitive. Thus no two of a, b, and c have a common divisor greater than 1.

Now notice that not all of a, b, and c can be odd, because if a = 2x + 1, b = 2y + 1, and c = 2z + 1, then the equation would be

(2x+1)2 + (2y+1)2 = (2z+1)2,
4x2 + 4x + 1 + 4y2 + 4y + 1 = 4z2 + 4z + 1,
4(x2 + x + y2 + y - z2 - z + 1) = 3.

This implies that 4 is a divisor of 3, which is false. Now suppose that c were even, and a and b odd, so a = 2x + 1, b = 2y + 1, and c = 2z. Now the equation would be

(2x+1)2 + (2y+1)2 = (2z)2,
4x2 + 4x + 1 + 4y2 + 4y + 1 = 4z2,
4(x2 + x + y2 + y - z2 + 1) = 2.

This implies that 4 is a divisor of 2, which is also false. Thus either a or b must be even, and the other two odd. Let's say it is b that is even, with a and c odd. (If not, switch the meanings of a and b in what follows below.)

Now rewrite the equation in the form

b2 = c2 - a2,
(b/2)2 = ([c - a]/2)([c + a]/2).

Notice that since b is even and a and c are odd, b/2, (c - a)/2, and (c + a)/2 are whole numbers, and all are positive. Now we claim that the greatest common divisor of (c - a)/2 and (c + a)/2 is 1. If d is any common divisor of these, then d would divide their sum, c, and their difference, a. We know, however, that the greatest common divisor of a and c is 1, so d must divide 1, so d = 1.

This gives us the product of two whole numbers, (c - a)/2 and (c + a)/2, whose greatest common divisor is 1, and whose product is a square. The only way that can happen is if each of them is a square itself. This means that there are positive whole numbers r and s such that

r2 = (c + a)/2,
s2 = (c - a)/2,
rs = b/2.

Furthermore, r > s, because r2 = s2 + a > s2, and s > 0, because c > a. In addition, since r2 and s2 have greatest common divisor 1, likewise r and s have greatest common divisor 1. Lastly, r and s can't both be odd, or else r2 - s2 = a would be even, which it isn't, and they can't both be even since 2 can't be a common divisor. This means that one of r and s is odd and one is even; hence r - s is odd.

Now, solving the above three equations for a, b, and c, we find that, for primitive Pythagorean triples,

a = r2 - s2,
b = 2rs,
c = r2 + s2,
r > s > 0 are whole numbers,
r - s is odd, and
the greatest common divisor of r and s is 1.

To see that the a, b, and c defined by these formulas do form a Pythagorean triple, just check the equation:

a2 + b2=(r2 - s2)2 + (2rs)2,
=r4 - 2r2s2 + s4 + 4r2s2,
=r4 + 2r2s2 + s4,
=(r2 + s2)2,

The above formulas for a, b, and c are the most general formulas for primitive Pythagorean triples. To every pair of whole numbers r and s satisfying those conditions, there corresponds a primitive Pythagorean triple, and to every Pythagorean triple, there corresponds a pair of whole numbers r and s satisfying those conditions. To find r and s given a, b, and c, use

r = sqrt([c + a]/2),
s = sqrt([c - a]/2).

Table of Small Primitive Pythagorean Triples

Here is a table of the first few primitive Pythagorean triples (Michael Somos provides a larger Pythagorean Triple Table on the Web):

rs ab c

Formulas for All Pythagorean Triples

To include all Pythagorean triples, both primitive and imprimitive, we let d > 0 be a whole number, and set

a = (r2 - s2)d,
b = 2rsd,
c = (r2 + s2)d,
r > s > 0 and d > 0 are whole numbers,
r - s is odd, and
the greatest common divisor of r and s is 1.

These formulas represent every Pythagorean triple. Given a Pythagorean Triple, we can recover d, r, and s using

d = GCD(a,b,c),
r = sqrt([c + a]/[2d]),
s = sqrt([c - a]/[2d]).

There is a one-to-one correspondence between Pythagorean triples and sets of values of the three parameters r, s, and d satisfying the conditions given above.

Perimeter, Area, Inradius, and Shortest Side

The perimeter P and area K of a Pythagorean triple triangle are given by

P = a + b + c = 2r(r + s)d,
K = ab/2 = rs(r2 - s2)d2.

The radius of the inscribed circle, or inradius, is always a whole number, and is given by the formula s(r-s)d.

To determine the shortest side, it will be a if

a < b,
r2 - s2 < 2rs,
(r - s)2 < 2s2,
r - s < s sqrt(2),
r < s(1 + sqrt[2]).

Similarly, the shortest side will be b if r > s(1 + sqrt[2]).

What About Higher Powers?

The equation an + bn = cn, n > 2, a, b, and c positive whole numbers, has no solutions. This statement is called "Fermat's Last Theorem." In the 17th century Pierre de Fermat conjectured that this equation has no solutions. This famous problem withstood the attacks of the mathematical world for more than three centuries. It was finally proved in the 1990's by Andrew Wiles, with help from Richard Taylor, using extremely advanced methods.

If we allow more terms, the equation

a3 + b3 + c3 = d3

does have solutions, such as (3,4,5,6). So does

a4 + b4 + c4 = d4,

the smallest being (95800,217519,414560,422481).

    From the Dr. Math archives:

    On the Web:

[Privacy Policy] [Terms of Use]

Math Forum Home || Math Library || Quick Reference || Math Forum Search

Ask Dr. Math ®
© 1994- The Math Forum at NCTM. All rights reserved.