Program: RMptriples.z80
I was motivated to write this after using a Pythagorean Triple - 21, 220, 221 - in the 3D version of the Lagrange Points program to perform a small rotation.
I discovered these can be generated by the so-called Euclid's Formula, even though the method seems to have been known to the Babylonians at least 1500 years before the time of Euclid (see e.g. info here about clay tablet Plimpton 322 - see below).
To generate triples (a, b, c), the formula says:
a = m*m - n*n; b = 2*m*n; c = m*m +n*n
where m and n:
are positive integers
m > n
one of m, n is even
one of m, n is odd
m, n are co-prime
To ensure this last condition, I used the more efficient form of Euclids's Algorithm from the Highest Common Factor program.
Conditions 3, 4 and 5 ensure the triples are primitive, i.e. they cannot be reduced to a simpler form, as e.g. triple (6, 8, 10) can be.
In the program, m takes integer values from 2 to 10. The last number can be edited of course to increase the number of triples. n takes values from 1 to m-1.
The triples are displayed in the following order: short side, longer side, hypotenuse. At some point it would be good to sort the output, e.g. by hypotenuse. However, I can see a problem: the list will not be complete for the range of numbers produced. This can be seen from the above output where e.g. a triple with c=113 is generated before one with c=85. The program stops with m=10, so could we have missed some with c smaller than the largest of 181 shown? The answer is yes - by making m=11, 3 of the extra 5 triples generated have values of c less than 181.
Plimpton 322
Plimpton 322 is a list of triangles composed of some Pythagorean Triples, and their associated properties, in the form of a table with 4 columns and 15 rows ordered in descending sequence of (short side/long side) squared. As such, it can be considered a form of trigonometric table, but I'll qualify that a little later.
There are 15 triples implied on the tablet (it lists the short sides and hypotenuses, but not the longer sides). Of these, 13 are primitive. Clearly the Babylonians knew how to determine if numbers are co-prime or not and presumably also about the concept of prime numbers. Eight (implied) primitive triples have c > 1000 and the largest one has a = 12709 and c = 18541. These are large triangles! To generate the largest, m=125 and n=54. I wonder what method they used to determine that these are co-prime and if they knew about Euclid's Algorithm?
The tablet is broken and it is possible that there are missing columns at the left. Angles aren't used, but can be determined. If we define the angle as being next to the long side and hypotenuse, then angles* range from ~45 degrees at the top of the table to ~32 degrees at the bottom. The difference between the angles associated with successive rows is just under one degree on average, but actually varies from less than half a degree to nearly two and there seems to be no pattern to this.
Why were those particular triples chosen? I found that by increasing the maximum value for m to the 125 needed for the largest triangle in the tablet, the program generated 441 triples in this range, providing many more suitable candidates for a more evenly-spaced table.
Why this range of angles? Perhaps it is one of a set - four such tablets could cover angles from 0 to 45 degrees (albeit with 60 rather than 45 entries!). For 45 to 90 degrees, the triples could be reused, switching the short and longer sides.
Was the tablet intended to be used as a trigonometric table, as we understand that term, with angles being present originally in a column now missing? (Presumably, angles would have had to be obtained by direct measurement of suitably scaled-down triangles). If so, it predates those of the Ancient Greeks, who are usually regarded as having developed the first ones, by 1500+ years! However, such a table would have been of limited practical use:
the angles, if present, would not have been 'tidy' integers or rational numbersÂ
there is an uneven difference in angle between successive entries
the number of entries (15) also counts against (would have expected 14 for the range given).
Perhaps instead they were searching for triples that could produce (near) whole integer angles and this was a work in progress, a prototype of trig. tables to come?
Regardless, what I find truly incredible, perhaps even more than the information it contains, is that in spite of its great antiquity, it is in a form that we recognise today - an ordered numbered table consisting of rows and columns!
* angles of the triangles associated with the triples:
44.76
44.25
43.79
43.27
42.07
41.54
40.32
39.77
38.72
37.44
36.87
34.98
33.86
33.26
31.89