First Filter to Fly

An educational reconstruction · Apollo-era circumlunar navigation

The First Filter
to Fly.

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.

Animated reconstruction: the Apollo free-return trajectory looping around the Moon, with the navigation filter's estimate and its 3-sigma uncertainty ellipse tracking the spacecraft.
The reconstruction, running. A ballistic free-return trajectory in the full Earth–Moon–Sun gravity field; the moving Moon; and, lower right, the filter's own estimate with its growing 3σ uncertainty ellipse. Rendered in MATLAB from this project — the same animation, on the correct physics. [ your simulation ]
§ 01Why I built this

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.

§ 02The wager of 1960

A sextant, a room-sized computer, and no room to be wrong.

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.

The figure‑8 free‑return: out past the Moon, around its far side, and back to Earth on a single ballistic arc — no engine required to come home. The safety principle that returned Apollo 13.
§ 03The chain, 1960–1972

How a journal paper became a way to the Moon.

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.

1960RIAS / Ames

A new approach to filtering.

Rudolf E. Kálmán

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.”

In the build the predict / correct recursion at the core of both filter variants.
1959–61NASA Ames

Linearize the impossible.

Stanley F. Schmidt · Leonard A. McGee · the Dynamics Analysis Branch

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.

In the build the deviation dynamics, the measurement set, and the estimate‑linearized (EKF) variant.
1962NASA TR R-135

The report I rebuilt from.

Gerald L. Smith · Stanley F. Schmidt · Leonard A. McGee

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.

In the build equations of motion, gravity‑gradient dynamics, and the angle‑measurement Jacobians.
1961–66MIT Instrumentation Lab

From Ames to the spacecraft.

Richard H. Battin

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.

In the build the reason this lineage — not some other estimator — is the one worth reconstructing.
1963–66MIT

Making it survive a 15‑bit word.

James E. Potter

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.

In the build the stability problem I sidestep with Joseph‑form updates and 64‑bit arithmetic.
1966–72Draper Laboratory

One cubic foot of guidance.

Eldon C. Hall & the Apollo Guidance Computer team

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.

In the build the 1961↔2026 comparison below — their constraints, my conveniences.
§ 04The people

Who did what — and which part of the project it became.

Rudolf E. Kálmán at a blackboard
Rudolf E. Kálmán
The algorithm · 1960

Recursive linear filtering — the predict/correct estimator the whole field is named for.

Gave the projectthe estimator at the centre of both filters.
Portrait of Stanley F. Schmidt
Stanley F. Schmidt
NASA Ames · 1959–61

Married Kálmán's theory to Ames' linearization; conceived re‑linearizing about the estimate.

Gave the projectthe nonlinear adaptation and the EKF variant.
LMportrait
Leonard A. McGee
NASA Ames · 1962 / 1985

Co‑developed the scheme and later wrote the definitive account of how the discovery happened.

Gave the projectthe Earth‑and‑Moon angle measurement set, and the history.
GSportrait
Gerald L. Smith
NASA Ames · 1962

Lead author of TR R‑135, the document this reconstruction is built on.

Gave the projectthe equations of motion and the measurement Jacobians, coded verbatim.
Portrait of Richard H. Battin
Richard H. Battin
MIT Instrumentation Lab

Carried the filter into the Apollo guidance system that actually flew.

Gave the projectthe reason this lineage is the one to rebuild.
JPportrait
James E. Potter
MIT

Square‑root formulation — the filter made numerically safe on flight‑computer word lengths.

Gave the projectthe stability issue I handle with the Joseph form.
Portrait of Eldon C. Hall
Eldon C. Hall
MIT / Draper · AGC

Led the Apollo Guidance Computer — the one cubic foot of hardware that ran it all.

Gave the projectthe 1961↔2026 machine comparison.
Portrait of Gregory L. Plett
Gregory L. Plett
UC Colorado Springs

The modern Kalman‑filter course whose notation and predict/correct framing I learned this in.

Gave the projectthe language I wrote the filter 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.

§ 051961 ↔ 2026

Everything they did the hard way, I got for free.

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
Logicvacuum tubes, a roomful~5,600 integrated‑circuit gatesbillions of transistors
Word length36‑bit15‑bit + parity64‑bit float
Memorycore, tens of thousands of words36,864 fixed (rope) + 2,048 erasablegigabytes
Multiply~240 µs46.8 µs< 1 nanosecond
Mass / power~10 tons, tens of kW70 lb, 55 W, 1 cu ft~1.5 kg
The filter run~15 min for 2.5 h of flightreal time, onboardwhole 5.7‑day mission in ~2 min
Transition matrix Φintegrate 18 ODEs, punch to cardsstored, precomputedexpm(A·Δt), one line
Interior of an Apollo command module: the guidance panel glowing amber, an astronaut's hand at the DSKY keypad entering data.
The interface. Navigation went in through the DSKY — the display-and-keyboard of the guidance computer. A crew member keyed each sighting and command by hand, digit by digit, into a machine with less memory than this sentence. [ Apollo command module, NASA ]

Sightings, taken by hand, minutes apart

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.

The difficulties, in their words

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.

§ 06The reconstruction

Flown again, on the correct physics.

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.

5.72 days
injection to re‑entry
1,986
scalar angle sightings
10
filter states, augmented
31,000→1.4
km miss, open loop → filtered
Two-panel plot: left, the free-return trajectory in the Earth-centred inertial frame with the Moon's orbit; right, the same trajectory in the Moon-corotating frame showing the figure-8, with nominal and true paths overlaid.
Fig. 1 — the trajectory. Left, the Earth‑centred inertial view with the Moon moving along its orbit. Right, the Moon‑corotating frame, where the free‑return path resolves into the figure‑8. Targeted to a 111‑km perilune and a 40‑km return perigee.
Semi-log plot of position error over mission time: the open-loop deviation grows past 30,000 km, while the estimate-linearized filter stays near 1 km and the nominal-linearized filter diverges after the lunar flyby.
Fig. 2 — the result. Open‑loop deviation (black) amplifies to 31,000 km by re‑entry. The estimate‑linearized filter (red) holds near a kilometre; the nominal‑linearized one (blue) tracks perfectly until the lunar flyby, then diverges — the whole point, in one chart.

Two filters, one difference

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.

Six small plots of the estimate-linearized filter's position and velocity errors, each staying within its shaded 3-sigma bound across the mission.
Fig. 3 — consistency. The estimate‑linearized filter's errors against their own ±3σ bounds. Inside the envelope from injection to entry: the filter's estimate of its own uncertainty is honest.
§ 08Colophon & sources

Read the whole thing.

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.