It’s July 20, 1969. Neil Armstrong and Buzz Aldrin are about to land on the moon. They will be the first humans to set foot on Earth’s only natural satellite. Suddenly, the onboard computer flashes: “Alarm 1202.” Over the next 278 seconds, four more alarms trigger: “Alarm 1202,” “Alarm 1201,” “Alarm 1202,” “Alarm 1202.”
The system is overloaded. Aldrin and Armstrong are instructed by the NASA crew on the ground to proceed with the landing. But the NASA team members know that their colleagues have done a good job and programmed in a safety net. And thanks to the error messages, they know how to address the problem.
Computer scientist Margaret Hamilton was one of the people responsible for the features that ultimately made the moon landing possible, despite those error messages. And her then four-year-old daughter may have helped spur her thoughts.
On supporting science journalism
If you’re enjoying this article, consider supporting our award-winning journalism by subscribing. By purchasing a subscription you are helping to ensure the future of impactful stories about the discoveries and ideas shaping our world today.
How to Describe the World with a Computer
The computer onboard Apollo 11’s lunar module had about a mere 74 kilobytes of storage in the form of read-only memory (ROM). To put that in perspective, today’s smartphones easily have 128 gigabytes of ROM storage, which is about two million times more—all so we can kill time on Instagram and TikTok.
Programming was also completely different in the 1960s. Common programming languages such as Python or Rust, which contain roughly understandable plaintext commands for arithmetic operations, didn’t exist back then. Computers of that era looked completely different from the compact devices we use today, too.
When Hamilton began working with computers, she had to make entirely different considerations than today’s programmers: Which register stores which number? How must the contents of the registers interact to add and multiply two numbers? Which memory space do I allocate for these registers, and which do I block off?
The lunar module’s onboard computer had to determine the speed, altitude and rotation of the module—which are all variable quantities. In principle, the onboard computer solved differential equations, which depend not only on variables such as x and y but also on their derivatives.
Such equations describe everything that changes. But there is no universally applicable method for solving these differential equations. Many don’t even have an exact solution. Therefore, we have to rely on approximation methods.
To understand how these methods work, consider the following example problem: suppose a spaceship is moving with constant acceleration, a, and you want to find out the distance it travels in a certain time, t. You know both the initial position, x0, and the initial velocity of the spaceship, v0. To solve the problem exactly, you have to solve the following differential equations:
You can find the solution directly for these problems. But if that’s not possible, you could work out the solution via step-by-step increments in position and velocity:
xn + 1 = xn + vnΔt,
vn + 1 = vn + aΔt
To evaluate these equations for a small time step (such as Δt = 1 second), first calculate x1 = x0 + v0 × 1s and v1 = v0 + a × 1s. You can then substitute the respective results of x1 and v1back into the equations to obtain x2 and v2 and obtain subsequent results in the same way. You can then work through the process like this until you find the distance the spaceship has traveled after a certain time, t.
Such recursive systems of equations are still part of fundamental research today, albeit in a significantly more complex form. Regardless of whether one studies cosmology, particle physics, medicine or chemical processes, one is always dealing with variable systems and thus with differential equations. And to solve these, you generally employ a set of recursive equations that a computer can evaluate.
In Hamilton’s time, computing power was severely limited. Programmers had to find ways to code equations as efficiently as possible. And as mentioned, programming languages as we know them today did not yet exist. Hamilton and her contemporaries had to devise the relevant mathematical equations, then translate them into clear instructions for the computer that would utilize registries that they also had to create and finally code these instructions into a sequence of 0’s and 1’s.
Even after writing the code, the task was not yet complete; back then computers didn’t have input fields like to turn text into executable code like those of today. To run a program, the code had to first be punched into paper tape; a hole represented a 1, and no hole represented a 0, corresponding to the two units of binary code, which most computers work with.
The Weather Is Chaotic
Margaret Hamilton got her start with computers at the Massachusetts Institute of Technology in the research group of Edward Lorenz, a well-known meteorologist. He had derived 12 interdependent equations for various weather conditions such as temperature, air pressure and humidity. Given precise initial conditions, these equations were supposed to predict future weather patterns.
Initially, the research group had no computer available. If its members wanted to create a weather forecast for the next three days, they needed five days to calculate the complex differential equations. That was hardly practical. The team around Lorenz was therefore delighted when he installed the Royal McBee LGP-30 “desk computer” in his office. It weighed around 360 kilograms, looked a bit like a freezer and was as loud as a helicopter. Lorenz bought the LGP-30 in 1959, the same year Hamilton joined his lab.
While Lorenz focused on the physical and mathematical aspects of the problem, Hamilton and her colleagues were busy programming the desk computer. She punched the corresponding codes into paper tape using a kind of typewriter. Because errors constantly occurred and changes were frequently made to the code, Hamilton sometimes edited the printout by hand by sealing excess holes with clear tape or piercing missing ones in the paper tape with a sharp pencil.
With this desk computer, Lorenz’s group made its greatest discovery: The researchers noticed that the weather forecast changed completely depending on how they rounded the numbers. Even if the input data differed only in the last few decimal places, that change could have an enormous effect on the result. This is what is now known in mathematics as a chaotic system.
When Lorenz, as a sole author, published his groundbreaking paper on what would become the foundation of chaos theory, Hamilton was just about to do work for NASA.
Crashing the Flight Simulator
While working for M.I.T.’s Instrumentation Laboratory, which was contracted by NASA to develop software for the Apollo program, Hamilton often took her daughter Lauren to work with her in the evenings and on weekends, sometimes allowing the child to play with the lab’s flight simulator. One day, the then four-year-old pressed all sorts of buttons on the device, causing the onboard computer to crash: she had tried to run the prelaunch program while the simulation was in flight, meaning two programs were trying to occupy the same section of computer memory.
This gave Hamilton pause for thought: she urgently wanted to create a way to prevent problems like the one Lauren had triggered from occurring during a real mission. Initially, NASA wasn’t enthusiastic, but the agency eventually agreed. Hamilton created a way to communicate with astronauts when emergencies or errors in the programming were occurring. Together with her colleagues, she also helped developed a kind of safety net designed to address such system crashes by restarting programs in a prioritized order after a shutdown or crash. So she helped program “emergency fixes,” contingency procedures that were implemented when something unexpected happened during a mission.
This work kept the first moon landing from being aborted, even though the onboard computer was overloaded. Buzz Aldrin had flipped a switch in the lunar module that activated the “rendezvous radar,” which was used to ensure the module could later dock with the command module. When Aldrin activated that radar, however, the lunar module was on its final approach and had to process a large amount of data. The additional rendezvous signals overwhelmed the system and caused the recurring error messages, alerting the astronauts and NASA to the specific problem.
But then Hamilton and her team’s safety net kicked in, leading the program to prioritize running processes that were crucial for a safe landing. Because he knew what the error codes meant from working with Hamilton, the late NASA engineer Jack Garman had the confidence to give the landing the go-ahead. And so, in 1969, humanity was able to set foot on another celestial body for the first time.
Hamilton hadn’t received much recognition for her important contributions until 2016, when U.S. president Barack Obama presented the then 80-year-old with the Presidential Medal of Freedom.
This article originally appeared in Spektrum der Wissenschaft and was reproduced with permission. It was translated from the original German version with the assistance of artificial intelligence and reviewed by our editors.
