Copyright © Had2Know 2010-2024. All Rights Reserved.
Terms of Use | Privacy Policy | Contact
Site Design by E. Emerson
How to Generate Pythagorean Triples
Pythagorean triples are sets of three integers that represent the sides of a right triangle. Some of the most well-known primitive Pythagorean triples are (3, 4, 5), (5, 12, 13) and (8, 15, 17). (Primitive means that you cannot divide each number by a common factor, i.e. the GCD = 1.)
You can verify that these give the sides of a right triangle by using the Pythagorean Theorem:
a² + b² = c²,
where a and b are the lengths of the legs and c is the hypotenuse. (Example: 8² + 15² = 17².)
Method 1: Two-Parameter Generator Set
Let m and n are positive integers with m > n, and leta = m² - n²
b = 2mn
c = m² + n²,
then (a, b, c) is a Pythagorean triple with legs a and b and hypotenuse c. This can be verified with algebra:
(m² - n²)² + (2mn)²
= m⁴ - 2m²n² + n⁴ + 4m²n²
= m⁴ + 2m²n² + n⁴
= (m² + n²)²
If GCD(m, n) = 1 and m and n are not both odd, then the generated triple will be primitive.
Method 2: Using Two Pythagorean Triples to Generate Two More
Suppose (a, b, c) and (x, y, z) are two Pythagorean triples. Then(ax+by, |ay-bx|, cz) and (|ax-by|, ay+bx, cz)
are also Pythagorean triples. For example, take (3, 4, 5) and (8, 15, 17) as the original pair. Using the transformation above, we can construct two new Pythagorean triples:
(3*8+4*15, |3*15-4*8|, 5*17)
= (84, 13, 85) and
(|3*8-4*15|, 3*15+4*8, 5*17)
= (36, 77, 85)
To see why this works, examine the expression (ax+by)² + |ay-bx|². This can be expanded into
a²x² + 2abxy + b²y² + a²y² - 2abxy + b²x²
= a²x² + b²y² + a²y² + b²x²
= (a² + b²)(x² + y²)
= c²z²
= (cz)²
The same algebra can be applied to the second generated set.
© Had2Know 2010