You are on page 1of 2

Using counting numbers to generate Pythagorean triples by Robert Simms, 11 June 1997, http://www.math.clemson.

edu/~rsimms
n in {1,2,3,4,...} t = floor( (3+sqrt(8*n-7))/2 ) s = n -(t^2-3*t+2)/2 x = 2*s*t y = t^2 -s^2 z = t^2 +s^2 {x,y,z} is a Pythagorean triple examples: 1 -> {3,4,5} 2 -> {6,8,10} (a multiple of #1) 3 -> {12,5,13} 4 -> {8,15,17} 5 -> {16,12,20} (a multiple of #1)

The reasoning behind the formulas


The use of two numbers, s and t, to generate Pythagorean triples is well known. It can generate all primitive Pythagorean triples, as well as some that are multiples of the primitive ones. t must be greater than s and both >= 1 to avoid numbers less than one for x, y, and z. So it seems reasonable to choose s and t from a grid of points with integer coordinates in an s-t plane. The restriction t>s means we must choose only points from above or below the main diagonal in the first quadrant. A function that maps the s and t coordinates to integers >= 1 above the main diagonal is n(s,t) = (t-2)*(t-1)/2+s, which is reminiscent of triangular numbers. But we want to go the other way, to solve for s and t given n. So start by solving for the variable that is present on the right hand side with the highest power. We may do this using the quadratic formula, treating s and n as constants. We get t=(3+sqrt(1-8*s+8*n))/2. We know that s had to be at least as big as 1, so replace s with a 1 as an approximation. This formula for t will then give the correct integer part, so use the floor function to eliminate any decimal portion. t=floor((3+sqrt(8*n-7))/2). Once we have t, solving for s is easy, just solve for s in the n(s,t) formula to get s in terms of t and n.
6 5 4 3 2 1 t |11 12 13 14 15 | 7 8 9 10 . | 4 5 6 . . | 2 3 . . . | 1 . . . . | . . . . . +-------------- s 1 2 3 4 5

[ Figure 1 ]

More detailed explaination. I recieved formulas from Jay McKinley X > 2 can be in a Pythagorean triple. that show that any integer

X odd: Y = (X^2-1)/2, Z = (X^2+1)/2 X even: Y = (X^2-4)/4, Z = (X^2+4)/4

However, not all triples can be found this way, e.g. 20, 21, 29

Further consideration
Now if we wish to attempt to eliminate non-primitive Pythagorean triples (those not all divisible by any one number >1) then we need to eliminate the numbers that give an s-t pair that are both odd or both even, since such pairs produce Pythagorean triples that are divisible by 2. The pattern of elimination is like that of the squares of one color on a chess board. The sequence of numbers to choose from is then {1,3,4,6,8,10,11,13,15,17,19,21,22,24,26,28,...} where the pattern is 2 odd, 4 even, 6 odd, 8 even, etc. To further eliminate numbers that yield non-primitive Pythagorean triples requires inspection, since the rule is that s and t must be co-prime and not both odd and no elimination pattern could yield co-prime s and t pairs, at least none that could be encoded into a formula. Among those numbers already given, 13 is the only one that still results in s and t with a common factor greater than 1.

An HP-48 Program to generate Pythagorean triples with the above method


This should be entered by hand, as I use << and >> for angle brackets and -> for the single right-arrow character, and sqrt for the square root character. N.PYT

One more note...


on the subject of solving for Z and Y from X or Z and X from Y The formulas for X,Y, and Z in terms of S and T are set up so that X will always be even, and Y will always be odd (if you're using S and T co-prime and not both odd). So if you were handed an even number for X or Y, call it X and divide it by 2 then write out all the factorizations of the form X/2=S*T where S<T and S and T are >0. Then use those S,T pairs in the formulas for Y and Z. If you were handed an odd number, call it Y and set it equal to (T-S)*(T+S). write out all the factorizations of Y (where T-S<T+S ) and solve for S and T using (if p and r are the two factors, p<r) T=(p+r)/2 and S=(r-p)/2, then use that S,T pair in the formulas for X and Z. - Robert

You might also like