Posts Tagged ‘number theory’

Generating Pythagorean Triples

May 6, 2009

Some small Pythagorean triples are

3, 4, 5

5, 12, 13

7, 24,  25.

In each case, the hypotenuse has length one greater one of the legs. Let’s try to find all such triples.

Let the longer of the legs be x. Then the hypotenuse is x+1. The shorter leg must be an integer, n.

(x+1)^2 = x^2 + n^2

2x+1 = n^2

x = \frac{n^2-1}{2}.

In order to get a Pythagorean triple, x must also be an integer. That means n^2 - 1 must be even, so n^2 must be odd. That happens whenever n itself is odd.

\begin{array}{ccc} n & x = (n^2 - 1)/2 & x+1 \\ 1 & 0 & 1 \\ 3 & 4 & 5 \\ 5 & 12 & 13 \\ 7 & 24 & 25 \\ 9 & 40 & 41 \\ 11 & 60 & 61 \\ 13 & 84 & 85 \end{array}

How about Pythagorean triples where one of the legs is two less than the hypotenuse?

(x+2)^2 = x^2 + n^2

4(x+1) = n^2

x = \frac{n^2}{4} - 1

So here we must have n^2 a multiple of 4, which happens when n is even.

\begin{array}{ccc} n & x = n^2/4-1 & x+2 \\ 2 & 0 & 2 \\ 4 & 3 & 5 \\ 6 & 8 & 10 \\ 8 & 15 & 17 \\ 10 & 24 & 26 \\ 12 & 35 & 37 \\ 14 & 48 & 50 \\ 16 & 63 & 65 \end{array}

How about triples where a leg is \Delta less than the hypotenuse?

(x+\Delta)^2 = x^2 + n^2

2\Delta x + \Delta^2 = n^2

x = \frac{n^2 - \Delta^2}{2\Delta}

So the numerator, n^2 - \Delta^2 needs to be a multiple of \Delta. Since the second term already is one, so must be the first. That means

n = c*\Delta

for some integer c. Plugging that back into the equation for x gives

x = \frac{(c\Delta)^2 - \Delta^2}{2\Delta} = \frac{\Delta(c^2-1)}{2}

So if \Delta is even, there’s nothing to worry about. Otherwise, c must be odd.

Want to find a Pythagorean triple that has a leg 103 shorter than the hypotenuse? Then \Delta = 103 so we can choose any odd number for c. How about 33?

x = \frac{103(33^2-1)}{2} = 56032.

n = \Delta*c = 103*33 = 3399

We have the Pythagorean triple 3399, 56032, 56135.


Design a site like this with WordPress.com
Get started