DEV Community

Ancient Biotechnology
Ancient Biotechnology

Posted on

Checking the Antikythera Mechanism's Calendar Maths with 20 Lines of Python

The Antikythera mechanism, the bronze geared device recovered from a Roman-era shipwreck off the Greek island of Antikythera in 1900–1901, is often called the oldest known analogue computer. Its back dials encode a handful of astronomical cycles that Babylonian and Greek astronomers already knew. A fun question for a developer is simple: how good were those cycles? You can check them in a few lines of Python.

The cycles on the back dials

Research published over the last two decades (notably by the Antikythera Mechanism Research Project, e.g. Freeth et al., Nature, 2006) identified these cycles on the back of the device:

  • Metonic cycle: 19 years ≈ 235 synodic (new moon to new moon) months. The upper back dial is a five-turn spiral divided into 235 cells.
  • Callippic cycle: 4 Metonic cycles = 76 years, shown on a small subsidiary dial.
  • Saros cycle: 223 synodic months, the classic eclipse-repeat period. The lower back dial is a four-turn spiral with 223 cells, and one of the surviving gears has 223 teeth.
  • Exeligmos: 3 Saros cycles, which brings eclipses back to roughly the same time of day.

Modern values to compare against

We need the mean lengths of the year and of the different kinds of month (values in days):

SYNODIC     = 29.530589   # new moon to new moon
TROPICAL    = 365.24219   # solar year
ANOMALISTIC = 27.554550   # perigee to perigee
DRACONIC    = 27.212221   # node to node

def show(label, a, b):
    print(f"{label:<28} {a:12.3f} {b:12.3f}  diff {a - b:+.3f} days")

# Metonic: 235 months vs 19 years
show("Metonic 235 m vs 19 y", 235 * SYNODIC, 19 * TROPICAL)

# Callippic: 940 months vs 76 years
show("Callippic 940 m vs 76 y", 940 * SYNODIC, 76 * TROPICAL)

# Saros: 223 synodic vs 239 anomalistic vs 242 draconic
show("Saros 223 syn vs 239 anom", 223 * SYNODIC, 239 * ANOMALISTIC)
show("Saros 223 syn vs 242 drac", 223 * SYNODIC, 242 * DRACONIC)

print("Saros in years:", round(223 * SYNODIC / TROPICAL, 3))
print("Saros fractional day:", round((223 * SYNODIC) % 1, 3))
Enter fullscreen mode Exit fullscreen mode

Output:

Metonic 235 m vs 19 y            6939.688     6939.602  diff +0.087 days
Callippic 940 m vs 76 y         27758.754    27758.406  diff +0.347 days
Saros 223 syn vs 239 anom        6585.321     6585.537  diff -0.216 days
Saros 223 syn vs 242 drac        6585.321     6585.357  diff -0.036 days
Saros in years: 18.03
Saros fractional day: 0.321
Enter fullscreen mode Exit fullscreen mode

What the numbers tell us

  1. The Metonic cycle drifts by only about two hours every 19 years. That is why it was good enough to run a lunisolar calendar, and why the device could show which month of the year a new moon fell in.
  2. The Saros works because three different months almost line up. An eclipse needs a new or full moon (synodic) near a node (draconic); the Moon's distance (anomalistic) affects what kind of eclipse you get. 223, 239 and 242 months all land within a few hours of each other, so an eclipse tends to be followed by a similar one about 18 years later.
  3. That leftover 0.321 day explains the Exeligmos. Each Saros shifts the eclipse by roughly a third of a day (about 8 hours), so the eclipse happens on a different part of the globe. Three Saros cycles add up to almost a whole day, which brings the eclipse back to about the same time of day. The mechanism has a small dial for exactly that correction.

Why this is a neat exercise

The mechanism's gear trains are essentially hard-coded ratios: the craftsmen picked integer tooth counts so that one turn of a dial matched one of these cycles. Re-deriving the cycles with modern constants is a nice reminder that good engineering is often about choosing the right approximation, not perfect precision. It is also a good teaching example for floating-point formatting, modular arithmetic (the fractional day), and comparing periods.

If you want the historical background (the 1901 recovery, the CT-scan work and the debate about who built it), I wrote a longer plain-language overview at Ancient Biotechnology: the Antikythera mechanism, the ancient computer. For more posts on ancient texts and lost technology, see ancientbiotech.com.

Constants are mean modern values; ancient astronomers used their own, slightly different period relations, so treat this as a sanity check, not a reconstruction.

Top comments (0)