# Fly me to the Moon

*Fly me to the moon**Let me play among the stars**Let me see what spring is like**–Bart Howard, 1954 (jazz standard sung by Frank Sinatra, among others)*

**On a Jupiter and Mars.**We have a new topic this month, and it has absolutely nothing–well, almost nothing–to do with the topics we've been discussing lately–software development, testing, and the like. On the other hand, it certainly has to do with embedded systems and software. Systems that tend to be rather remote. Like 240,000 miles remote.

If you happened to see my column in Embedded.com **(“Calculating trajectories for Apollo program”)**, where I reminisced about my days with NASA, you know that I was deeply involved in the planning stages of Project Apollo. During that time, I spent a lot of energy learning neat concepts, making interesting relationships, and picking up skills that make designing lunar missions easier. One of the big disappointments of my young life is that, after Apollo was cancelled in 1972, we've never had the curiosity or motivation to go back. So all those neat concepts have pretty much lain fallow.

What you probably don't know is that now, after more than 40 years, I'm finally getting another chance to go back to the Moon, at least vicariously and in spirit. Since last summer, I've been working with one of the groups competing for the Google Lunar X-Prize competition. (**www.googlelunarxprize.org/)**. The competition invites non-governmental teams to soft-land a robotic rover on the Moon, and have it carry out certain tasks, which include relaying back real-time TV images, roving over at least 500 meters, and surviving the cold, two-week long lunar night. The first two teams to do this will share a $30 million prize.

I'm working with a group called Part Time Scientists **(www.part-time-scientists.com/)**, which is based in Germany. This effort has been a very exciting one for me. After all these years, I had pretty much abandoned all hope of working on things Lunar again, but here I am doing just that. What I'm doing for the X-Prize effort is pretty much the same as I did before: designing the trajectories. Managing Editor Susan Rambo and I thought you might be interested in how it's done.

1959 all over again

Years before **President Kennedy** made his famous** “Before the decade is out”** speech, lots of people were saying, “Let's go to the Moon.” The obvious response, to anyone with the slightest spirit of adventure, was to say, “Yeah, let's!” closely followed by, “How do we do that?” In 1959, we didn't have a very good answer.

Most of the work I did for NASA was to design the trajectory that gets people to the Moon and back. At the time, space was truly a new frontier for us. We knew virtually nothing about the physics of the problem, we didn't have very good reference books to study, and we didn't have time to go get degrees in astrodynamics. One of the NASA engineers, who had studies astrodynamics, created a handwritten “Cliff Notes” sort of document, and we all studied Xeroxed copies of it.

My first attempts to get a satisfactory lunar trajectory were pretty pitiful, but I learned. Early on, I decided that I wanted more than just to get a final, satisfactory trajectory. I wanted to understand, at a very deep level, the principles involved.

In the beginning I had more questions than answers, but from time to time I'd get little glimmers of insight. Whenever I thought about the problem a little more, I'd have one more little glimmer. Now, after more than 40 years of thinking, I believe I finally understand what's going on to that deeper level. I'd like to share that understanding with you.

It's not easy

The movie *Apollo 13* makes the task of getting to the Moon seem pretty easy. You point the nose of the spacecraft at the Moon, light off that big J-2 rocket motor on the Saturn upper stage, and off you go. Simple.

The reality is not simple at all. You can't just aim at the Moon, because there's the small matter of an Earth and a Moon and their gravitational fields. Before you lit the candle, you were orbiting close to the Earth. Afterwards, the spacecraft still wants to orbit the Earth, so your path is going to be curved in weird and wonderful ways.

Take a look at **Figure 1** , which depicts the now-familiar “Figure 8” circumlunar trajectory. This trajectory, which goes out, swings around the Moon, and returns to the Earth, attracted a lot of my attention in those early days,^{1} where the spacecraft goes out to the Moon, swings around it, and returns to the Earth.

**FIGURE 1–THE CIRCUMLUNAR FIGURE-8 TRAJECTORY**

**Click on image to enlarge.**

The circumlunar trajectory became central to the Apollo missions, whether they landed on the Moon or not, and for good reason: We didn't just want to send people to the Moon. We wanted to get them back. The nice part about the circumlunar trajectory is that you're coasting in free-fall all the way. Once the booster has done its job, executing what was called the Trans-Lunar Injection (TLI) burn, the spacecraft can coast all the way to the Moon and back. If you've executed that burn perfectly, the spacecraft will coast out to the Moon, swing around it, and return to a safe reentry at Earth, with no more rocket burns required. For obvious reasons, we called it the Free Return trajectory.

Of course, nobody had any illusions that the Free Return was going to be truly free, because the TLI is not going to be perfect Every time you fire a rocket motor, you risk getting it slightly wrong. and any error at the beginning of the trajectory translates into a bigger error at the end. What's more, the circumlunar trajectory is particularly sensitive to errors in its initial conditions. Even so, using the Free Return trajectory, the astronauts had at least a fighting chance of getting home alive, if something bad happened. And if they could still apply some midcourse corrections, as Jim Lovell and his crew did during Apollo 13, the fighting chance gets a whole lot more optimistic.

Ironically, the first Apollo mission not to start with a Free Return trajectory was Apollo 13. After the explosion in the liquid oxygen tank, they had to apply a burn, using the LEM motor, to get back onto a Free Return path.

Since the days of Sputnik, we've become used to seeing orbits depicted as circular or elliptical. Not surprisingly, the physics problem of the motion of two gravitating bodies–Sun and planet, Earth and Moon, or Earth and spacecraft–is called the two-body problem. Way back in 1609, Johannes Kepler conjectured, based on Tycho Brahe's meticulous observations of Mars, that the planets moved in elliptical orbits about the Sun.

Sixty years later, Isaac Newton solved the two-body problem, and confirmed Kepler's laws. He did it, by the way, by first inventing his three laws of motion, his law of gravity, and calculus. He was 22. So, Isaac, how was your summer vacation?

Newton found that the general solution of the two-body problem is not always an ellipse. It can be any *conic section* , which includes the circle, ellipse, parabola, and hyperbola.

The three-body problem

One look at **Figure 1** , though, tells you that this ain't your grandfathers ellipse. It's a strange and complicated trajectory, bending left, then right, then around the moon, in a sinuous path perhaps more familiar to a figure skater than an astronaut.

The trajectory is not an ellipse because this isn't a two-body problem, it's a three-body problem. As soon as the early astronomers–which included such mathematical giants as Gauss, Euler, Lagrange, and Poincaré–learned about Newton's triumph with the two-body problem, they probably said the 17th century equivalent of, “Hot doggies! Let's do it again, with one more body!” The idea wasn't based on just idle curiosity. Real three-body encounters exist in nature. A near miss of a planet by a comet is one; the motion of the Moon, as perturbed by the Sun, is another.

So they set out to solve the three-body problem. They didn't have much luck; the problem has proven to be intractable. Despite their best efforts and a lot of concentrated brainpower, they never found that elusive closed-form solution, and such a solution has since been shown to be impossible.

This is not to say that they didn't get any useful results. To help them study the problem, they used a time-tested technique: If you can't solve a given problem, try solving a different one. In this case, they reasoned that they might have better results if they made a few simplifying assumptions. The result is called the Restricted Three-Body Problem (RTBP). based on the assumptions that:

1. The mass of one body is negligible. Thus the remaining two bodies form a two-body system, orbiting their common center of mass.

2. The orbit is a circleThe motion of the massless body is restricted to the plane of the other bodies' orbits.

The early astronomers were seeking a closed-form, analytical solution like Newton had found for the two-body problem. They didn't get that, but they were able to get a lot of insight into the motion. In particular, Lagrange was able to identify and study the five Lagrange equilibrium points, L1 through L5. Points L1, L2, and L3 lie along the Earth-Moon axis, and are unstable. Points L4 and L5 lie in the orbit of the Moon, spaced 60 degrees ahead and behind it. These points are stable; any masses that find their way there tend to stay there, drifting along in lazy orbits around their Lagrange points.

Still, we now know that the analytical solution to the RTBP doesn't exist. If you can't solve a dynamics problem analytically, you have only one recourse: Solve it numerically, by integrating the equations of motion numerically.

Those early guys could and did do just that, but it's not an exercise for the faint-hearted. If you try it, make sure you have several new pencils with large erasers. For all practical purposes, the RTBP had to wait for digital computers with enough horsepower to crank out the numerical solution. By a happy coincidence, such computers became available in the late 50's, about the same time I did. Indeed, it was a computer simulation of the RTBP that I used in most of my studies.

Looking at **Figure 1** again, one other aspect stands out: The trajectory is symmetric. The reason doesn't leap out at you, at least it didn't to me. It took me a few years to figure out why, but once you see it, it's obvious. You're not likely to see this explanation in any textbook, so remember, you heard it here first.

Here's the deal: Although the Moon influences the motion of the spacecraft throughout the flight, it has very little effect while the spacecraft is near the Earth. Near the Earth, we can expect the trajectory to look a lot like a two-body solution; that is, segments of an ellipse. But it's a long, skinny ellipse with a perigee near the Earth, and an apogee way out past the Moon.

Now, the parameters of most two-body orbits depend on two constants of the motion; the energy and the angular momentum. However, the eccentricity of our elliptical segments is high–about 0.97 or 0.98. That's very near the 1.0 of a parabola. And it turns out that the parameters of the parabola depend on only one of the constants: The angular momentum. Show me a parabolic orbit whose perigee has some specific value, and I'll tell you what its angular momentum has to be.

But that's exactly what the situation has to be for the circumlunar mission. On the outbound leg, we get the best efficiency when the TLI burn starts as close to the Earth as possible, just outside the sensible atmosphere. On the inbound leg, we need a trajectory that just grazes that same atmosphere. For all practical purposes, the two perigees are the same, so the angular momenta must also be the same.

This requirement places a special constraint on the encounter with the Moon. Whatever the Moon does to our trajectory, it cannot be allowed to change the angular momentum. As we'll see in a moment, this requires that the trajectory near the Moon must be symmetric as well.

All of this places an interesting constraint on the point of closest approach (I call it perilune, but strictly speaking, it should be periselene). You can put the perilune anywhere you like, as long as it's lunar latitude 0, longitude 180. I'll bet no one ever told you *that* before.

There's one more important point about Figure 1: It's a * LIE * . Or, at the very least, highly misleading. The trajectory of Figure 1 is supposed to represent an inertial coordinate system, “non-rotating relative to the background of fixed stars.”

But look again at the figure. What's that little gray circle you see, out there to the right? You know, the one labeled “Moon”? It's just sitting there, isn't it, like the bullseye at a shooting gallery. But the real Moon *isn't* just sitting there; it's moving in an orbit of its own. It's moving pretty fast, in fact, at over 1,000 m/s (2,200 mi/hr). At this point in its trajectory, our spacecraft is close to apogee so it's moving much more slowly around 200 m/s.

When we think casually about a lunar encounter, most of us have a mental image of a sort of rendezvous, much as we might use to rendezvous with a geosynchronous satellite. But this is the wrong model. In reality, it's more like this: We put ourselves in the path of the Moon, wave our arms, go “Boogah Boogah,” and dare it to run over us. Which it will absolutely do, unless we dodge it deftly. It's more like a matador's pass than a rendezvous.

Now perhaps you see the real issue with Figure 1; an issue that makes the problem seem easier to solve than it really is. If the Moon were, in fact, fixed in space, the problem would be static. The only variable would be the initial position and velocity of the trajectory. You can think of the problem as be analogous to a golf putt on a particularly diabolical, warped and convoluted green. The target–the hole–is fixed, so to hit it, you only need to adjust your stroke.

But since the Moon is moving, you not only have to hit the ball just right, you have to do it at the right time.

Instead of that golf putt, the situation is more analogous to a figure-skating exhibition, where two performers glide smoothly out to the corners of the rink, far away from each other. Then at some prearranged time, they curve back to center ice, execute a waltz-like twirl, and part again.

The timing of the circumlunar trajectory is now the issue. If you get it right, you get that lovely little twirl that you see in **Figure 1** . Get it wrong, and the Moon is simply not there when you arrive. To get it right, you have to lead the Moon, much as a hunter shooting at a clay pigeon. The typical flight time for an Apollo mission was about 3 1/2 days. The Moon moves about 13 degrees per day, so the rendezvous point should be about 45 degrees ahead of the Moon's current position. The geometry shown in *Apollo 13* simply can't work.

Pin down that Moon

I must tell you in all candor, when I first started trying to generate a good lunar trajectory, I struggled for quite awhile before any of my attempts got within 20,000 miles of the target. It's a tricky thing. Worse yet, when you see that you've missed the desired trajectory, it's not immediately obvious what you should change to get closer.

Now we understand that the little gray circle of **Figure 1** isn't really there; it only comes whizzing by just in time to dance with us. And for that reason, timing becomes an issue. So we ask ourselves: Is there something we can do to fix that?

Turns out, there is. What if we define a new coordinate system, a rotating one, that rotates at the same rate as the Moon moves around the Earth. If we do it right, we can arrange for the x-axis to always lie along the Earth-Moon axis. It's the same situation that we appeared to have in Figure 1, but didn't.

This approach is, in fact, the same one adopted by Euler, Lagrange, and company. In their formulation of the RTBP, they wrote the equations of motion in the rotating system, which meant that they had to add centrifugal and Coriolis terms to the equations. We don't really have to do that. It's easier to compute things in an inertial system; we only need to use the rotating one during input and output transformations.

In 1960, I was using a simulation of the RTBP to study the circumlunar trajectory. I found it pretty easy to get trajectories of the proper shape, and that allowed me to do a full parametric study over a wide range of parameters. I'm afraid I took this pleasant result very much for granted; it was my first lunar simulation, after all, and I didn't pick the coordinate system.

I was more than a little surprised when we moved on to a three-dimensional, N-body simulation and found the task to be much harder. At the time, I figured that the difference was the three-dimensional nature of the simulation, and the more realistic orbits for the Moon and planets. Only now, at the end, do I realize that it's not the higher fidelity of the model, but the rotating coordinate system, that makes the difference.

It's the difference between the golf putt and the figure-skating maneuver. The rotating coordinate system takes timing out of the equation, and that's what makes the problem easier.

One last point: Using the rotating coordinate system is easiest in the RTBP, where the rotation rate is constant, as is the radial distance between Earth and Moon. In such a case, it's easy to see that the Moon must stay pinned at that one spot on the x-axis.

But switching to a more realistic model doesn't have to negate the value of the coordinate system. Even with the most accurate model for the motion of the Earth-Moon system (including solar perturbations), you can always define a coordinate system such that the x-axis is along the Earth-Moon axis, the Moon's velocity lies in the x-y plane, and the z-axis is normal to its angular momentum vector. If you also normalize the scale to the instantaneous Earth-Moon distance, there's the Moon again, pinned to a fixed point.

In **Figure 2** , I've redrawn the circumlunar trajectory in the rotating coordinate system:

**FIGURE 2–CIRCUMLUNAR TRAJECTORY IN ROTATING COORDINATES**

**Click on image to enlarge.**

As you can see, transforming the coordinate system warps the trajectory quite a lot. Now the segments of the trajectory that are close to the Earth don't look much at all like parts of an ellipse. But they really are. That is to say, if you transform an elliptical orbit into the same coordinate system, it'll look very much like Figure 2. Of course, since the original trajectory was symmetric, the new one will be, also.

The interesting part of Figure 2 is out there at the right, where the spacecraft swings past a now-stationary Moon. In a sense, the tight loop of Figure 1 has been unwrapped. There's no longer a twirly waltz step, just a simple flyby. As we've eliminated the apparent motion of the Moon, we've taken the timing issue back out of the situation. Our figure-skating analogy now reverts back to that of a particularly challenging golf putt.

Now, I said earlier that the Moon has virtually no effect on the motion, when the spacecraft is close to the Earth. The converse is also true; Near the Moon, the trajectory looks very much like a conic section. Not an ellipse, though. The relative velocity (which, you'll recall, is mostly due to the Moon's orbital motion) is too high for that. Instead, it's a hyperbola. If you want to go into orbit around the Moon, you need a decelerating burn, called Lunar Orbit Injection (TLI).

If you remember your geometry, you know that a hyperbola is asymptotic to two straight lines called, amazingly enough, the asymptotes. In **Figure 2** , the spacecraft approaches the Moon on one such asymptote, moving down and to the right, at almost constant speed. As it nears the Moon, it accelerates and starts to curve around the Moon. It arrives at perilune, the point of closest approach, with its maximum velocity. Then it departs again, this time moving down and to the left.

The hyperbolic character of the circumlunar trajectory near the Moon is apparent in Figure 2.

This encounter between the Moon and the spacecraft is a special case of a swingby, or gravity assist, maneuver. JPL uses such maneuvers all the time, to boost a probe's velocity to reach the outer planets. But because our trajectory is symmetric, there is no boost; the velocity vector is bent from one asymptote to the other, but the magnitude isn't changed.

In a way, the Moon only serves to reflect the velocity back towards the Earth. As we approach the Moon, the velocity is downward in the figure, and out away from the Earth. After the encounter with the Moon, the downward velocity hasn't changed, but the horizontal velocity has been reflected back towards the Earth. If we think about the trajectory purely in terms of the velocity vector, we've only rotated it through an angle of about 90 degrees.

I'm sure it will come as no shock to you that this angle is tightly connected to the miss distance. If we miss the Moon by a lot, the angle must be much shallower. If we miss it entirely, there is of course no deflection at all. To skim close to the surface, the trajectory must be bent as you see it in Figure 2.

There's a very important implication of this relationship. If we truly want a low-altitude approach, which we did for Apollo, we have no choice but to let the trajectory bend through a fairly large angle. To do this, we must arrive at the Moon with a relatively high radial velocity; say about 800 m/s. This is important because it requires a higher velocity, and therefore more fuel, after the TLI burn.

Sp what's new?

I always find it interesting when a given constraint on a design drives other constraints which drive other constraints which drive …

In the case of Apollo, we wanted the astronauts to have the best chance of coming back to Earth alive. To insure that, we wanted a free return, circumlunar trajectory. We wanted to do our TLI close to the Earth, and just skim the atmosphere on the way back. This forced the trajectory to be the symmetric figure-8 we've come to know and love.

We wanted to pass close to the Moon. To do that, the Moon-relative hyperbola needed a fairly large deflection angle, which meant that the radial velocity had to be high, which meant that the velocity after TLI had to be larger than we might have liked.

See how it's all connected?

When I first began generating trajectories for the Google Lunar X-Prize, I naturally started out thinking along the lines of my earlier designs. But I soon realized that the trajectories should be different, because the requirements are different (sound familiar?). The Apollo design was driven by the desire for a free return, in case the astronauts had to abort the LOI maneuver. In the X-Prize mission, that maneuver is essential. If the LOI fails, it's Game Over; the mission has failed. What happens to the spacecraft after that, we don't care.

Finally, because our trajectory doesn't need a return leg, the whole discussion about the shape of the Moon-relative hyperbola is moot. We no longer need a radial velocity when we get to the Moon. Instead of approaching the Moon from about a 45 degree angle, as in the trajectory of **Figure 2** , we can approach it directly down the y-axis, with no x-velocity at all. And the lower velocity at the Moon means a lower-energy TLI burn, less fuel, and more payload.

**Figure 3** shows the new shape.

**FIGURE 3–THE LOW-ENERGY TRAJECTORY**

**Click on image to enlarge.**

Because this trajectory has lower energy, it has a longer trip time: More like five days than three?.

In the figure, I've shown the trajectory impacting the Moon. Remember the plan: Dangle the spacecraft out there in front of the Moon, and dare it to run you down. It's the Boogah-Boogah strategy. From the perspective of someone standing on the Moon at longitude 90 W, the spacecraft would be descending vertically.

This is not an unreasonable approach, as long as you don't mind the 90 W part. A vertical descent is what we used for Surveyor and other unmanned missions. It simplifies the automated landing quite a bit, and you can change that landing longitude by making only the slightest tweaks to the outbound trajectory.

The vertical descent is simple to automate, but it's not very efficient. When you're landing vertically, your rocket motor expends a lot of fuel fighting gravity. With a grazing, nearly horizontal approach, centrifugal force gives you some help countering gravity. In orbit, after all, it counters gravity completely.

So instead of landing vertically, it's better to go into orbit first. You can do this by tweaking the TLI a tiny bit, so the spacecraft passes behind the Moon. Better yet, pass in front of the Moon, and save more fuel yet. Or even give the trajectory a small inclination (less than 1 degree), pass above or below the Moon, and go into a polar orbit. Going into orbit lets us go to pretty much any landing site we choose. The price we pay is a more difficult job for the software that controls the automated landing.

KISS *Simplify as much as possible, but no more. * –Einstein*Keep It Simple, Sidney. * –Crenshaw (among others)

I presume you've figured out, by now, that the geometry of a lunar mission is not a simple one. What I must tell you now is that it's even more complicated than you thought. How complicated is it, you ask? Like **Figure 4** complicated.

**FIGURE 4–ORBIT PLANES**

**Click on image to enlarge.**

This figure shows three of the important planes involved: the Equator, the Ecliptic, and the plane of the Moon's orbit. There's a fourth plane that I didn't even have the courage to try to draw: The plane of the trajectory, which can be (and usually is) different from all three that I've shown.

But the situation is even worse than you think. All the planes are moving. Our equatorial plane precesses around the Ecliptic with a period of 26,000 years. Well, Ok, I guess it's not that fast. But the Moon's orbit also precesses about the Ecliptic, with a period of only 18.7 years. Since Project Apollo, it's been around twice, changing the inclination of the Moon's orbit to the Equator by 5 degrees. A solution that was valid three years ago is worthless today.

Finally, the plane of the Moon's orbit isn't a plane at all. The solar perturbation includes out-of-plane components, with periods of one month and one year. Neither is the orbit plane a plane.

Why am I telling you all this? Because I want you to understand that the problem is complicated. What's more, the more accurate you want the result to be, the more complicated it gets. “Exact” models for the motion of the Earth and Moon can run as large as the 1400-term series of the Hill-Brown lunar theory. Then there's the 10,000 or so terms of the Earth's gravitational field, a similar number for the Moon, and terms describing the nutation and wander of the Earth's poles. Want light pressure and solar wind? Better put those in, also.

Computer simulations exist that model all of these effects, and will give you precision solutions, accurate to a gnat's hair. NASA has one. Analytical Graphics, Inc. (AGI) has a very excellent (and expensive) one called Satellite Tool Kit (STK). AGI has graciously agreed to supply a license to each of the Google Lunar X-Prize teams.

The problem with these high-precision models is that, as noted above, all the “constants” are really changing with time. Change the launch date, and you've changed them all. This may be fine–even essential–for the nominal trajectory that you need when the spacecraft and its booster are sitting on the launch pad. But it's a terrible choice for parametric studies during the design phase. That's why I tend to invoke the KISS philosophy, and look for useful approximations.

Do they exist? You bet. Over the years, we've developed quite a number of approximate methods, rules of thumb, back-of-the-envelope calculations, etc., that give us an understanding of the situation without having to run high-precision simulations.

I'll go even further than that. Novices use high-precision solutions, because they don't have a feel for which effects matter, and which ones don't. Experts (like Einstein) can use back-of-the-envelope calculations because they know what are the dominant effects.

Want an example? Consider that return-from-the-Moon thing. You want to reenter the Earth's atmosphere with a grazing entry? From my discussion on angular momentum, we know that