Pythagorean triples

Problem : Find all triples of integers (a,b,c) such that a2+b2=c2.
Prerequisites :
If a=ua' and b=ub' then c2=u2(a'2+b'2). As a'2+b'2 is an integer, c is a multiple of u.

Thus we can restrict the study to primitive Pythagorean triples, that is when a and b are coprimes. It is equivalent to say that a and c are coprimes.

Assume a is odd. Then a2-1=(a+1)(a-1) is multiple of 8.

If b was also odd then c2-2 would be a multiple of 8, which is impossible, as c2 must either be odd or multiple of 4.

Thus b is even, c is odd, and (c+a), (c-a) are even.

Let u=(c+a)/2 , v=(c-a)/2, so that c=u+v and a=u-v
u and v are coprimes, because a and c are coprimes (any common divisor of u and v would be a common divisor of a and c). Writing b=2b' the relation a2+b2=c2 gives b'2= (c2-a2)/4= uv.
uv is a square, thus has only even exponents in its prime factorization.
u,v are coprimes, thus have no common element in their prime factorization.
Thus u and v also each have only even exponents in their factorization. Thus both are squares.
In conclusion, u=m2 and v=n2, so that all solutions are of the form
a = m2-n2
b = 2mn
c = m2+n2
Conversely, any triple (a,b,c) defined in this way from m,n, satisfies a2+b2=c2.

As a and c must be odd, we must have either m even and n odd, or m odd and n even. Both cases can be exchanged by exchanging m and n, but this changes the sign of a. So we may reduce the study to the case when m is even and n is odd, if we don't forget that some solutions use the case n>m that appear with a<0.

The above formulas can be written in a compact form using complex numbers: a+ib = (m+in)2

If, on the other hand, we take m and n to be both odd, then we have m+in = (1+i)(m'+in') for some relative integers m' and n' where one is odd and the other is even. Then,
a
+ib = (m+in)2=2i(m'+in')2 = 2ia' - 2b' where a'+ib' = (m'+in')2.

Other proof

An even shorter proof exists but makes use of another mathematical result : that the existence and uniqueness of prime factorization does not only apply to the set of integers, but also to the Gaussian integers (which form a principal ideal domain, and thus a unique factorization domain).
So the number (a+ib)(a-ib)=c2 has a unique factorization into Gaussian prime numbers. When the triple (a,b,c) is primitive, the number a+ib is not divisible by any non-unit integer, and thus cannot have any pair of conjugate prime factors. As the prime factors of a-ib are the conjugate of those of a+ib, the numbers a+ib and a-ib are coprimes. But their product is a square, thus each one is also a square, up to a unit factor.

List of smallest Pythagorean triples

Here is the list of first Pythagorean triples (a,b,c) given by a+ib = (m+in)2:
 n \ m
0
2
4
6
8
10
1
-1,0,1
3,4,5
15,8,17
35,12,37
63,16,65
99,20,101
3
-9,0,9
-5,12,13
7,24,25
27,36,45
55,48,73
91,60,109
5
-25,0,25
-21,20,29
-9,40,41
11,60,61
39,80,89
75,100,125
7
-49,0,49
-45,28,53
-33,56,65
-13,84,85
15,112,113
51,140,149
9
-81,0,81
-77,36,85
-65,72,97
-45,108,117
-17,144,145



We notice that 65 is the hypotenuse of 2 triangles in this list : -33+56i=(4+7i)2 , and 63+16i=(8+i)2. This is because we have the multiple factorization 65=(4+7i)(4-7i)=(8+i)(8-i)=5×13
where
5=(2+i)(2-i)
13=(3+2i)(3-2i)
8+i=(3+2i)(2-i)
4+7i=(3+2i)(2+i)
The same for 85 = 5×17 :
(2+i)(4+i)=7+6i
(2+i)(4-i)=9+2i

Another parametrization

We may reject the choice of (m even, n odd) as artificial, and consider that it should be mixed with (m odd, n even) in the same table. However we need to still present this as a table with ligns and columns. If we kept m and n as parameters we would have twice more cells, with the cases of (even, even) and (odd, odd) giving values of non-primitive Pythagorean triples:


 n \ m
0
1
2
3
4
5
6
0
0,0,0
1,0,1 4,0,4
9,0,9
16,0,16 25,0,25 36,0,36
1
-1,0,1
0,2,2
3,4,5
8,6,10 15,8,17
24,10,26 35,12,37
2
-4,0,4
-3,4,5 0,8,8
5,12,13 12,16,20 21,20,29 32,24,40
3
-9,0,9
-8,6,10
-5,12,13
0,18,18
7,24,25
16,30,34 27,36,45
4
-16,0,16
-15,8,17 -12,16,20
-7,24,25 0,32,32
9,40,41 20,48,52
5
-25,0,25
-24,10,26
-21,20,29
-16,30,34
-9,40,41
0,50,50
11,60,61

As this table is symmetric with respect to the diagonal, we only need to take one half of this table as divided by the diagonal.
Let us take the upper half (m>n), and then move its content to form a new table with parameters n and p = m-n.
With this new parameter, the condition (m even, n odd) or (m odd, n even) takes the simple form of (p odd). The condition that m and n are coprimes, simply says that n and p are coprimes.

Replacing m = p+n in the formulas, gives
a = p2+ 2 np
b = 2 np + 2n2 = 2 n(p+n)
c = p2 + 2 np+
2n2 = p2+ 2n(p+n)
thus the following table

n \ p
1
3
5
7
9
11
0
1,0,1
9,0,9
25,0,25
49,0,49
81,0,81
121,0,121
1
3,4,5 15,8,17 35,12,37 63,16,65 99,20,101 143,24,145
2
5,12,13 21,20,29 45,28,53 77,36,85 117,44,125
165,52,173
3
7,24,25 27,36,45 55,48,73 91,60,109 135, 
187,84,205
4
9,40,41 33,56,65 65,72,97 105, 88, 137 153,104,185 209,120,241
5
11,60,61 39,80,89 75,100,125 119, 120, 169 171,140, 221 231,160,281
6
13,84,85 -45,108,117 85, 132, 157 133,156, 205 189,
253,
7
15,112,113 51,140,149 95, 168, 193 147,
207,
275,
8
17,144,145 57,176,185 105, 208, 233 161, 240, 289 225,


A video on Pythagorean triples was made by Grant Sanderson (3Blue1Brown).

Back to Set theory home page