An educational reconstruction · Apollo-era circumlunar navigation
In 1960, a new piece of mathematics was asked to do something no equation had done before: steer human beings to the Moon and bring them home. This is that story — and a MATLAB reconstruction of it, flown again from the original NASA documents.
I was working through a Kalman-filtering course when it struck me that the first time anyone trusted this filter with a real job, the job was getting people to the Moon and back.
The linear Kalman filter is clean on paper — a predict step, a correct step, an optimal gain, derived in a lecture or two. I wanted to feel it carry real weight. And the more I read, the more I kept returning to the same fact: its very first serious engineering use was onboard navigation for a circumlunar flight, worked out at NASA Ames beginning in 1959, published in 1962, and later flown, in descendant form, on Apollo.
So I set the coursework aside and rebuilt that first job from the primary sources. When I could not find one of the original reports online, I wrote to NASA’s STI Information Desk — they wrote back within days, pointing me to the exact page in Astrionics R&D Report No. 3. Not a themed animation over stock footage — the actual thing. A genuine free-return trajectory, targeted in the real gravity field. The same star-and-horizon sightings a crew would take by hand. The filter written the way Smith, Schmidt and McGee first wrote it. I wanted to stand where those engineers stood: a brand-new algorithm, a computer that filled a room, sightings entered a few minutes apart by a human with a sextant, and lives riding on whether the numbers converged.
What I did not expect is how little the hard parts have moved. The questions they answered in 1961 — where do you linearize, how do you accept a measurement whenever it happens to arrive, how do you keep a covariance honest on a short-word machine — are the same questions I answer today, only with better tools. This page is the history I found, told the way I wish it had been told to me.
“Small errors at injection produce such large errors later — near the Moon — that guidance is generally necessary.”
NASA TR R‑135 (1962), stating the whole problem in one sentence. My reconstruction turns that sentence into a number: an uncorrected trajectory misses Earth re‑entry by 31,000 km. The filter brings it back to about one.
Picture the task as it looked before anyone knew it could be done. A spacecraft leaves Earth orbit on a translunar coast. For three days it falls freely toward a Moon that is itself moving 3,600 km every hour. Miss the aim point by a fraction of a degree at departure and you arrive thousands of kilometres off — or not at all.
There was no GPS. There were no ground radars far enough out to help near the Moon. The plan was that the crew themselves would navigate: line up a known star with the lit edge of the Earth or Moon in a sextant, press a button, and hand the onboard computer a single angle. From a thin, irregular trickle of such angles, the computer had to know the ship's position and velocity well enough to plan a course correction — and it had to do it in a memory smaller than a modern text message.
The mathematics to fuse those measurements optimally did not exist in usable form. Then, in 1960, it arrived.
A six‑year relay from a fresh idea to flight hardware. Each link is a person and a decision — and each is something I had to re‑implement to make the reconstruction work.
Kálmán publishes a recursive solution to the linear filtering problem: fold each new measurement into a running best estimate, weighted by an optimal gain. Compact, sequential, and — unlike the Wiener filter before it — built for the dynamical state estimation the space age needed. That autumn he visits Ames; the sequential form “hit a responsive chord.”
An eight‑person branch had chosen circumlunar navigation as its problem and had been building trajectory‑linearization tools with no software to speak of. Schmidt saw that those tools could manufacture exactly the linear system Kálmán's theory required: linearize the nonlinear motion about a reference path, and filter the deviations. Two inventions followed — splitting the algorithm into a time update and a measurement update so a human's irregular sightings could be processed whenever they arrived, and, after a mis‑configured run, re‑linearizing about the estimate instead of the reference. The second became the extended Kalman filter.
The Ames work is published as Technical Report R‑135. It lays out everything: the equations of motion for an oblate Earth plus Moon and Sun, the linear perturbation dynamics, the optical star‑and‑horizon angles and their partial derivatives, and the filter's predict/correct equations. My MATLAB follows its appendices almost line for line.
Directed by Schmidt toward Kálmán's work, Battin carried the filter into the Apollo guidance design at MIT. His lab would write the software that actually navigated the missions, turning a feasibility study on an IBM 704 into a system three crews would trust.
On the flight computer's short word length, the covariance recursion loses its positive‑definiteness and the filter can quietly diverge. Potter reformulated it to propagate a square root of the covariance instead — numerically safe on the hardware that flew.
The filter's descendants ran on the Apollo Guidance Computer: 15‑bit words, memory woven by hand into core rope, a multiply that took 46.8 microseconds. Documented in MIT R‑700, it is the machine against which I measure how much easier my version had it.
Recursive linear filtering — the predict/correct estimator the whole field is named for.
Married Kálmán's theory to Ames' linearization; conceived re‑linearizing about the estimate.
Co‑developed the scheme and later wrote the definitive account of how the discovery happened.
Lead author of TR R‑135, the document this reconstruction is built on.
Carried the filter into the Apollo guidance system that actually flew.
Square‑root formulation — the filter made numerically safe on flight‑computer word lengths.
Led the Apollo Guidance Computer — the one cubic foot of hardware that ran it all.
The modern Kalman‑filter course whose notation and predict/correct framing I learned this in.
The measurement realism comes from two more sources. The Bellcomm error analysis (D. A. Corey, T. S. Englar, B. G. Niedfeldt, R. V. Sperry, 1966) sets the sextant noise at 10 arc‑seconds. The Apollo 13 Mission Report, Supplement 1 (TRW / NASA, 1970) supplies the 8‑km Earth‑horizon bias and the venting‑class acceleration the filter has to estimate — both taken from what actually happened in flight.
The clearest way to honour the original work is to measure it. Same problem, three machines, sixty‑five years apart.
| IBM 704NASA Ames, ~1961 | Apollo Guidance ComputerBlock II, flown | This reconstructiona laptop, 2026 | |
|---|---|---|---|
| Logic | vacuum tubes, a roomful | ~5,600 integrated‑circuit gates | billions of transistors |
| Word length | 36‑bit | 15‑bit + parity | 64‑bit float |
| Memory | core, tens of thousands of words | 36,864 fixed (rope) + 2,048 erasable | gigabytes |
| Multiply | ~240 µs | 46.8 µs | < 1 nanosecond |
| Mass / power | ~10 tons, tens of kW | 70 lb, 55 W, 1 cu ft | ~1.5 kg |
| The filter run | ~15 min for 2.5 h of flight | real time, onboard | whole 5.7‑day mission in ~2 min |
| Transition matrix Φ | integrate 18 ODEs, punch to cards | stored, precomputed | expm(A·Δt), one line |
This is the detail that changed how I saw the whole thing. There was no sensor stream. A crew member floated to the optics, brought a catalogued star down to the lit horizon of the Earth or the Moon, and marked — one angle at a time, a fresh mark every several minutes, whenever the geometry and the workload allowed.
Kálmán's original filter assumed measurements arrive on a fixed clock. Human sightings do not. That mismatch is precisely why Ames split the algorithm into a time update that coasts the estimate forward and a measurement update that folds in a mark whenever it comes. My reconstruction inherits that structure directly: it processes one scalar angle at a time, exactly as R‑135 describes, so a lone hand‑taken sighting is a trivial 1×1 update — “the ultimate in calculation simplicity,” as the report puts it.
Reading the 1985 account, what stays with you is how close it ran to failure. The transition‑matrix software fell six months behind. The first full simulation gave “disappointing results” — traced to a single mis‑called subroutine. “On the second run,” they wrote, “everything worked fine.”
An accidental error in input conditions caused the true trajectory to remain in Earth orbit, but the estimate had the conditions for a lunar transfer… the estimator soon converged close to the true state. This modification has come to be known as the extended Kalman filter. McGee & Schmidt, NASA TM‑86847, 1985
A mistake, in other words, discovered one of the most‑used algorithms in modern engineering. I reproduce that exact split in the reconstruction: the nominal‑linearized filter and the estimate‑linearized one, run on identical data, so you can watch the second save the mission where the first gives up.
Two MATLAB files, no toolboxes. A real free‑return trajectory, an independent “truth” the filter is never told, and 1,986 sextant‑grade angle sightings over the whole journey.
Both filters are identical but for where they linearize. The linearized Kalman filter works about the precomputed nominal path — the textbook form, and flawless for fifty hours. Then a lunar flyby amplifies a 344‑km deviation into thousands, the linearization is evaluated in the wrong place, and the most informative measurements of the mission arrive as poison. It diverges to 22,000 km.
The estimate‑linearized variant — the one Ames discovered by accident — re‑evaluates about its own best guess at every step. On the same sightings, it arrives at re‑entry with about 1.4 km of error, having also quietly identified an unmodelled venting acceleration and the 8‑km horizon bias pulled from Apollo 13's own flight data.
The reconstruction is about the navigation. This is what the navigation was for — the arc from the pad to the sea, in NASA's own public‑domain photographs.
The engineering decisions, algorithm and system design, validation strategy, analysis and stated limitations are my own. The historical narrative and every physical constant are drawn from the primary sources listed here.
Sreeram Anil
Nürnberg, Germany · Code under Apache 2.0
Primary sources
NASA TR R‑135 — Smith, Schmidt & McGee, Application of Statistical Filter Theory to the Optimal Estimation of Position and Velocity on Board a Circumlunar Vehicle, 1962.
NASA TM‑86847 — McGee & Schmidt, Discovery of the Kalman Filter as a Practical Tool for Aerospace and Industry, 1985.
Bellcomm TR‑66‑310‑4 — Corey, Englar, Niedfeldt & Sperry, Summary of Apollo Guidance and Navigation Error Analysis, 1966.
MSC‑02680 Suppl. 1 — Apollo 13 Mission Report, Supplement 1: GN&C Systems Performance Analysis, TRW / NASA, 1970.
MIT R‑700, Vol. III — Hall, MIT's Role in Project Apollo: Computer Subsystem, 1972.
Image credits
Mission photographs — the crew, the Saturn V launch, the lunar surface, Earthrise (AS08‑14‑2383), splashdown, and the DSKY cabin interior — are NASA, public domain. Portraits (Kálmán, Schmidt, Battin, Hall, Plett) are reproduced from public sources for educational use; rights remain with their respective holders. The simulation animation and every plotted figure are the author's own.