Saturday, October 4, 2014

A Different Pythagorean Triple Generator

Pythagorean triples are sets of three integers that satisfy the equation a2 + b2 = c2.  Examples of Pythagorean triples include (3, 4, 5) and (5, 12, 13), because 32 + 42 = 52 and 52 + 122 = 132.

The most common approach to generate Pythagorean triples is to use Euclid’s method, in which you choose two integers m and n and generate a, b, and c by using the formulas a = m2 – n2, b = 2mn, and c = m2 + n2.  For example, if you choose m = 2 and n = 1, then a = 22 – 12 = 3, b = 2∙2∙1 = 4, and c = 22 + 12 = 5, which is the (3, 4, 5) triple.  This can be proven through substitution: a2 + b2 = (m2 – n2)2 + (2mn)2 = m4 –  2m2n2 + n4 + 4m2n2 = m4 +  2m2n2 + n4 = (m2 + n2)2 = c2.

But here’s a different approach.  We can take a known Pythagorean triple, 32 + 42 = 52, but let x = 0, which produces a quadratic equation (x + 3)2 + (x + 4)2 = (x + 5)2.  Since many quadratic equations have two real answers, there may be one other real solution for x that satisfies this equation, and in this case there is:
(x + 3)2 + (x + 4)2 = (x + 5)2
(x2 + 6x + 9) + (x2 + 8x + 16) = (x2 + 10x + 25)
x2 + (6 + 8 – 10)x + 9 + 16 – 25 = 0
x2 + 4x = 0
x(x + 4) = 0
So x = 0 (which we already knew) and x = -4.  Plugging x = -4 back into the original quadratic equation (x + 3)2 + (x + 4)2 = (x + 5)2, we get (-4 + 3)2 + (-4 + 4)2 = (-4 + 5)2 or (-1)2 + (0)2 = (1)2, which means we generated a new Pythagorean triple (-1, 0, 1). In other words, there are two sets of Pythagorean triples whose integers are consecutive: (3, 4, 5) and (-1, 0, 1).

Now, you might recognize that the triple (-1, 0, 1) is in the same family as (1, 0, 1) or (0, 1, 1), because (-1)2 and (1)2 are both equal to 1, and addition is commutative.  The same principle applies with the Pythagorean triple (3, 4, 5) we used in our above example, so we can use (-3, 4, 5) instead.  In fact, we can use any combination of (±3, ±4, ±5).  Because there are so many combinations, it is helpful generalize our method with (±a, ±b, ±c), where (a, b, c) represent a Pythagorean triple. So:
(x ± a)2 + (x ± b)2 = (x ± c)2
(x2 ± 2ax + a2) + (x2 ± 2bx + b2) = (x2 ± 2cx + c2)
x2 + 2(±a ± b ∓ c)x + a2 + b2 – c2 = 0
x2 + 2(±a ± b ∓ c)x = 0
x(x + 2(±a ± b ∓ c)) = 0
So x = 0 or x = -2(±a ± b ∓ c) = ∓2a ∓ 2b ± 2c.  Plugging x = ∓2a ∓ 2b ± 2c back into the original quadratic equation (x ± a)2 + (x ± b)2 = (x ± c)2, we get (∓2a ∓ 2b ± 2c ± a)2 + (∓2a ∓ 2b ± 2c ± b)2 = (∓2a ∓ 2b ± 2c ± c)2 or (∓a ∓ 2b ± 2c)2 + (∓2a ∓ b ± 2c)2 = (∓2a ∓ 2b ± 3c)2.  Therefore, if (a, b, c) is a Pythagorean triple, then (∓a ∓ 2b ± 2c, ∓2a ∓ b ± 2c, ∓2a ∓ 2b ± 3c) are also Pythagorean triples. 

For example, since (3, 4, 5) is a Pythagorean triple, then (∓3 ∓ 2∙4 ± 2∙5, ∓2∙3 ∓ 4 ± 2∙5, ∓2∙3 ∓ 2∙4 ± 3∙5) are also Pythagorean triples.  All the possibilities include:
(-3 – 2∙4 + 2∙5, -2∙3 – 4 + 2∙5, -2∙3 – 2∙4 + 3∙5) = (-1, 0, 1) → (0, 1, 1)
(3 – 2∙4 + 2∙5, 2∙3 – 4 + 2∙5, 2∙3 – 2∙4 + 3∙5) = (5, 12, 13) → (5, 12, 13)
(-3 + 2∙4 + 2∙5, -2∙3 + 4 + 2∙5, -2∙3 + 2∙4 + 3∙5) = (15, 8, 17) → (8, 15, 17)
(-3 – 2∙4 – 2∙5, -2∙3 – 4 – 2∙5, -2∙3 – 2∙4 – 3∙5) = (-21, -20, -29) → (20, 21, 29)
(3 + 2∙4 – 2∙5, 2∙3 + 4 – 2∙5, 2∙3 + 2∙4 – 3∙5) = (1, 0, -1) → (0, 1, 1)
(-3 + 2∙4 – 2∙5, -2∙3 + 4 – 2∙5, -2∙3 + 2∙4 – 3∙5) = (-5, -12, -13) → (5, 12, 13)
(3 – 2∙4 – 2∙5, 2∙3 – 4 – 2∙5, 2∙3 – 2∙4 – 3∙5) = (-15, -8, -17) → (8, 15, 17)
(3 + 2∙4 + 2∙5, 2∙3 + 4 + 2∙5, 2∙3 + 2∙4 + 3∙5) = (21, 20, 29) → (20, 21, 29)
So using this method, the Pythagorean triple (3, 4, 5) generates four new families of Pythagorean triples which include (0, 1, 1), (5, 12, 13), (8, 15, 17), and (20, 21, 29).

This Pythagorean triple generator can be proved by expanding (∓a ∓ 2b ± 2c)2 + (∓2a ∓ b ± 2c)2 = (∓2a ∓ 2b ± 3c)2 and simplifying it to a2 + b2 = c2:
(∓a ∓ 2b ± 2c)2 + (∓2a ∓ b ± 2c)2 = (∓2a ∓ 2b ± 3c)2
(a2 + 4b2 + 4c2 ± 4ab ∓ 4ac ∓ 8bc)  + (4a2 + b2 + 4c2 ± 4ab ∓ 8ac ∓ 4bc) = 4a2 + 4b2 + 9c2 ± 8ab ∓ 12ac∓12bc
5a2 + 5b2 + 8c2 ± 8ab ∓ 12ac ∓ 12bc = 4a2 + 4b2 + 9c2 ± 8ab ∓ 12ac∓12bc
5a2 + 5b2 + 8c2 = 4a2 + 4b2 + 9c2
a2 + b2 = c2

A quick Google search shows that this Pythagorean triple generator was first published by a Swedish mathematician named Berggen in 1934.  I am not sure if he arrived to it the same way as I did.

No comments:

Post a Comment