Pythagorean Triples

## **Problem**

A Pythagorean triple is a set of three positive integers

(
a
,
b
,
c
)

{\displaystyle (a, b, c)}

 that satisfies the Pythagorean theorem

a
2

b
2

=

c
2

{\displaystyle a^2+b^2=c^2}

. The earliest table of Pythagorean triples can be found on an ancient Babylonian clay tablet called *Plimpton 322* (c. 1800 BC). However, the clay tablet does not indicate any knowledge of the Pythagoean triples formula. Derive the formula for generating primitive Pythagorean triples

(
a
,
b
,
c
# )
(
2
m
n
,

m
2

−

n
2

,

m
2

n
2

)

{\displaystyle (a,b,c) = (2mn, m^2-n^2, m^2+n^2) }

 for positive integers

m
,
n

{\displaystyle m,n}

, where

gcd
(
m
,
n
# )
1

{\displaystyle \gcd(m,n) = 1}

 and

gcd
(
a
,
b
,
c
# )
1

{\displaystyle \gcd(a,b,c) = 1 }

.

## **Solution**

The Pythagorean theorem states that for a right triangle with sides

a
,
b
,
c

{\displaystyle a,b,c}

, where

c

{\displaystyle c}

 is the longest side,

a
2

b
2

=

c
2

.

{\displaystyle a^2 + b^2 = c^2.}

Subtract

b
2

{\displaystyle b^2}

 on both sides and factorize:

a
2

=

c
2

−

b
2

a
2

=
(
c
b
)
(
c
−
b
)
.

{\displaystyle \begin{align}
a^2 &= c^2 - b^2 \\[5 pt]
a^2 &= (c+b)(c-b).
\end{align} }

Next, divide by

a
2

{\displaystyle a^2}

 to get

(

c
b

a

)

(

c
−
b

a

)

=

{\displaystyle \left(\frac{c+b}{a}\right)\left(\frac{c-b}{a}\right) = 1. }

If

c
−
b

a

{\displaystyle \frac{c-b}{a} }

 is a rational number, then

c
−
b

a

=

n
m

{\displaystyle \frac{c-b}{a} = \frac{n}{m} }

 and

c
b

a

=

m
n

{\displaystyle \frac{c+b}{a} = \frac{m}{n} }

, where

gcd
(
m
,
n
# )
1

{\displaystyle \gcd(m,n) = 1}

. Subsequently,

c
a

−

b
a

=

n
m

{\displaystyle \frac{c}{a} - \frac{b}{a} = \frac{n}{m} }

 and

c
a

b
a

=

m
n

{\displaystyle \frac{c}{a} + \frac{b}{a} = \frac{m}{n} }

.

By adding the two expressions, it can be shown that

2

(

c
a

)

=

m
2

n
2

m
n

c
a

=

m
2

n
2

2
m
n

.

{\displaystyle \begin{align}
2\left(\frac{c}{a}\right) = \frac{m^2 + n^2}{mn} \\[5 pt]
\frac{c}{a} = \frac{m^2 + n^2}{2mn}.
\end{align} }

For primitive Pythagorean triples,

gcd
(
a
,
c
# )
1

{\displaystyle \gcd(a,c) = 1 }

; therefore,

# a
2
m
n

{\displaystyle a = 2mn }

 and

# c

m
2

n
2

{\displaystyle c = m^2 + n^2 }

.

By subtracting the two expressions, it can be shown that

2

(

b
a

)

=

m
2

−

n
2

m
n

b
a

=

m
2

−

n
2

2
m
n

.

{\displaystyle \begin{align}
2\left(\frac{b}{a}\right) = \frac{m^2 - n^2}{mn} \\[5 pt]
\frac{b}{a} = \frac{m^2 - n^2}{2mn}.
\end{align} }

For primitive Pythagorean triples,

gcd
(
a
,
b
# )
1

{\displaystyle \gcd(a,b)=1}

; therefore,

# a
2
m
n

{\displaystyle a = 2mn }

 and

# b

m
2

−

n
2

{\displaystyle b = m^2 - n^2 }

. Therefore, the primitive Pythagorean triples can be generated by

(
a
,
b
,
c
# )
(
2
m
n
,

m
2

−

n
2

,

m
2

n
2

)
.

{\displaystyle (a,b,c) = (2mn, m^2-n^2, m^2+n^2). }

**Note:** To generate all Pythagorean triples, one can scale each side by a common factor

k

{\displaystyle k}

 that is a positive integer.

(
a
,
b
,
c
# )

(

2
k
m
n
,
k
(

m
2

−

n
2

)
,
k
(

m
2

n
2

)

)

{\displaystyle (a,b,c) = \left(2kmn, k(m^2-n^2), k(m^2+n^2)\right) }