The Magic Encyclopedia ™

Pythagorean Triplets

The "Pyhagorean Triplet" (a,b,c) is a solution to the equation of Pythagoras:
a2 + b2 = c2.
recently I found the following parametrisation:

PT([n,k]): (a,b,c) = (2n(2k+n+1),c-2n2,a+(2k+1)2)
n = 1,2,... ; k = 0,1,...

to be an exhaustive one. (statement needs analitic proof)
Non-primitive PT's can be located as follows:

let p be a factor of n other then 2, then
PT([n,k]) = p2 PT([n/p,(2k-p+1)/2p])
provided (2k-p+1)/2p is an integer
or (2k-p+1) % 2p == 0
ie k = pl + (p-1)/2 ; l = 0,1,..

c = 2n(2k+n+1)+(2k+1)2 = 4k2 + 4k(n+1) + (n+1)2 + n2 ==>
4k2 + 4k(n+1) + (n+1)2 + n2 - c = 0 ==>
k = [-4(n+1) +/- sqrt(16(n+1)2 - 16((n+1)2 + n2 - c) ]/ 8 ==>
k = [sqrt(c - n2) - (n+1)] / 2
which means:
c - n2 = p2 and p - (n+1) = 2k ; k = 0,1,....
ie p - (n + 1) >= 0 ==> p - 1 - sqrt(c-p2) >= 0 ==>
sqrt(c-p2) <= p-1 ==> c-p2 <= (p-1)2 ==>
c <= p2 + (p-1)2

thus suffices to locate c within the table
[n,k]c = [sqrt(c-p2),(p-sqrt(c-p2)-1)/2] ; p = max(2,q),..,trunc(sqrt(c))
q the least integer satisfying c <= q2 + (q-1)2

further let ptc(c) be the amount of PT's (a,b,c) and p a prime number then:
ptc(p) = 0 or 1;
ptc(pn) = n ptc(p)
ptc(x * y) = ptc(x) + (2 ptc(x) + 1) ptc(y)

With the "locating procedure" it can be verified that:
ptc(c) = 0 for c = 1,2,3,7,11,19,...
ptc(c) = 1 for c = 5,13,17,29,37,...
for the ptc formulae's I've only numerical evidence up to multiplication of 5 primes (first 10 primes) reason for the formulae illudes me currently.

Excercise
verification of above statements (first few primes)
(note: for ranges of p see above)
c p2 n = sqrt(c - p2) k = (p-n-1)/2 PT([n,k]) = (a,b,c) or
error reasoning
ptc(c)
1,2,3 trunc(sqrt(c)) = 1 < 2 ==> error 0
5 22 = 4 1 0 PT([1,0]) = (4,3,5) 1
7 trunc(sqrt(7)) = 2 and
22 + 12 = 5 < 7 ==> error
0
11 32 = 9 sqrt(2) n not integer ==> error 0
13 32 = 9 2 0 PT([2,0]) = (12,5,13) 1
17 42 = 16 1 1 PT([1,1]) = (8,15,17) 1
19,23 42 = 16 sqrt(3),sqrt(7) n not integer ==> error 0
29 52 = 25 2 1 PT([2,1]) = (20,21,29) 1
31 52 = 25 sqrt(6) n not integer ==> error 0
37 52 = 25 sqrt(12) n not integer ==> error 1
62 = 36 1 2 PT([1,2]) = (12,35,37)
41 52 = 25 4 0 PT([4,0]) = (40,9,41) 1
62 = 36 sqrt(5) n not integer ==> error
verification of above statements (some composite numbers)
25 25 <= 42 + 32 = 25 lowest possible p is 4
trunc(sqrt(25)) = 5 highest possible p is 5
ptc(25) = 2 ptc(5) = 2 [ptc(5)] = 2
counts: 5 * PT([1,0]) = 5 (4,3,5)
1
42 = 16 3 0 PT([3,0]) = (24,7,25)
35 35 <= 52 + 42 = 41 lowest possible p is 5
trunc(sqrt(35)) = 5 highest possible p is 5
ptc(35) = ptc(5*7) = [ptc(5)] + (2* ptc(5)]+1)ptc(7) = 1 + 0 = 1
counts: 7 * PT([1,0]) = 7 (4,3,5)
0
52 = 25 sqrt(10) n not integer ==> error
45 45 <= 62 + 52 = 61 lowest possible p is 6
trunc(sqrt(45)) = 6 highest possible p is 6
ptc(45) = ptc(325) = [2 ptc(3)] + (2*[2 ptc(3)]+1)ptc(5) = 0 + 1 = 1
1
62 = 36 3 1 PT([3,1]) = 9 (4,3,5)
65 65 <= 72 + 62 = 85 lowest possible p is 7
trunc(sqrt(65)) = 8 highest possible p is 8
ptc(65) = ptc(5*13) = ptc(5) + (2*ptc(5)+1)ptc(13) = 1 + 3 = 4
includes 5 * PT([2,0]) = 5 (12,5,13) and 13 * PT([1,0]) = 13 (4,3,5)
2
72 = 49 4 1 PT([4,1]) = (56,33,65)
82 = 64 1 3 PT([1,3]) = (16,63,65)