Plimpton 322 and Pythagorean triples: rebuilding a Babylonian table in Python
Plimpton 322 lists 15 right triangles with whole-number sides, c. 1822 to 1762 BCE. I rebuild every row in Python and locate the scribe's 7 known errors.
119 and 169 are the short side and the diagonal of a right triangle whose other side is 120, and they are row 1 of Plimpton 322. The tablet is Old Babylonian, from Larsa in southern Iraq, written c. 1822 to 1762 BCE, and each of its 15 rows gives a right triangle with whole-number sides. Row 15, with the scribe’s error corrected, is 28, 45, 53. In modern terms each row is a Pythagorean triple, a² + b² = c².
What the table was for is still argued: number theory, a teacher’s list of problems, or an exact trigonometric table. I rebuilt it in Python both ways scholars say it could have been made, and let the code find the scribe’s mistakes (plimpton322.py, in the series Ancient algorithms, implemented).
What Plimpton 322 says
The surviving part of the tablet has 4 columns with headings and 15 ruled rows of numbers. The numbers are in base 60, with no zero and no mark for the units place; the post on YBC 7289 explains the notation. Here is the table with the scribe’s errors corrected, after Robson (2001, Table 1), and with the long side, which the tablet never writes, added from the reconstruction:
| Row | Column I | II: short side | III: diagonal | Short side | Long side | Diagonal |
|---|---|---|---|---|---|---|
| 1 | 1;59,00,15 | 1 59 | 2 49 | 119 | 120 | 169 |
| 2 | 1;56,56,58,14,50,06,15 | 56 07 | 1 20 25 | 3,367 | 3,456 | 4,825 |
| 3 | 1;55,07,41,15,33,45 | 1 16 41 | 1 50 49 | 4,601 | 4,800 | 6,649 |
| 4 | 1;53,10,29,32,52,16 | 3 31 49 | 5 09 01 | 12,709 | 13,500 | 18,541 |
| 5 | 1;48,54,01,40 | 1 05 | 1 37 | 65 | 72 | 97 |
| 6 | 1;47,06,41,40 | 5 19 | 8 01 | 319 | 360 | 481 |
| 7 | 1;43,11,56,28,26,40 | 38 11 | 59 01 | 2,291 | 2,700 | 3,541 |
| 8 | 1;41,33,45,14,03,45 | 13 19 | 20 49 | 799 | 960 | 1,249 |
| 9 | 1;38,33,36,36 | 8 01 | 12 49 | 481 | 600 | 769 |
| 10 | 1;35,10,02,28,27,24,26,40 | 1 22 41 | 2 16 01 | 4,961 | 6,480 | 8,161 |
| 11 | 1;33,45 | 45 | 1 15 | 45 | 60 | 75 |
| 12 | 1;29,21,54,02,15 | 27 59 | 48 49 | 1,679 | 2,400 | 2,929 |
| 13 | 1;27,00,03,45 | 2 41 | 4 49 | 161 | 240 | 289 |
| 14 | 1;25,48,51,35,06,40 | 29 31 | 53 49 | 1,771 | 2,700 | 3,229 |
| 15 | 1;23,13,46,40 | 28 | 53 | 28 | 45 | 53 |
Every row is exact, from 119² + 120² = 169² to 28² + 45² = 53², and the rows are sorted by column I, the square of diagonal over long side: row 1 is (169/120)² = 1;59,00,15. Every long side is a regular number, one with no prime factors other than 2, 3 and 5, so column I is a finite base-60 fraction.
Who wrote it, and when
- The tablet. Item 322 in Isaac Mendelsohn’s 1943 catalog of Columbia University’s cuneiform tablets, listed as a “commercial account” (Robson 2001, p. 172), now in Columbia’s Rare Book and Manuscript Library. The surviving piece measures about 12.7 by 8.8 cm.
- How it got there. Dug up illegally in the 1920s, sold by the dealer Edgar J. Banks to the publisher George Arthur Plimpton, and left to Columbia shortly before Plimpton died in 1936 (Robson 2001, pp. 171 to 172).
- Where it was written. Larsa, modern Tell Senkereh. Banks’s price list gives “Senkereh”, and the script of the headings matches other tablets from Larsa (Robson 2001, p. 172). CDLI, entry P254790, also gives Larsa.
- When. Robson dates it by its format alone. Tables laid out across a landscape tablet, with a last column headed MU.BI.IM, “its name”, are attested from 1822 BCE onward, and Hammurabi of Babylon took Larsa in 1762 BCE. That puts the tablet in the 60 years or so before 1762 BCE. The date is an inference.
- First published. Otto Neugebauer and Abraham Sachs, Mathematical Cuneiform Texts (1945), as text A.
The left edge is broken along a column line, and Robson (2001, p. 172) notes traces of glue in the break; Mansfield and Wildberger (2017, p. 397) take it as modern glue. Whatever stood to the left of column I is lost, and the reverse is blank but ruled for more rows.
The headings, transcribed and translated
The 4 headings are in a mix of Sumerian word-signs and Akkadian. The transliteration below is Robson’s (2001, pp. 191 to 192), with her restorations of the damaged signs in square brackets.
Column I:
[ta]-ki-il-ti ṣi-li-ip-tim / [ša 1 in]-na-as-sà-hu-ú-ma SAG i-il-lu-ú
| Akkadian | Meaning |
|---|---|
| takilti | the takiltum of, a word from kullum, “to hold”; Robson suggests “holding square” |
| ṣiliptim | of the diagonal |
| ša | which, from which |
| 1 | 1 (restored) |
| innassahu | is torn out, from nasāhum, “to tear out” |
| -ma | and then, so that |
| SAG | the short side (Akkadian pūtum) |
| illû | comes up, from elûm, “to rise” |
Column II: ÍB.SI₈ SAG, “the square-side of the short side”. Column III: ÍB.SI₈ ṣiliptim, “the square-side of the diagonal”. Column IV: MU.BI.IM, “its name”. The entries read ki 1, ki 2 and so on, “its place” (Mansfield and Wildberger 2017).
My translation of column I: “The holding square of the diagonal; take 1 away from it, and the square of the short side comes out.” Robson (2001, p. 192) translates the start as “the holding-square of the diagonal from which 1 is torn out”.
ÍB.SI₈ is the word-sign for Akkadian mithartum, “square”, yet columns II and III hold lengths. Robson explains that mithartum also names the side of a square, so over these columns it means “square-side”. The heading of column I is a recipe: take the square in column I, remove 1, and what is left is the square of the short side.
The tablet shows no working and no use, and no ancient copy is known (Robson 2001, p. 199). The 1s of column I sit on the broken edge; Robson (p. 190) and Mansfield and Wildberger restore them.
How the table can be rebuilt from reciprocal pairs
E. M. Bruins proposed in 1949 that the table was built from reciprocal pairs, and Robson (2001) restated this reading with evidence from other tablets. A reciprocal pair is a number and its reciprocal: 2;24 and 0;25 are a pair, because 2.4 × 5/12 = 1. Scribes kept tables of them, called igi (the number) and igibi (its reciprocal), and divided by multiplying with them.
Row 1, step by step:
- Take the igi
x = 2;24(= 12/5) and its igibi1/x = 0;25(= 5/12). - Halve their difference:
(2;24 - 0;25)/2 = 0;59,30. Halve their sum:(2;24 + 0;25)/2 = 1;24,30. - Square the second:
1;24,30² = 1;59,00,15. That is column I. - Clear the fractions. Both numbers end in 30, so multiply both by 2:
1;59and2;49. Read without the point, these are1 59and2 49, columns II and III. The long side is the multiplier, 2, which is 2 00 = 120 in the same reading.
Row 15, as Robson (2001, p. 192) works it: the igi is 1;48 and its reciprocal 0;33,20. Half the difference is 0;37,20 and half the sum 1;10,40, with long side 1. Multiply by 3 (both end in a multiple of 20): 1;52, 3 and 3;32. Multiply by 5: 9;20, 15 and 17;40. Multiply by 3: 28, 45 and 53. The code reads the last digits 52 and 32 as both divisible by 4 and multiplies by 15 in 1 step, which gives the same sides. Friberg (2007) calls this clearing of trailing digits the trailing-part algorithm.
The 15 igi values run from 2;24 down to 1;48. Robson (2001, p. 196) notes that each igi and its reciprocal on the tablet have at most 4 base-60 digits, and she limits the total length of each pair.1 With at most 4 digits each and 7 in all, I ran the rule over every regular number from 1;48 to 2;24, and it admits exactly 18: the tablet’s 15, plus 3 that Robson lists as missing lines 4a, 8a and 11a. She argues that 4a and 11a give sides longer than any on the tablet, and that 8a is hard to derive from the standard tables. All 3 have q above 60 in the p, q reading below.
Why the reciprocal method works
Write x for the igi. Then:
So half the sum and half the difference are the diagonal and short side of a right triangle with long side 1. That is the identity the heading of column I describes: the square of the diagonal, less 1, is the square of the short side.
Robson connects it to the school problem YBC 6967, which finds a reciprocal pair with difference 7 by cutting a rectangle into an L shape and completing the square: the corner square has side half the difference, and the completed square has side half the sum (Robson 2001, pp. 183 to 185). Rescaled so the pair multiplies to 1, the same numbers give her 2 triangles, 2 23, 24, 2 25 and 12, 5, 13, which the tests check.
The other reading: generating pairs p and q
Neugebauer and Sachs (1945) read the table as built from 2 regular whole numbers p > q:
Row 1 uses p = 12, q = 5: 144 - 25 = 119, 2 × 12 × 5 = 120, 144 + 25 = 169. With x = p/q, the 2 readings give the same triangle, scaled by 2pq, and a property test checks that they agree after common factors are removed.
The p, q reading also accounts for which rows appear. Take every coprime pair of regular numbers with q at most 60 and p/q at most 2;24, sorted by column I: there are 38, and the first 15 are the tablet’s rows, in order. Derek de Solla Price noticed this in 1964, and Mansfield and Wildberger (2017, pp. 405 to 406) give a procedure a scribe could follow with the standard reciprocal table.
Robson (2001, pp. 177 to 179) argues against the p, q reading on 3 grounds:
- Choosing the pairs. The standard reciprocal table, which holds every
pandq, has 44 numbers, so it offers the scribe 946 pairs. Ruling out pairs of 2 odd numbers leaves 880, and keeping only coprime pairs leaves 159, but there is no Old Babylonian evidence for the ideas of odd and even or of coprime numbers. The reading does not say how the scribe chose 15 of them. - Column order and column I. Old Babylonian tables run from left to right with the first column sorted, and columns to the left hold steps toward those on the right. In the p, q reading column I is derived from columns II and III, so its place and its heading do not fit, and columns of
pandqwould not be sorted. - The errors. Gillings and Neugebauer explain the row 2 diagonal by 3 slips in a row. Price explains it with 1, taking
27²as2 03 45, but cannot say why the scribe would do that (p. 179).
The scribal errors, found by code
Robson (2001, Table 2) lists 7 errors on the tablet. The module stores the tablet’s numbers as written, errors included, compares each cell with the rebuilt table, and names the slip:
| Row | Column | Written | Correct | The code’s diagnosis |
|---|---|---|---|---|
| 2 | I | …14 56 15 | …14 50 06 15 | 2 places added: 50 + 06 = 56 |
| 8 | I | …33 59 03 45 | …33 45 14 03 45 | 2 places added: 45 + 14 = 59 |
| 13 | I | 1 27 03 45 | 1 27 00 03 45 | empty place left out |
| 9 | II | 9 01 | 8 01 | 1 digit miscopied |
| 13 | II | 7 12 01 | 2 41 | the square of the correct value: 161² = 25,921 = 7 12 01 |
| 15 | II | 56 | 28 | twice the correct value |
| 2 | III | 3 12 01 | 1 20 25 | no simple relation |
These are the 7 cells Robson lists. Her descriptions match the code’s for 5 of them; for rows 2 and 8 of column I she says 2 places were run together, where the code reports the same digits as 2 places added.
- Row 13, column II holds the square of the short side: the scribe took 1 from column I and forgot the square root. Robson reads this as evidence that columns II and III were computed from column I.
- Row 15 has 56 and 53. The reciprocal reading gives 28, 45, 53, so 56 is twice too large;
p = 9, q = 5gives 56, 90, 106, so 53 is half too small. Run on the p, q rows, the code moves the error to column III. - Row 2, column III: Robson (2001, pp. 192 to 193) suggests the scribe multiplied by 12 twice too often, got
3 13 00 00for the diagonal, and copied it back misread as3 12 01.
The code reports 1 more difference. Row 11 has 45 and 1 15, the triangle 45, 60, 75, where full reduction gives 3, 4, 5; read without a point, they are the unreduced 0;45 and 1;15. Robson and Mansfield and Wildberger both list 45 and 1 15, and neither counts it as an error.
For each written row, d² - b² must be a perfect square if b and d belong to a right triangle with a whole long side. Rows 2, 9, 13 and 15 fail that test, and they are the 4 rows with an error in column II or III.
The Python
This version clears the fractions in 1 step with a least common multiple, which gives the same sides as the scribe’s step-by-step method.
from fractions import Fraction
from math import lcm
def is_regular(n: int) -> bool:
"""True when n has no prime factors other than 2, 3 and 5."""
for p in (2, 3, 5):
while n % p == 0:
n //= p
return n == 1
def plimpton_row(x: Fraction) -> tuple[Fraction, int, int, int]:
"""Column I, then the short side, long side and diagonal, from the igi x."""
if not (is_regular(x.numerator) and is_regular(x.denominator)):
raise ValueError(f"{x} is not regular")
short = (x - 1 / x) / 2 # half the difference of x and its reciprocal
diagonal = (x + 1 / x) / 2 # half the sum
long_side = lcm(short.denominator, diagonal.denominator)
return diagonal**2, int(short * long_side), long_side, int(diagonal * long_side)
def base60(x: Fraction) -> str:
"""A regular number in base 60, written like 1;59,00,15."""
whole, rest, digits = int(x), x - int(x), []
while rest:
rest *= 60
digits.append(f"{int(rest):02d}")
rest -= int(rest)
return f"{whole};" + ",".join(digits) if digits else str(whole)
for x in (Fraction(12, 5), Fraction(64, 27), Fraction(9, 5)):
column_i, b, long_side, d = plimpton_row(x)
print(base60(column_i), b, long_side, d)
# 1;59,00,15 119 120 169
# 1;56,56,58,14,50,06,15 3367 3456 4825
# 1;23,13,46,40 28 45 53
The repo version follows the scribe more closely, with trailing_part_steps, robson_candidates, generator_pairs and compare_with_tablet. Its tests check every row against Robson’s Tables 1, 4 and 6 (all but row 11’s long side, where the tablet keeps a common factor), the 7 errors, Robson’s and Mansfield and Wildberger’s worked steps, and, with Hypothesis, that every regular igi gives a primitive triple and that both readings agree.
Generating Pythagorean triples with Euclid’s formula
The modern way to generate every Pythagorean triple is Euclid’s formula. For whole numbers m > n > 0, coprime and not both odd:
is a primitive triple, one whose 3 sides share no factor, and every primitive triple comes out exactly once. Euclid’s Elements, Book X, Lemma 1 to Proposition 29 (c. 300 BCE), builds it from the identity that a product plus the square of half the difference of its factors equals the square of half their sum, the same identity as the reciprocal method.
from math import gcd, isqrt
def euclid_triples(max_diagonal: int) -> list[tuple[int, int, int]]:
"""Every primitive triple (a, b, c) with c <= max_diagonal, sorted by c."""
triples = []
for m in range(2, isqrt(max_diagonal) + 1):
for n in range(1, m):
if (m - n) % 2 and gcd(m, n) == 1 and m * m + n * n <= max_diagonal:
triples.append((m * m - n * n, 2 * m * n, m * m + n * n))
return sorted(triples, key=lambda t: (t[2], t[0]))
print(euclid_triples(30))
# [(3, 4, 5), (5, 12, 13), (15, 8, 17), (7, 24, 25), (21, 20, 29)]
There are 16 primitive triples with a diagonal up to 100 and 158 up to 1,000.
Euclid’s formula takes any m and n. The tablet takes only regular p and q, so column I is exact in base 60, and with q at most 60 its 15 rows are the first 15 such triangles, from almost half a square (row 1) to a short side 0.62 of the long side (row 15). Robson’s lines 4a, 8a and 11a fall in that range with q above 60.
What is debated
- What it was for.
- Number theory. Neugebauer and Sachs (1945) wrote of the tablet’s number-theoretical character. Robson (2001) argues there is no evidence of Old Babylonian research mathematics of this kind.
- A teacher’s aid. Friberg (1981), Buck (1980) and Robson (2001, 2002) read it as a teacher’s list for setting problems about right triangles or reciprocal pairs, with intermediate values a teacher could check. Mansfield and Wildberger (2017) reply that the square roots implied by column I are too hard for school problems.
- Exact trigonometry. Mansfield and Wildberger (2017) argue that it is a trigonometric table built on ratios with no angles, with column I as an index. Robson (2001, pp. 179 to 183) had argued that Old Babylonian geometry had no measured angle, so no trigonometric reading can be historical, and a 2017 note from the University of Hamburg’s Centre for the Study of Manuscript Cultures pointed out that the tablet “contains no data on the said angles”. Mansfield and Wildberger write that there is no known historical evidence of how the table was used.
- Whether the table was meant to continue. The reverse is ruled for more rows. Under the generating-pair rule, 23 more rows would complete 38, and Mansfield and Wildberger (2017) and Britton, Proust and Shnider (2011) think those were planned.
Key takeaways
- Plimpton 322 (Larsa, c. 1822 to 1762 BCE, Columbia University) lists the short side and diagonal of 15 right triangles with whole-number sides, sorted by the square of diagonal over long side.
- Every row can be rebuilt from a regular number and its reciprocal, or from 2 regular numbers
pandq, and comparing the result with the tablet finds Robson’s 7 errors. - What the table was for is open. The teacher’s-aid reading and the exact-trigonometry reading both have published defenders, and the tablet has no angles.
- The code and tests are in ancient-algorithms. The previous post covers the square root of 2 on YBC 7289, and the next takes up Euclid’s algorithm.
Sources
- O. Neugebauer and A. Sachs, Mathematical Cuneiform Texts. American Oriental Series 29, American Oriental Society, 1945. Text A.
- E. Robson, “Neither Sherlock Holmes nor Babylon: a reassessment of Plimpton 322”. Historia Mathematica 28, 2001, 167 to 206. The source of the transcription, the errors and the reciprocal reconstruction used here.
- E. Robson, “Words and pictures: new light on Plimpton 322”. American Mathematical Monthly 109, 2002, 105 to 120.
- D. F. Mansfield and N. J. Wildberger, “Plimpton 322 is Babylonian exact sexagesimal trigonometry”. Historia Mathematica 44, 2017, 395 to 419. Open access.
- J. Friberg, “Methods and traditions of Babylonian mathematics: Plimpton 322, Pythagorean triples, and the Babylonian triangle parameter equations”. Historia Mathematica 8, 1981, 277 to 318.
- R. C. Buck, “Sherlock Holmes in Babylon”. American Mathematical Monthly 87, 1980, 335 to 345.
- E. M. Bruins, “On Plimpton 322: Pythagorean numbers in Babylonian mathematics”. Proceedings of the Koninklijke Nederlandse Akademie van Wetenschappen 52, 1949, 629 to 632.
- J. P. Britton, C. Proust and S. Shnider, “Plimpton 322: a review and a different perspective”. Archive for History of Exact Sciences 65, 2011, 519 to 566.
- Euclid, Elements, Book X, Lemma 1 to Proposition 29, in D. E. Joyce’s online edition.
- Cuneiform Digital Library Initiative, Plimpton 322, P254790.
Footnotes
-
Robson writes that the total is “always less than seven”, but her own pairs reach 7 digits, for example 2 22 13 20 with 25 18 45. The code allows 7, which reproduces her Tables 8 and 9. Allowing 4 digits each with no total limit adds her lines 6a, 9a and 12a, as her note 34 says. ↩
Common questions
What does Plimpton 322 say?↓
Plimpton 322 is a table with 4 surviving columns and 15 rows. Column I gives the square of the diagonal of a right triangle whose long side is 1. Columns II and III give the short side and the diagonal of the same triangle scaled up to whole numbers, for example 119 and 169, whose long side is 120. Column IV numbers the rows. The headings call column I the 'takiltum of the diagonal' from which 1 is taken away so that the short side comes up, and columns II and III the 'square-side' of the short side and of the diagonal.
Was the Pythagorean theorem known before Pythagoras?↓
The relation was used. Old Babylonian tablets from more than 1,000 years before Pythagoras compute diagonals from sides with it: YBC 7289 multiplies a side by the square root of 2, BM 96957 + VAT 6598 estimates the diagonal of a gate from its height and width, and Plimpton 322 lists 15 triangles that satisfy it exactly. Historians call this the diagonal rule. No Old Babylonian proof of it survives, so whether this counts as knowing the theorem depends on whether you require a proof.
Is Plimpton 322 a trigonometric table?↓
Mansfield and Wildberger (2017) argue that it is a ratio-based trigonometric table with no angles. Robson (2001) argued before them that Old Babylonian mathematics had no concept of measured angle, so no trigonometric reading can be right, and she reads the tablet as a teacher's list for setting problems. The tablet itself contains no angles, and no text shows how it was used. The claim is disputed.
How do you generate Pythagorean triples?↓
Use Euclid's formula: for whole numbers m > n > 0 that share no factor and are not both odd, (m^2 - n^2, 2mn, m^2 + n^2) is a primitive Pythagorean triple, and every primitive triple arises once this way. For example m = 2, n = 1 gives (3, 4, 5), and m = 12, n = 5 gives (119, 120, 169), row 1 of Plimpton 322.
What are the errors on Plimpton 322?↓
Robson (2001) lists 7. 3 are in column I: 2 places run together in rows 2 and 8, and an empty place left out in row 13. Row 9 has 9 01 for 8 01, row 13 has the square of the short side instead of the short side, row 15 has a value twice or half the right one, and row 2 has 3 12 01 for 1 20 25, an error with no simple explanation.