Primitive Pythagorean Triples, or PPT’s, are non-trivial integer solutions to the Pythagorean equation z2 = x2 + y2, where we assume that 0<x<y<z and that x, y and z are co-prime.
Euclid’s formulae allow PPT’s to be generated using 2 (positive integer) parameters, usually denoted by m and n. The PPT’s (usually) take the form ( m2– n2, 2mn, m2+n2) or ( 2mn, m2-n2, m2+n2), where m>n≥1, m and n are co-prime, and m-n is odd. Clearly, m2+n2 is the largest number in each triple.
Note: It is easier to spot patterns in generated triples if these are ordered as in (x, y, z) where x<y<z.
There are 2 cases that can occur, i.e. ( m2– n2, 2mn, m2+n2) where m2-n2< 2mn and
( 2mn, m2-n2, m2+n2) where 2mn < m2-n2. If m2-n2< 2mn then it is easy to show that
n < m < (1+√2)n. Hence if we wished to write a program to generate such triples we would first have to choose n from 1,2,3, … and then choose m from (n+1), …, int((1+√2)n).
Any proofs that I have seen that establish the above formulae for x, y and z make use of parity, factorisability and co-primeness, but interestingly do not make use of geometry.
It cannot be assumed of course that x, y, and z form the sides of a triangle. That has to be proved.
However the consequences of proving that x, y, and z form the sides of a triangle lead to a simple method of generating PPT’s which is also simply proved.
Returning to the equation z2= x2+ y2, it is easy to show that z<x+y, since x2+ y2 < (x+y)2 and so, since 0<x<y<z, x, y, and z do form the sides of a triangle. It follows, from z<x+y and x<y, that z<2y. Hence y<z<2y, and so there is an integer a, where 0<a<y, such that z=y+a. Also, since 0<x<y, there is an integer b, where 0<b<y, such that x=y-b.
So, z2= x2+ y2 becomes (y+a)2 = (y-b)2+ y2, where 0<a<y and 0<b<y.
After multiplying out and re-arranging (y+a)2 = (y-b)2+ y2 we get, 2a(a+b) = (y – (a+b))2.
Hence 2|(y-(a+b)) and so y-(a+b) = 2c, where c is an integer and it is easy to show that c>0.
Note: [2c = y – (a+b) = y – (z-y + y-x) = y + x – z > 0]
So, x = a+2c, y = a + b + 2c = (x+b) and z = 2a + b + 2c = (y+a), where a(a+b)= 2c2.
Note: it is easy to show that a<√2 c.
To generate PPT’s, first choose any integral c, c≥1; then choose integral a in the range 1≤a<√2c so that a|2c2; then finally choose integral b , b≥1, using a(a+b)= 2c2, or b=(2c²)/a – a, making sure that the resulting x, y and z have no common factors.
If c=1 then a=1 and b = 1. Hence we get the PPT (3,4,5).
If c=2 then a=1 and b=7, and this gives the PPT (5,12,13)
If c=3 then a=1 and b=17 or a=2 and b=7, giving PPT’s (7,24,25) and (8,15,17).
If c=4 then a=1 and b=31 giving PPT (9,40,41).
If c=5 then a=1 and b=49 or a=2 and b= 23 giving PPT’s ( 11, 60, 61) and ( 12, 35, 37).
If c=6 then a = 1 and b = 71 and we get the PPT (13,84,85).
The following is a short Python program to generate PPT’s using this method.
import math #Generating primitive Pythagorean Triples # def hcf(x,y): #assume y!=x while y!=x: if y>x: y=y-x else: x=x-y #endif #endwhile return x #enddef # def generate_triples(): for c in range(1,60): for a in range(1,int(math.sqrt(2)*c)+1): if int(2*c*c/a)==2*c*c/a: b=int(2*c*c/a)-a x=a+2*c y=a+b+2*c z=2*a+b+2*c if hcf(x,y)==1: print ("c = ",c) print ("x = ",x) print ("y = ",y) print ("z = ",z) print () #endif #endif #endfor #endfor #enddef # generate_triples()
These estimates can be refined a little. For example, if m is the positive root of the equation 36 = m³ + 6m² then a<md<a+b/2.
Suppose that md≤a, then from ** we have 3a(a+b)(2a+b)+36a²d<(6d)³ and so
3a(a+b)(2a+b)<36d(6d² – a²). Now md≤a implies that d≤a/m and so,
3a(a+b)(2a+b)<36d(6(a/m)² – a²) = 36a²d(6/m² – 1) = 6a²dm ≤ 6a³.
So, 3a(a+b)(2a+b) < 6a³ and therefore 3ab(3a+b)<0 and so 3a+b<0 which is not possible.