Navigation 
 Home 
 Search 
 Site map 

 Contact Graeme 
 Home 
 Email 
 Twitter

 Skip Navigation LinksMath Help > Number Theory > Pythagorean Triples > 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

a² + b² = c²,

we could see that d² 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)² + (2y+1)² = (2z+1)²,
4x² + 4x + 1 + 4y² + 4y + 1 = 4z² + 4z + 1,
4(x² + x + y² + y - z² - 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)² + (2y+1)² = (2z)²,
4x² + 4x + 1 + 4y² + 4y + 1 = 4z²,
4(x² + x + y² + y - z² + 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

b² = c² - a²,
(b/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

r² = (c + a)/2,
s² = (c - a)/2,
rs = b/2.

Furthermore, r > s, because r² = s² + a > s², and s > 0, because c > a. In addition, since r² and s² 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 r² - s² = 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 = r² - s²,
b = 2rs,
c = r² + s²,
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:

a² + b² = (r² - s²)² + (2rs)²,
= r4 - 2r²s² + s4 + 4r²s²,
= r4 + 2r²s² + s4,
= (r² + s²)²,
= c².

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 triple (a,b,c), take a,c to be odd, and 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:

 r   s   a   b   c 
2 1 3 4 5
3 2 5 12 13
4 1 15 8 17
4 3 7 24 25
5 2 21 20 29
5 4 9 40 41
6 1 35 12 37
6 5 11 60 61
7 2 45 28 53

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 = (r² - s²)d,
b = 2rsd,
c = (r² + s²)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 (a,b,c) with common divisor d, and a/d and c/d are both odd, we can recover d, r, and s using

d = GCD(a,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.

Some interesting facts about Pythagorean Triples

If a, b, c is a Primitive Pythagorean Triple such that a²+b²=c² then one of a,b is a multiple of three, and one of a,b is a multiple of four.

Proof:

We showed, above, that exactly one of a and b is even (if both are even, it's not primitive; if neither is even then a²+b² isn't a square) so without loss of generality, we assume b is even.  That makes (c+a)/2 an integer, as well as (c-a)/2.

Let r = sqrt([c + a]/2), and
let s = sqrt([c - a]/2) are also integers, because...

(rs)² = r²s² = ([c+a]/2)([c-a]/2) = (c² - a²)/4 = (b/2)²
Since (b/2)² is a square and (c+a)/2 and (c-a)/2 are coprime (because the triple is primitive),
it follows that  (c+a)/2 and (c-a)/2 are both squares.  Also, it follows that r and s are coprime.

a = r² - s²,
and a is odd, so if r² is even, s² is odd, and vice-versa; exactly one of r and s is even.

b = 2rs, and since one of r and s is even, b is not only even, but it is a multiple of four as well.

That takes care of the "multiple of four" part of the proof.  Now for the "multiple of three" part...

If r or s is a multiple of 3 then b is a multiple of 3.  If neither one is a multiple of 3 then r²-1 = (r+1)(r-1) is a multiple of 3, and by the same logic so is s²-1.  So the difference r²-s² is a multiple of 3, so a is a multiple of 3.

Hard Question: Prove the area isn't a square number

An interesting problem was posed on algebra-online.com in the beginning of September, 2000:

Prove that the area of a right triangle with integer sides is not a perfect square.

I didn't know how to do it at first, but I got some help.  Here is the proof.

Related pages in this website

Number Theory

Pythagorean Theorem

Prove that the area of a right triangle with integer sides is not a perfect square.  I got some help, and finished this proof!

Puzzle question -- if m is the product of n distinct primes, how many different right triangles with integer sides have a leg of length m?

Arithmetic Sequence of Perfect Squares, page 3 -- If a², b², c² are in arithmetic sequence, why is their constant difference a multiple of 24?  Look at the second answer to this question for the relationship between Pythagorean Triples and this arithmetic sequence of squares.

Theorems Involving Perfect Squares -- answers questions such as "why is the square root of x irrational unless x is a perfect square?" and other fundamental questions about perfect squares.


The webmaster and author of this Math Help site is Graeme McRae.