Pythagorean Triples #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
The main result is the classification of Pythagorean triples. The final result is for general
Pythagorean triples. It follows from the more interesting relatively prime case. We use the
"rational parametrization of the circle" method for the proof. The parametrization maps the point
(x / z, y / z)
to the slope of the line through (-1 , 0)
and (x / z, y / z)
. This quickly
shows that (x / z, y / z) = (2 * m * n / (m ^ 2 + n ^ 2), (m ^ 2 - n ^ 2) / (m ^ 2 + n ^ 2))
where
m / n
is the slope. In order to identify numerators and denominators we now need results showing
that these are coprime. This is easy except for the prime 2. In order to deal with that we have to
analyze the parity of x
, y
, m
and n
and eliminate all the impossible cases. This takes up
the bulk of the proof below.
Three integers x
, y
, and z
form a Pythagorean triple if x * x + y * y = z * z
.
Pythagorean triples are interchangable, i.e x * x + y * y = y * y + x * x = z * z
.
This comes from additive commutativity.
The zeroth Pythagorean triple is all zeros.
A triple is still a triple if you multiply x
, y
and z
by a constant k
.
(k*x, k*y, k*z)
is a Pythagorean triple if and only if
(x, y, z)
is also a triple.
A Pythagorean triple x, y, z
is “classified” if there exist integers k, m, n
such that
either
x = k * (m ^ 2 - n ^ 2)
andy = k * (2 * m * n)
, orx = k * (2 * m * n)
andy = k * (m ^ 2 - n ^ 2)
.
A primitive pythogorean triple x, y, z
is a pythagorean triple with x
and y
coprime.
Such a triple is “primitively classified” if there exist coprime integers m, n
such that either
x = m ^ 2 - n ^ 2
andy = 2 * m * n
, orx = 2 * m * n
andy = m ^ 2 - n ^ 2
.
A parametrization of the unit circle #
For the classification of pythogorean triples, we will use a parametrization of the unit circle.
by assuming x
is odd and z
is positive we get a slightly more precise classification of
the pythagorean triple x ^ 2 + y ^ 2 = z ^ 2