The Enūma Anu Enlil, a series of 70 clay tablets, was found in the ruins of King Ashurbanipal’s library in Nineveh (on the eastern bank of the River Tigris, opposite modern-day Mosul in Iraq). The name means “in the days of Anu and Enlil”; Anu was the sky god, Enlil the wind god. The tablets, which date as far back as 1950 BC, list 7,000 omens from Babylonian astrology: “If the moon can be seen on the first day, the land will be happy.” But tablet 63 is different: it gives the times when Venus first became visible, or disappeared, over a 21-year period. This Venus tablet of Ammisaduqa is the earliest known record of planetary observations.

The Babylonians were expert astronomers who produced star catalogues and tables of eclipses, planetary motion and changes in the length of day. They were also capable mathematicians, with a number system much like ours, but using base 60 rather than ten. They could solve quadratic equations and calculate the diagonal of a square with precision, and they applied their mathematical skills to the heavens. In those days, mathematics and astronomy were part and parcel of astrology and religion, and the whole package was intimately bound up with agriculture through the progression of the seasons.

The torch of astronomy passed by way of ancient Greece to India. In sixth-century India, mathematics was a sub-branch of astronomy, and astronomy still played second fiddle to reading omens in the stars. The Arab world made further advances in our understanding of the cosmos, and kept the ancient knowledge alive until Europe once more turned its attentions to the science of the heavens.

In 1601 Johannes Kepler became imperial mathematician to the Holy Roman emperor Rudolf II. Casting the emperor’s horoscope paid the bills, and it also left time for serious mathematics and astronomy. Kepler had inherited accurate observations of Mars from his former master Tycho Brahe, and from these he extracted three mathematical patterns, his laws of planetary motion. By then, thanks to Nicolaus Copernicus, it was known—though still controversial, to say the least—that the planets revolve round the sun, not the Earth. Their orbits were thought to be combinations of circles, but Kepler’s calculations showed that planets move in ellipses. His other two laws govern how quickly the planet moves and how long it takes to go round the sun.

In his epic Mathematical Principles of Natural Philosophy of 1687, Isaac Newton built on Kepler’s laws and deduced his law of universal gravitation: every body in the universe attracts every other body with a force that obeys a specific mathematical rule. These forces determine how moons, planets and stars move. Newton’s book paved the way to a rational scientific understanding of nature based on precise mathematical laws, and opened up the metaphor of the clockwork universe.

One of the great tests of Newtonian gravitation was Edmond Halley’s prediction about a comet. In ancient times comets, bright bodies with long curved tails that seemed to appear from nowhere, were seen as omens of disaster. From old records, Halley realised one particular comet was a repeat visitor, with an elliptical orbit that took it near the Earth every 76 years. He predicted its next return in 1758. By then Halley was dead, but his prediction proved correct.

Even today, Newton’s law remains vital to astronomy and space exploration; Einstein’s later refinements are seldom needed. A topical example concerns another comet, rejoicing in the name 67P/Churyumov-Gerasimenko, which takes about six-and-a-half years to orbit the sun. In 2004 the European Space Agency (ESA) launched the Rosetta probe to visit the comet and find out what it looked like and what it was made of. Famously, it resembled a rubber duck: two round lumps joined by a narrow neck. On November 12, 2014 a small capsule, Philae, landed on the head of the duck, which was 480 million kilometers from Earth and travelling at over 50,000 kilometers per hour. Unfortunately Philae bounced and ended up on its side, but even so it had sent back vital and unprecedented data.

It’s worth visiting the ESA’s “Where is Rosetta?” web page to see an animation of the astonishing route the probe took. It wasn’t direct. The probe began by moving towards the sun, even though the comet was far outside the orbit of Mars, and moving away. Rosetta’s orbit swung past the sun, returned close to the Earth, and was flung outwards to an encounter with Mars. It then swung back to meet the Earth for a second time, then back beyond Mars’s orbit. By now the comet was on the far side of the sun and closer to it than Rosetta was. A third encounter with Earth flung the probe outwards again, chasing the comet as it now sped away from the sun. Finally, Rosetta made its rendezvous with destiny.

Why such a complicated route? The ESA didn’t just point its rocket at the comet and blast off. That would have required far too much fuel, and by the time it got there the comet would have been somewhere else. Instead, Rosetta performed a carefully choreographed cosmic dance, tugged by the combined gravitational forces of the sun, the Earth, Mars and other relevant bodies. Its route was designed for fuel efficiency; the price paid was that it took Rosetta ten years to get to its destination. Each close fly-by with Earth and Mars gave the probe a free boost as it borrowed energy from the planet. An occasional small burst from four thrusters kept the craft on track. And every kilometer of the trip was governed by Newton’s law of gravity.

Complex trajectories such as this one have now become standard in many unmanned space missions. They originated in mathematical studies of chaotic dynamics in the motion of three gravitating bodies, and go back to pioneering work by Edward Belbruno at the Jet Propulsion Laboratory in California in 1990. He realised that these techniques could put a Japanese probe, Hiten, into lunar orbit after a failure of its parent craft, even though there was hardly any fuel available.

Mathematics has always enjoyed a close relationship with astronomy; not just in the technology of space missions but in understanding planets, stars, galaxies—even the entire universe. How, for example, did the solar system form? We can’t go back to take a look, so we have to do some celestial archaeology, inferring what happened from the evidence that remains. Our main tool is mathematical modelling, which lets us test whether hypothetical scenarios make sense.

Observations and theoretical astrophysics tell us that the sun came into being about 4.8 billion years ago, and the planets of the solar system formed at much the same time. Everything condensed out of the solar nebula, a huge cloud of gas—mainly hydrogen and helium, the two commonest elements in the universe. The cloud was about 65 light years across, 15 times the distance to the nearest star today. One fragment, about four light years across, gave rise to the solar system; other fragments became other stars—many of which, we now know, have their own planets. As our fragment collapsed under its own gravitational field, most of the gas collected at the centre, where enormous pressures ignited nuclear reactions to create the sun. Much of the remaining gas clumped into smaller, but still gigantic, bodies: the planets. The rest either got swept away or remains as various items of clutter—asteroids; centaurs (small bodies with characteristics of both comets and asteroids); Kuiper Belt objects, in the debris field beyond Neptune; comets in the Oort Cloud, which is a quarter of the way to the next-nearest star.

This scenario, minus the nuclear physics, was first proposed in the eighteenth-century, but fell out of favour in the twentieth because it seemed not to account for the sun’s low angular momentum (a measure of how much rotation it has, taking into account its mass and speed) compared to that of the planets. But in the 1980s astronomers observed gas clouds round young stars, and mathematical modelling of the collapsing clouds showed plausible, and very dramatic, mechanisms that fitted the observations.

According to these ideas, the early solar system was very different from the sedate one we see today. The planets formed not as single clumps, but by a chaotic process of accretion. For the first 100,000 years, slowly growing “planetesimals” swept up gas and dust, and created circular rings in the nebula by clearing out gaps between them. Each gap was littered with millions of these tiny bodies. At that point the planetesimals ran out of new matter to sweep up, but there were so many of them that they kept bumping into each other. Some broke up, but others merged; the mergers won and planets built up, piece by tiny piece.

Late in 2014 dramatic evidence for this process was found: an image of a proto-planetary disc around the young star HL Tau, 450 light years away in the Taurus constellation. This image showed concentric bright rings of gas, with dark rings in between. The dark rings are almost cer­tainly caused by nascent planets sweeping up dust and gas.

Until very recently, astronomers thought that once the solar system came into being it was very stable: the planets trundled ponderously along preordained orbits and nothing much changed. No longer: it is now thought that the larger worlds—the gas giants Jupiter and Saturn and the ice giants Uranus and Neptune—first appeared outside the “frost line” where water freezes, but subsequently reorganised each other in a lengthy gravitational tug of war.

In the early solar system, the giants were closer together and millions of planetesimals roamed the outer regions. Today the order of the giants, outwards from the sun, is Jupiter, Saturn, Uranus, Neptune. But in one likely scenario it was originally Jupiter, Neptune, Uranus, Saturn. When the solar system was about 600 million years old, this cosy arrangement came to an end. All of the planets’ orbital periods were slowly changing, and Jupiter and Saturn wandered into a 2:1 resonance—Saturn’s “year” became twice that of Jupiter. Repeated alignments of these two worlds then pushed Neptune and Uranus outwards, with Neptune overtaking Uranus. This disturbed the planetesimals, making them fall towards the sun. Chaos erupted in the solar system as planetesimals played celestial pinball among the planets. The giant planets moved out, and the planetesimals moved in. Eventually the planetesimals took on Jupiter, whose huge mass was decisive. Some were flung out of the solar system altogether, while the rest went into long, thin orbits stretching out to vast distances. After that, it mostly settled down.

These theories are not idle speculation. They are supported by huge computer calculations of the solar system’s dynamics over billions of years, carried out in particular by the research groups of Jack Wisdom of the Massachusetts Institute of Technology and Jacques Laskar of CNRS, the French national centre for scientific research. Some cunning mathematics is required even to set up these simulations: the deep structure of the laws of motion must not be disturbed by the unavoidable numerical approximations that occur. This structure includes the laws of conservation of energy and angular momentum, whose totals cannot change. Amazingly, the planetary migrations not only keep these quantities in balance, but happen because they balance.

Another playground for mathematicians and astronomers investigating Newtonian gravitation is the rings of Saturn. The most distant of the planets known to the ancients, Saturn is about 1.3 billion kilometres from Earth. In 1610, when Galileo looked at Saturn through his telescope, he sent his fellows a Latin anagram: smaismrmilmepoetaleumibunenugttauiras. This was a standard way to preannounce a discovery without giving it away. Kepler deciphered it as reading—in translation—“Be greeted, double knob, offspring of Mars,” and thought Galileo was claiming Mars had two moons (as Kepler had predicted, and rightly so). But Galileo later explained that his anagram actually meant: “I have observed the most distant of planets to have a triple form.” That is, Saturn consists of three bodies.

So much for anagrams.

Galileo’s image of the planet was blurred. Using a better telescope, the Dutch mathematician Christiaan Huygens realised that the middle body was the planet and the others were parts of a gigantic system of rings. Mathematics proves—contrary to an early suggestion by the French scholar Pierre-Simon Laplace—that the rings cannot be solid. In fact, they are made up of ice particles, ranging in size from fine dust to lumps ten metres across. There are several current theories for the rings’ formation: the break-up of a moon, or perhaps leftovers from Saturn’s own primordial nebula. Mathematics is being used to try to find out which explanation, if any, is correct.

Mathematical studies also explain many puzzling features of Saturn’s rings. For one thing, the rings are dense in some regions, but so thin in others that at first sight there seem to be gaps. Some of these gaps come from resonances between the rings and the periods of Saturn’s 62 moons, which can systematically disturb gas in orbits related to that of the moon itself. Other gaps are organised by “shepherd moons” that hustle out any sheepish moonlet that strays into the gap. When the spacecraft Voyager 1 flew past in 1980, some rings appeared to be braided. We now know that they are kinked and lumpy, another subtle consequence of Newtonian gravity in this complex system.

Mathematics has illuminated many other cosmic puzzles: the formation of Earth’s moon, the future of the solar system, the formation and dynamics of galaxies—even the origin of the universe itself in the Big Bang. In ancient India, mathematics was a sub-branch of astronomy. Today, if anything, it is the other way round. Mathematicians are making discoveries and inventing methods; astronomers and cosmologists are making ever greater use of the latest mathematical tools and concepts to advance this utterly fascinating subject. Mathematical thinking teaches us more about humanity’s place in the universe. And it helps us to seek out new places.

This article was originally published at www.newstatesman.com.