Pythagtriple PDF
Pythagtriple PDF
KEITH CONRAD
1. Introduction
A Pythagorean triple is a triple of positive integers (a, b, c) where a2 + b2 = c2 . Examples
include (3, 4, 5), (5, 12, 13), and (8, 15, 17). Below is an ancient Babylonian tablet listing
15 Pythagorean triples. It is called Plimpton 322 (George Arthur Plimpton donated it to
Columbia University). More information about it can be found at [1].
Plimpton 322
Some Pythagorean triples are scalar multiples of other triples: (6, 8, 10) is twice (3, 4, 5).
We call a triple (a, b, c) primitive when the three integers have no common factor. For any
triple (a, b, c), if d is the greatest common divisor of all three terms then (a/d, b/d, c/d) is a
primitive triple and the original triple is a scalar multiple of this, so finding all Pythagorean
triples is basically the same as finding all primitive Pythagorean triples. Our goal is to
describe the primitive Pythagorean triples.
We will be using different characterizations of primitive triples, as described in the fol-
lowing lemma.
Lemma 1.1. For a Pythagorean triple (a, b, c), the following properties are equivalent:
1
2 KEITH CONRAD
k ` a b c
2 1 3 4 5
3 2 5 12 13
4 1 15 8 17
4 3 7 24 25
Table 1. Examples of Primitive Triples
Table 1 lists examples of the values of k and ` for some primitive triples. Notice in
particular that the triple (8, 15, 17) is recorded in the table as (15, 8, 17) because of the
convention in Theorem 1.2 that the middle term of the triple is even. Since k 6 ` mod 2,
one of k and ` is even and the other is odd. The first two rows in Table 1 shows that either
k or ` can be even; it depends on the particular triple (a, b, c). How it depends on the triple
will be seen at the end of Section 3.
Lets first check that the formula in Theorem 1.2 always yields primitive Pythagorean
triples. For all k and ` in Z, the formula
(k 2 `2 )2 + (2k`)2 = (k 2 + `2 )2
is true, so (k 2 `2 , 2k`, k 2 + `2 ) is a Pythagorean triple when k > ` > 0. When (k, `) = 1
and k 6 ` mod 2, lets check (k 2 `2 , 2k`, k 2 + `2 ) is a primitive triple. This follows (by
Lemma 1.1) from showing k 2 `2 and k 2 + `2 are relatively prime. If d is a (positive)
common divisor of k 2 `2 and k 2 + `2 then d divides their sum and difference, which are
2k 2 and 2`2 . Since k 2 + `2 and k 2 `2 are odd, d is odd, so d|k 2 and d|`2 . Since k and `
are relatively prime, so are k 2 and `2 , so d = 1.
If we relax any of the conditions on k and ` in Theorem 1.2 we wont get a primitive
Pythagorean triple. For instance, taking k = 3 and ` = 1 produces the triple (8, 6, 10). The
condition k 6 ` mod 2 is violated here.
Next we will show, in two ways, that a primitive Pythagorean triple arises in the form
given by Theorem 1.2: using unique factorization in Z (an algebraic proof) and using
intersections of lines and circles (a geometric proof). Then we will put the formula to work
and see some generalizations.
PYTHAGOREAN TRIPLES 3
b2 = c2 a2 = (c + a)(c a).
The two integers on the right, (c + a)/2 and (c a)/2, are relatively prime: if d is a common
divisor then it divides their sum and difference, which are c and a, and those are relatively
prime, so d = 1. Since c > a > 0, both factors on the right side of (2.1) are positive. Since
they are relatively prime and their product is a square, unique factorization in Z tells us
that
c+a ca
(2.2) = k2 , = `2
2 2
for some positive integers k and `. Since, as we noted already, (c + a)/2 and (c a)/2 are
relatively prime, also k and ` are relatively prime. Adding and subtracting the equations
in (2.2),
c = k 2 + `2 , a = k 2 `2 ,
so
2
b
= k 2 `2 = b2 = 4k 2 `2 = b = 2k`,
2
the last step holding because b, k, and ` are positive.
It remains to check that k 6 ` mod 2. Since k and ` are relatively prime, they are
not both even. If they were both odd then k 2 + `2 , 2k`, and k 2 `2 would all be even,
contradicting primitivity of (a, b, c).
(a/c, b/c)
(1, 0)
x
Substituting the equation for the line into the equation for the unit circle gives us an
equation whose roots are the x-coordinates of the two points on both the line and the circle:
1 = x2 + y 2
= x2 + (m(x + 1))2
= (1 + m2 )x2 + 2m2 x + m2 ,
so
(3.1) 0 = (1 + m2 )x2 + 2m2 x + m2 1.
Since (1, 0) and (a/c, b/c) lie on both the line and the circle, the two roots of (3.1) are 1
and a/c. The sum of the roots is 2m2 /(1 + m2 ), so
a 2m2
1 + = .
c 1 + m2
Thus
a 2m2 1 m2
=1 = .
c 1 + m2 1 + m2
Since (a/c, b/c) is on the line y = m(x + 1),
1 m2
b a 2m
=m +1 =m 2
+1 = .
c c 1+m 1 + m2
Since m is the slope of a line connecting (1, 0) to a point on the unit circle in the first
quadrant, 0 < m < 1. Write m = b/(a + c) in reduced form as m = `/k with positive
relatively prime integers k and `. (Why dont we write m = k/`? Because the choice we
made will match the formulas as written in Theorem 1.2.) Since m < 1, k > `. The formulas
for a/c and b/c in terms of m become
a 1 (`/k)2 k 2 `2
(3.2) = =
c 1 + (`/k)2 k 2 + `2
and
b 2(`/k)2 2k`
(3.3) = 2
= 2 .
c 1 + (`/k) k + `2
By definition, k and ` are relatively prime. Lets check that k 6 ` mod 2. If k and `
have the same parity then they must both be odd (they are not both even since they are
PYTHAGOREAN TRIPLES 5
relatively prime). Then the fraction 2k`/(k 2 + `2 ) has an even numerator and denominator,
so it simplifies further to
2k` k`
2 2
= 2 .
k +` (k + `2 )/2
Here the numerator is odd, so the reduced form representation b/c must have an odd
numerator. But b is even by hypothesis, so we have a contradiction.
From the end of Section 1, the three numbers k 2 `2 , 2k`, and k 2 +`2 form a Pythagorean
triple and the first and third numbers are relatively prime, so the triple is primitive by
Lemma 1.1. Therefore the fractions on the right in (3.2) and (3.3) are in reduced form. The
fractions a/c and b/c are also in reduced form since the triple (a, b, c) is primitive, so the
(positive) numerators and denominators match:
a = k 2 `2 , b = 2k`, c = k 2 + `2 .
This concludes the geometric proof of Theorem 1.2.
Remark 3.1. While this derivation was motivated by geometry, the calculations were pure
algebra and we could formulate them without references to a picture. That is, if we have
numbers x and y with x2 + y 2 = 1 and x 6= 1, we can (without motivation) define the
number m to fit the condition y = m(x + 1). Then substituting this into x2 + y 2 = 1 tells
us
x2 + m2 (x + 1)2 = 1,
and expanding the square gives
m2 1
2 2 2 2 2
0 = (1 + m )x + 2m x + (m 1) = (1 + m )(x + 1) x + ,
1 + m2
so from x 6= 1 we have x = (1 m2 )/(1 + m2 ) and y = m(x + 1) = 2m/(1 + m2 ).
One nice consequence of our geometric derivation of the formula for primitive Pythagorean
triples (a, b, c) is that it tells us which of k or ` will be even. The formula
b `
m= =
a+c k
says that `/k is the reduced form fraction for b/(a + c). We know either ` or k is even. We
will have k even when a + c is divisible by a higher power of 2 than b is, and ` is even when b
is divisible by a higher power of 2 than a + c is. For instance, in the triple (3, 4, 5), a + c = 8
and b = 4, so k is even. (Here k = 2 and ` = 1.) The triple (5, 12, 13) has a + c = 18 = 2 9
and b = 12 = 22 3, so ` is even. (Here k = 3 and ` = 2.)
4. Applications
Using the parametric formula for primitive Pythagorean triples, we can address questions
concerning relations among the sides of a primitive right triangle.
The most well-known Pythagorean triples, (3, 4, 5), and (5, 12, 13), have consecutive
terms. We ask: what are all the Pythagorean triples (a, b, c) with a pair of consecutive
terms (either a and b or b and c)? Any such triple is automatically primitive since consec-
utive integers are relatively prime.
First we consider the case when a and b (the two legs) are consecutive. For a and b to
differ by 1 means
(k 2 `2 ) 2k` = 1.
6 KEITH CONRAD
x y k ` a b c
1 1 2 1 3 4 5
3 2 5 2 21 20 29
7 5 12 5 119 120 169
17 12 29 12 697 696 985
41 29 70 29 4059 4060 5741
Table 2. Consecutive Legs
Even if two legs in a primitive triple dont differ by 1, the formula for their difference is
still (k `)2 2`2 , so the possible differences between legs in a primitive triple are precisely
the odd values of x2 2y 2 for positive integers x and y. Not every odd number can arise
in this way, e.g., the equation x2 2y 2 = 5 has no integral solution (why?), so no primitive
Pythagorean triple has its legs differing by 5.
Important results in number theory have developed from the study of values of x2 dy 2 ,
where d is a fixed nonsquare integer. The special case d = 2 shows up in the setting of
Pythagorean triples, but other values of d are important for other problems.
Turning now to a leg and hypotenuse which differ by 1, the story is much simpler. The
hypotenuse is odd, so it can only differ by 1 from the even leg. This difference is
k 2 + `2 2k` = (k `)2 ,
which is an odd square. This is 1 only if k = ` + 1 (recall k > ` by convention), leading to
the triple (2` + 1, 2`2 + 2`, 2`2 + 2` + 1). The first four examples are in Table 3.
` 2` + 1 2`2 + 2` 2`2 + 2` + 1
1 3 4 5
2 5 12 13
3 7 24 25
4 9 40 41
Table 3. Consecutive Leg and Hypotenuse
Now we look at a connection between Pythagorean triples and reducible quadratic poly-
nomials, taken from [2]. While
x2 + 4x + 3 = (x + 1)(x + 3) and x2 + 4x 3 is irreducible,
we have
x2 + 5x + 6 = (x + 2)(x + 3) and x2 + 5x 6 = (x 1)(x + 6).
PYTHAGOREAN TRIPLES 7
Are there more examples like this second one, where integral polynomials x2 + mx + n and
x2 + mx n both factor? Here m and n are nonzero.
If we ask what happens when the sign of m changes, the answer is not interesting. Indeed,
if x2 + mx + n = (x r1 )(x r2 ) then x2 mx + n = (x + r1 )(x + r2 ), so either both of these
factor (with integral coefficients) or both dont. Therefore in our question on x2 + mx n,
we may assume m > 0. Since the issue is about sign changes on n, wemay take n > 0 also.
m m2 4n
By the quadratic formula, the roots of x2 + mx n are , which are
2
integers exactly when m2 4n = . (Note m2 4n m mod 2, so the numerator is even
when the discriminant is a perfect square.) So we can factor x2 + mx + n and x2 + mx n
if and only if
m2 4n = d2 , m2 + 4n = e2 , d and e Z.
Then d2 + e2 = 2m2 , so d e mod 2. Solving,
d2 + e2 e+d 2 ed 2
m2 = = + .
2 2 2
Thus we have a Pythagorean triple (without a specified even term)
ed e+d ed e+d
, ,m , < < m.
2 2 2 2
As an exercise, show this Pythagorean triple is primitive if and only if (m, n) = 1.
There is a one-to-one correspondence
Pythagorean triples (a, b, c) with a < b < c reducible x2 + mx n,
given by
2 ab 2 ed e+d
(a, b, c) 7 x + cx , x + mx n 7 , ,m ,
2 2 2
with m2 4n = d2 and m2 + 4n = e2 . The table below shows some corresponding
Pythagorean triples and reducible x2 + mx n. In particular, the example x2 + 5x 6
corresponds to the (3, 4, 5) triple and thus is the simplest example.
a b c m n x2 + mx + n x2 + mx n
3 4 5 5 6 (x + 2)(x + 3) (x 1)(x + 6)
5 12 13 13 30 (x + 3)(x + 10) (x 2)(x + 15)
8 15 17 17 60 (x + 5)(x + 12) (x 3)(x + 20)
20 21 29 29 210 (x + 14)(x + 15) (x 6)(x + 35)
Using the formula for primitive Pythagorean triples, we can now write a formula for all
the reducible x2 + mx n when (m, n) = 1:
x2 + (k 2 + `2 )x k`(k 2 `2 ),
where k > ` > 0, (k, `) = 1, and k 6 ` mod 2. As an exercise, work out the factorization of
this polynomial explicitly in terms of k and `.
5. Generalizations
The two derivations of the formula for primitive Pythagorean triples, one algebraic and
the other geometric, are each worthwhile: they let us extend Theorem 1.2 in different
directions.
8 KEITH CONRAD
The algebraic proof of Theorem 1.2 carries over to Pythagorean triples of polynomials in
R[T ]. These are polynomials f (T ), g(T ), and h(T ) in R[T ] which satisfy
f (T )2 + g(T )2 = h(T )2 .
One example of such a triple is (T 2 1, 2T, T 2 + 1). Can we describe all polynomial
Pythagorean triples?
There are two features of the Pythagorean triples of integers which play no role when we
look at Pythagorean triples of polynomials:
(1) The special attention to positive solutions of a2 + b2 = c2 is ignored. We allow any
polynomial solutions to f 2 + g 2 = h2 with the only proviso being that f, g, and h
are all nonzero.
(2) The number 2 is an invertible constant in R[T ], so the even/odd aspect that cropped
up with integral Pythagorean triples simply drops out of consideration. Being di-
visible by 2 is not an important feature in R[T ] since we can always divide by 2 in
R[T ].
We will call a Pythagorean triple of polynomials (f, g, h) primitive if the terms in it are
pairwise relatively prime. This is the same as any two of the polynomials being relatively
prime, and is also the same as (f, g, h) not being a non-constant multiple of another triple
(polynomial analogue of Lemma 1.1).
Theorem 5.1. The primitive Pythagorean triples (f (T ), g(T ), h(T )) in R[T ] are given by
the formulas
f (T ) = c(k(T )2 `(T )2 ), g(T ) = 2ck(T )`(T ), h = c(k(T )2 + `(T )2 ),
where c R and k(T ) and `(T ) are relatively prime in R[T ].
Proof. This is left as an exercise in adapting the techniques in the algebraic proof of Theorem
1.2. Note that if two polynomials are relatively prime and multiply to a squared polynomial,
the two polynomials have to be squares up to constant multiple. This follows from unique
factorization in R[T ].
The geometric proof of Theorem 1.2 has a benefit in calculus. First of all, this proof leads
to a non-trigonometric parametrization of the points on the unit circle: any point (x0 , y0 )
satisfying x2 + y 2 = 1 other than (1, 0) has the form
1 m2 2m
(5.1) x0 = 2
, y0 =
1+m 1 + m2
where m = y0 /(x0 + 1). The formulas in (5.1) for x0 and y0 arise by looking at the
intersection points of x2 + y 2 = 1 and y = m(x + 1), where this linear equation describes
any line through (1, 0) other than the vertical line. The correspondences
1 m2
2m y
(5.2) m 2
, 2
, (x, y) m= ,
1+m 1+m 1+x
between real numbers m and points on the unit circle (x, y) other than (1, 0) are inverses
of each other, as the reader can check. Moreover, the formulas have arithmetic content: m
is rational if and only if x0 and y0 are both rational: the formulas in (5.2) each one have
rational output if there is rational input. So (5.1) is well-suited to describe the rational
points on x2 + y 2 = 1. See Table 4. Compare this to the trigonometric parametrization
(cos , sin ), where nearly all rational points have messy corresponding angles .
PYTHAGOREAN TRIPLES 9
m x y
1/2 3/5 4/5
1/3 4/5 3/5
2/5 21/29 20/29
7/9 16/65 63/65
Table 4. Rational points from slopes on x2 + y 2 = 1
Comparing the rational parametrization of the unit circle in (5.1) and the trigonometric
parametrization, we can write (with some assistance from (5.2))
1 m2 2m
cos = 2
, sin = ,
1+m 1 + m2
where m = sin /(1 + cos ). A point on the unit circle at angle relative to the origin and
the positive x-axis makes an angle of /2 relative to the point (1, 0) and the half-line to
its right. Therefore m = tan(/2). Now take a look in any calculus book for the method
of integrating rational functions in sin and cos . The trick of the method is the u-
substitution u = tan(/2), which turns cos and sin into rational functions of u and any
integral of a rational function of cos and sin into an integral of a rational function of u.
Now we see the origin of this trick: use two different parametrizations of the unit circle to
express an integral involving one parameterization (trig functions) as an integral involving
the other parametrization (rational functions).
If we take any conic in the plane (a curve of degree 2: an ellipse, hyperbola, or parabola)
given by an equation having rational coefficients and we can find one rational point on it,
then we can use slopes of lines through that point to parametrize all the other rational
points on the conic. Here is an example using another circle.
Theorem 5.2. The rational points on the circle x2 + y 2 = 2 other than (1, 1) can be
described by the formula
1 + 2m m2 m2 + 2m 1
,
m2 + 1 m2 + 1
where m Q. A rational point (x, y) other than (1, 1) arises this way using m =
(y + 1)/(x + 1), and (1, 1) arises this way using m = 1.
Proof. The point (1, 1) lies on the circle. A non-vertical line through (1, 1) has the
form y = m(x + 1) 1. Any line through (1, 1) intersects the circle in a second point,
except for the tangent line y = x 2 (where m = 1).
(1, 1)
x
(1, 1)
10 KEITH CONRAD
To find the second point of intersection, substitute the equation of the line into the
equation x2 + y 2 = 2 and solve for the two roots of the resulting quadratic in x: one
root is 1, and we can find the other root by the same method as in the geometric proof
of Theorem 1.2. This will give the x-coordinate formula above, and substituting this into
y = m(x + 1) 1 gives the y-coordinate. The only rational point on x2 + y 2 = 2 which
we dont find by this method is (1, 1), which is the second intersection point of the circle
with the vertical line through (1, 1). This vertical line is not described by an equation
of the form y = m(x + 1) 1. The parameter value that gives the point (1, 1) itself is
m = 1, which is the slope of the tangent line to x2 + y 2 = 2 at (1, 1) (touching the
point (1, 1) twice, in a sense).
Remark 5.3. Since x2 + y 2 = 2 if and only if ((x y)/2)2 + ((x + y)/2)2 = 1, the geometric
proof of Theorem 1.2 yields (x y)/2 = (1 m2 )/(1 + m2 ) and (x + y)/2 = 2m/(1 + m2 ).
Adding and subtracting these equations recovers the formulas in Theorem 5.2.
Armed with the description of the rational points on x2 + y 2 = 2 in Theorem 5.2, we
can get a description of the primitive integral solutions of a2 + b2 = 2c2 , where primitive
means a, b, and c have no common factor (equivalently, this means any two of a, b, and c
are relatively prime, i.e., an analogue of Lemma 1.1 holds). In a primitive triple (a, b, c), a
and b both must be odd, so 2c2 2 mod 8, hence c is odd as well. For Pythagorean triples,
the middle term was chosen to be the even one. The analogue of that here is that we take
c > 0 and pick the signs on a and b so that a 6 b mod 4. With these conventions, we have
a = k 2 + 2k` `2 , b = `2 + 2k` k 2 , c = k 2 + `2
where (k, `) = 1, k 6 ` mod 2, and k > 0. Conversely, any triple defined by these formulas
is a primitive solution to a2 + b2 = 2c2 with b 6 a mod 4.
k ` a b c
1 2 1 7 5
1 2 7 1 5
1 4 7 23 17
4 1 23 7 29
2 5 1 41 29
Table 5. Primitive Solutions to a2 + b2 = 2c2
Integers satisfying a2 + b2 = 2c2 are not the sides of a right triangle, but they have
an arithmetic interpretation: since c2 = 21 (a2 + b2 ), c2 is the average of a2 and b2 . In
other words, a2 , c2 , b2 is an arithmetic progression of squares (taking a2 < b2 ). From Table
5, squaring the entries in the a, b, and c columns yield three such progressions: 1, 25, 49
(common difference 24), 49, 289, 529 (common difference 240), and 1, 841, 1681 (common
difference 840). There are infinitely many 3-term arithmetic progressions of squares, and
we can find them all using the rational parametrization of the rational points on x2 +y 2 = 2.
What about 4-term arithmetic progressions of squares?
References
[1] W. Casselman, http://www.math.ubc.ca/cass/courses/m446-03/pl322/pl322.html.
[2] J. L. Poet and D. L. Vestal, Jr., Curious Consequences of a Miscopied Quadratic, College Math. J.
36 (2005), 273277.