If it had not been for two storms 2,000 years apart in the same area of the Mediterranean, the most important technological artifact from the ancient world could have been lost forever.

The first storm, in the middle of the 1st century B.C., sank a Roman merchant vessel laden with Greek treasures. The second storm, in A.D. 1900, drove a party of sponge divers to shelter off the tiny island of Antikythera, between Crete and the mainland of Greece. When the storm subsided, the divers tried their luck for sponges in the local waters and chanced on the wreck. Months later the divers returned, with backing from the Greek government. Over nine months they recovered a hoard of beautiful ancient Greek objects—rare bronzes, stunning glassware, amphorae, pottery and jewelry—in one of the first major underwater archaeological excavations in history.

One item attracted little attention at first: an undistinguished, heavily calcified lump the size of a phone book. Some months later it fell apart, revealing the remains of corroded bronze gearwheels—all sandwiched together and with teeth just one and a half millimeters long—along with plates covered in scientific scales and Greek inscriptions. The discovery was a shock: until then, the ancients were thought to have made gears only for crude mechanical tasks.

Three of the main fragments of the Antikythera mechanism, as the device has come to be known, are now on display at the Greek National Archaeological Museum in Athens. They look small and fragile, surrounded by imposing bronze statues and other artistic glories of ancient Greece. But their subtle power is even more shocking than anyone had imagined at first.

I first heard about the mechanism in 2000. I was a filmmaker, and astronomer Mike Edmunds of Cardiff University in Wales contacted me because he thought the mechanism would make a great subject for a TV documentary. I learned that over many decades researchers studying the mechanism had made considerable progress, suggesting that it calculated astronomical data, but they still had not been able to fully grasp how it worked. As a former mathematician, I became intensely interested in understanding the mechanism myself.

Edmunds and I gathered an international collaboration that eventually included historians, astronomers and two teams of imaging experts. In the past few years our group has reconstructed how nearly all the surviving parts worked and what functions they performed. The mechanism calculated the dates of lunar and solar eclipses, modeled the moon’s subtle apparent motions through the sky to the best of the available knowledge, and kept track of the dates of events of social significance, such as the Olympic Games. Nothing of comparable technological sophistication is known anywhere in the world for at least a millennium afterward. Had this unique specimen not survived, historians would have thought that it could not have existed at that time.

Early Pioneers
German philologist Albert Rehm was the first person to understand, around 1905, that the Antikythera mechanism was an astronomical calculator. Half a century later, when science historian Derek J. de Solla Price, then at the Institute for Advanced Study in Princeton, N.J., described the device in a Scientific American article, it still had revealed few of its secrets.

The device, Price suggested, was operated by turning a crank on its side, and it displayed its output by moving pointers on dials located on its front and back. By turning the crank, the user could set the machine on a certain date as indicated on a 365-day calendar dial in the front. (The dial could be rotated to adjust for an extra day every four years, as in today’s leap years.) At the same time, the crank powered all the other gears in the mechanism to yield the information corresponding to the set date.

A second front dial, concentric with the calendar, was marked out with 360 degrees and with the 12 signs representing the constellations of the zo­diac. These are the constellations crossed by the sun in its apparent motion with respect to the “fixed” stars—“motion” that in fact results from Earth’s orbiting the sun—along the path called the ecliptic. Price surmised that the front of the mechanism probably had a pointer showing where along the ecliptic the sun would be at the desired date.

In the surviving fragments, Price identified the remains of a dozen gears that had been part of the mechanism’s innards. He also estimated their tooth counts—which is all one can do given that nearly all the gears are damaged and incomplete. Later, in a landmark 1974 study, Price described 27 gears in the main fragment and provided improved tooth counts based on the first x-rays of the mechanism, by Greek radiologist Charalambos Karakalos.

Tooth counts indicate what the mechanism calculated. For example, turning the crank to give a full turn to a primary 64-tooth gear represented the passage of a year, as shown by a pointer on the calendar dial. That primary gear was also paired to two 38-tooth secondary gears, each of which consequently turned by 64/38 times for every year. Similarly, the motion relayed from gear to gear throughout the mechanism; at each step, the ratio of the numbers of gear teeth represents a different fraction. The motion eventually transmitted to the pointers, which thus turned at rates corresponding to different astronomical cycles. Price discovered that the ratios of one of these gear trains embodied an ancient Babylonian cycle of the moon.

Price, like Rehm before him, suggested that the mechanism also contained epicyclic gearing—gears spinning on bearings that are themselves attached to other gears, like the cups on a Mad Hatter teacup ride. Epicyclic gears extend the range of formulas gears can calculate beyond multiplications of fractions to additions and subtractions. No other example of epicyclic gearing is known to have existed in Western technology for another 1,500 years.

Several other researchers studied the mechanism, most notably Michael Wright, a curator at the Science Museum in London, in collaboration with computer scientist Allan Bromley of the University of Sydney. They took the first three-dimensional x-rays of the mechanism and showed that Price’s model of the mechanism had to be wrong. Bromley died in 2002, but Wright persisted and made significant advances. For example, he found evidence that the back dials, which at first look like concentric rings, are in fact spirals and discovered an epicyclic mechanism at the front that calculated the phase of the moon.

Wright also adopted one of Price’s insights, namely that the dial on the upper back might be a lunar calendar, based on the 19-year, 235-lunar-month cycle called the Metonic cycle. This calendar is named after fifth-century B.C. astronomer Meton of Athens—although it had been discovered earlier by the Babylonians—and is still used today to determine the Jewish festival of Rosh Hashanah and the Christian festival of Easter. Later, we would discover that the pointer was extensible, so that a pin on its end could follow a groove around each successive turn of the spiral.

BladeRunner in Athens
As our group began its efforts, we were hampered by a frustrating lack of data. We had no access to the previous x-ray studies, and we did not even have a good set of still photographs. Two images in a science magazine—x-rays of a goldfish and an enhanced photograph of a Babylonian clay tablet—suggested to me new ways to get better data.

We asked Hewlett-Packard in California to perform state-of-the-art photographic imaging and X-Tek Systems in the U.K. to do three-dimensional x-ray imaging. After four years of careful diplomacy, John Seiradakis of the Aristotle University of Thessaloniki and Xenophon Moussas of the University of Athens obtained the required permissions, and we arranged for the imaging teams to bring their tools to Athens, a necessary step because the Antikythera mechanism is too fragile to travel.

Meanwhile we had a totally unexpected call from Mary Zafeiropoulou at the museum. She had been to the basement storage and found boxes of bits labeled “Antikythera.” Might we be interested? Of course we were interested. We now had a total of 82 fragments, up from about 20.

The HP team, led by Tom Malzbender, assembled a mysterious-looking dome about five feet across and covered in electronic flashbulbs that provided lighting from a range of different angles. The team exploited a technique from the computer gaming industry, called polynomial texture mapping, to enhance surface details. Inscriptions Price had found difficult to read were now clearly legible, and fine details could be enhanced on the computer screen by controlling the reflectance of the surface and the angle of the lighting. The inscriptions are essentially an instruction manual written on the outer plates.

A month later local police had to clear the streets in central Athens so that a truck carrying the BladeRunner, X-Tek’s eight-ton x-ray machine, could gain access to the museum. The BladeRunner performs computed tomography similar to a hospital’s CT scan, but with finer detail. X-Tek’s Roger Hadland and his group had specially modified it with enough x-ray power to penetrate the fragments of the Antikythera mechanism. The resulting 3-D reconstruction was wonderful: whereas Price could see only a puzzle of overlapping gears, we could now isolate layers inside the fragment and see all the fine details of the gear teeth.

Unexpectedly, the x-rays revealed more than 2,000 new text characters that had been hidden deep inside the fragments. (We have now identified and interpreted a total of 3,000 characters out of perhaps 15,000 that existed originally.) In Athens, Moussas and Yanis Bitsakis, also at the University of Athens, and Agamemnon Tselikas of the Center for History and Palaeography began to discover inscriptions that had been invisible to human eyes for more than 2,000 years. One translated as “... spiral subdivisions 235...,” confirming that the upper back dial was a spiral describing the Metonic calendar.

Babylon System
Back at home in London, I began to examine the CT scans as well. Certain fragments were clearly all part of a spiral dial in the lower back. An estimate of the total number of divisions in the dial’s four-turn spiral suggested 220 to 225.

The prime number 223 was the obvious contender. The ancient Babylonians had discovered that if a lunar eclipse is observed—something that can happen only during a full moon—usually a similar lunar eclipse will take place 223 full moons later. Similarly, if the Babylonians saw a solar eclipse—which can take place only during a new moon—they could predict that 223 new moons later there would be a similar one (although they could not always see it: solar eclipses are visible only from specific locations, and ancient astronomers could not predict them reliably). Eclipses repeat this way because every 223 lunar months the sun, Earth and the moon return to approximately the same alignment with respect to one another, a periodicity known as the Saros cycle.

Between the scale divisions were blocks of symbols, nearly all containing Σ (sigma) or H (eta), or both. I soon realized that Σ stands for Σεληνη (selene), Greek for “moon,” indicating a lunar eclipse; H stands for Ηλιοσ (helios), Greek for “sun,” indicating a solar eclipse. The Babylonians also knew that within the 223-month period, eclipses can take place only in particular months, arranged in a predictable pattern and separated by gaps of five or six months; the distribution of symbols around the dial exactly matched that pattern.

I now needed to follow the trail of clues into the heart of the mechanism to discover where this new insight would lead. The first step was to find a gear with 223 teeth to drive this new Saros dial. Karakalos had estimated that a large gear visible at the back of the main fragment had 222 teeth. But Wright had revised this estimate to 223, and Edmunds confirmed this. With plausible tooth counts for other gears and with the addition of a small, hypothetical gear, this 223-tooth gear could perform the required calculation.

But a huge problem still remained unsolved and proved to be the hardest part of the gearing to crack. In addition to calculating the Saros cycle, the large 223-tooth gear also carried the epicyclic system noticed by Price: a sandwich of two small gears attached to the larger gear in teacup-ride fashion. Each epicyclic gear also connected to another small gear. Confusingly, all four small gears appeared to have the same tooth count—50—which seemed nonsensical because the output would then be the same as the input.

After months of frustration, I remembered that Wright had observed that one of the two epicyclic gears has a pin on its face that engages with a slot on the other. His key idea was that the two gears turned on slightly different axes, separated by about a millimeter. As a consequence, the angle turned by one gear alternated between being slightly wider and being slightly narrower than the angle turned by the other gear. Thus, if one gear turned at a constant rate, the other gear’s rate kept varying between slightly faster and slightly slower.

Ask for the Moon
Although Wright rejected his own observation, I realized that the varying rotation rate is precisely what is needed to calculate the moon’s motion according to the most advanced astronomical theory of the second century B.C., the one often attributed to Hipparchos of Rhodes. Before Kepler (A.D. 1605), no one understood that orbits are elliptical and that the moon accelerates toward the perigee—its closest point to Earth—and slows down toward the apogee, the opposite point. But the ancients did know that the moon’s motion against the zodiac appears to periodically slow down and speed up. In Hipparchos’s model, the moon moved at a constant rate around a circle whose center itself moved around a circle at a constant rate—a fairly good approximation of the moon’s apparent motion. These circles on circles, themselves called epicycles, dominated astronomical thinking for the next 1,800 years.

There was one further complication: the apogee and perigee are not fixed, because the ellipse of the moon’s orbit rotates by a full turn about every nine years. The time it takes for the body to get back to the perigee is thus a bit longer than the time it takes it to come back to the same point in the zodiac. The difference was just 0.112579655 turns a year. With the input gear having 27 teeth, the rotation of the large gear was slightly too big; with 26 teeth, it was slightly too small. The right result seemed to be about halfway in between. So I tried the impossible idea that the input gear had 26 1/2 teeth. I pressed the key on my calculator, and it gave 0.112579655— exactly the right answer. It could not be a coincidence to nine places of decimals! But gears cannot have fractional numbers of teeth.

Then I realized that 26 1/2 × 2 = 53. In fact, Wright had estimated a crucial gear to have 53 teeth, and I now saw that that count made everything work out. The designer had mounted the pin and slot epicyclically to subtly slow down the period of its variation while keeping the basic rotation the same, a conception of pure genius. Thanks to Edmunds, we also realized that the epicyclic gearing system, which is in the back of the mechanism, moved a shaft that turned inside another, hollow shaft through the rest of the mechanism and to the front, so that the lunar motion could be represented on the zodiac dial and on the lunar phase display. All gear counts were now explained, with the exception of one small gear that remains a mystery to this day.

Further research has caused us to make some modifications to our model. One was about a small subsidiary dial that is positioned in the back, inside the Metonic dial, and is divided into four quadrants. The first clue came when I read the word “NEMEA” under one of the quadrants. Alexander Jones, a New York University historian, explained that it refers to the Nemean Games, one of the major athletic events in ancient Greece. Eventually we found, engraved round the four sectors of the dial, most of “ISTHMIA,” for games at Corinth, “PYTHIA,” for games at Delphi, “NAA,” for minor games at Dodona, and “OLYMPIA,” for the most important games of the Greek world, the Olympics. All games took place every two or four years. Previously we had considered the mechanism to be purely an instrument of mathematical astronomy, but the Olympiad dial—as we named it—gave it an entirely unexpected social function.

Twenty-nine of the 30 surviving gears calculate cycles of the sun and the moon. But our studies of the inscriptions at the front of the mechanism have also yielded a trove of information on the risings and settings of significant stars and of the planets. Moreover, on the “primary” gearwheel at the front of the mechanism remnants of bearings stand witness to a lost epicyclic system that could well have modeled the back-and-forth motions of the planets along the ecliptic (as well as the anomalies in the sun’s own motion). All these clues strongly support the inclusion of the sun and of at least some of the five planets known in ancient times—Mercury, Venus, Mars, Jupiter and Saturn.

Wright built a model of the mechanism with epicyclic systems for all five planets. But his ingenious layout does not agree with all the evidence. With its 40 extra gears, it may also be too complex to match the brilliant simplicity of the rest of the mechanism. The ultimate answer may still lie 50 meters down on the ocean floor.

The question of where the mechanism came from and who created it is still open. Most of the cargo in the wrecked ship came from the eastern Greek world, from places such as Pergamon, Kos and Rhodes. It was a natural guess that Hipparchos or another Rhodian astronomer built the mechanism. But text hidden between the 235 monthly scale divisions of the Metonic calendar contradicts this view. Some of the month names were used only in specific locations in the ancient Greek world and suggest a Corinthian origin. If the mechanism was from Corinth itself, it was almost certainly made before Corinth was completely devastated by the Romans in 146 B.C. Perhaps more likely is that it was made to be used in one of the Corinthian colonies in northwestern Greece or Sicily.

Sicily suggests a remarkable possibility. The island’s city of Syracuse was home to Archimedes, the greatest scientist of antiquity. In the first century B.C. Roman statesman Cicero tells how in 212 Archimedes was killed at the siege of Syracuse and how the victorious Roman general, Marcellus, took away with him only one piece of plunder—an astronomical instrument made by Archimedes. Was that the Antikythera mechanism? We believe not, because it appears to have been made many decades after Archimedes died. But it could have been constructed in a tradition of instrument making that originated with the eureka man himself.

Many questions about the Antikythera mechanism remain unanswered—perhaps the greatest being why this powerful technology seems to have been so little exploited in its own era and in succeeding centuries.

In Scientific American, Price wrote:

It is a bit frightening to know that just before the fall of their great civilization the ancient Greeks had come so close to our age, not only in their thought, but also in their scientific technology.

Our discoveries have shown that the Antikythera mechanism was even closer to our world than Price had conceived.

Note: This article was originally printed with the title,"Decoding an Ancient Computer."