The N-Body Problem

Author

Devendra Ghate

Published

November 3, 2026

1 Where we are going

Every space mission starts with a prediction. To send a probe to Mars we must know where Mars will be seven months after launch; to fly past Jupiter we must know where Jupiter will be six years from now, to within a few hundred kilometres. So the first problem of spaceflight mechanics is an old one: explain, and then predict, the positions of the bodies of the solar system at any time.

This note attacks that problem in the most direct way possible. We replace every body by a point mass, let every point attract every other by Newton’s law of gravitation, and write down the equations of motion. The result is the celebrated \(N\)-body problem. We will find that it is easy to write down and impossible to solve in general, and the reasons why it cannot be solved will tell us which simplifications to make next.

Two kinds of boxes run through the note. A blue Try it box asks you to do something small: compute a number, write out a sum, run a script. Do it before reading on; the point that follows is made by your own answer. A green Check yourself box asks a short question that tests whether the previous paragraphs went in. Each has a hidden answer, which you should open only after you have an answer of your own.

When you finish, you should be able to answer the following without hand-waving.

  1. Why may the Sun and the planets be replaced by points, and when does that argument fail?
  2. Which quantities stay constant when \(N\) bodies attract each other, and why?
  3. Why can the two-body problem be solved with pen and paper while the three-body problem cannot?
  4. What does it mean for an orbit to be chaotic, and why does chaos not stop us from flying missions?
  5. Which simplification turns the \(N\)-body problem into something we can solve, and how good is it?

Symbols and constants shared by all the notes are collected on the notation page; the study plan gives the order in which to read the notes.

2 From observations to a law

2.1 Kepler’s three laws

The story starts with data. Tycho Brahe measured the positions of the planets, with the naked eye, to one or two minutes of arc, night after night for some twenty years. Johannes Kepler inherited these tables and spent years fitting curves to them. The result was three laws.

  1. First law. The orbit of a planet is an ellipse with the Sun at one of the two foci.
  2. Second law. The line joining the planet to the Sun sweeps out equal areas in equal times.
  3. Third law. The square of the period \(T\) of a planet is proportional to the cube of the semi-major axis \(a\) of its orbit: \(T^2\propto a^3\), with the same constant for every planet.

History: Tycho and Kepler. Tycho Brahe (1546–1601) built the observatory of Uraniborg on the island of Hven and later moved to Prague. Kepler (1571–1630) joined him there in 1600. When Tycho died in 1601 Kepler kept the observations, over the objections of Tycho’s heirs.

Kepler published the first two laws in Astronomia Nova (1609), after a long struggle with the orbit of Mars, whose eccentricity (\(0.093\)) is large enough to rule out a circle at Tycho’s accuracy. The third law appeared ten years later, in Harmonices Mundi (1619).

Before we use the third law, let us test it on real numbers.

The table gives the semi-major axis \(a\) (in astronomical units, \(1~\text{AU}\approx1.496\times10^{8}\) km, the mean Earth–Sun distance) and the period \(T\) (in years) of six planets. Compute \(T^2/a^3\) for each.

Mercury Venus Earth Mars Jupiter Saturn
\(a\) (AU) \(0.387\) \(0.723\) \(1.000\) \(1.524\) \(5.203\) \(9.537\)
\(T\) (yr) \(0.241\) \(0.615\) \(1.000\) \(1.881\) \(11.86\) \(29.46\)
What you should find \(T^2/a^3 = 1.002,\ 1.001,\ 1.000,\ 1.000,\ 0.999,\ 1.001\). Over a factor of \(25\) in distance and \(120\) in period, the ratio is the same to \(0.2\%\). In these units the constant is \(1\) simply because the year and the AU are defined by the Earth’s orbit.

Kepler’s laws are a superb description, but they are kinematic: they say what the orbits look like, not why. They give no rule for computing the orbit of a new body from its position and velocity, and they say nothing about bodies that do not orbit the Sun.

The four large moons of Jupiter also obey \(T^2\propto a^3\). For Io, \(a=421\,700\) km and \(T=1.769\) days. Compute \(T^2/a^3\) in yr\(^2\)/AU\(^3\). Is it \(1\)? What would Kepler have needed in order to explain the number you get?

Answer Converting, \(a=2.819\times10^{-3}\) AU and \(T=4.844\times10^{-3}\) yr, so \(T^2/a^3\approx1047\). Callisto gives the same \(1047\). So the law holds about Jupiter, but with a constant \(1047\) times larger than about the Sun. Kepler had no way to explain this. It needs a force law in which the constant depends on the attracting body; Newton’s law gives \(T^2/a^3 = 4\pi^2/(G M)\) (to be proved in the two-body note), so \(1047\) is the ratio of the mass of the Sun to the mass of Jupiter. With Kepler’s law and a stopwatch, you have weighed Jupiter.

2.2 Newton’s explanation

Newton supplied the missing law. He showed that if every body attracts every other with a force proportional to the product of their masses and inversely proportional to the square of their distance, then Kepler’s three laws follow, with the constant in the third law fixed by the mass of the attracting body. The rest of this note works out what Newton’s law implies when there are \(N\) bodies instead of two.

History: the Principia. Newton’s Philosophiæ Naturalis Principia Mathematica (1687) derives Kepler’s laws from the inverse-square law in Book I, and in Book III applies the law to the planets, the Moon, the comets and the tides. Kepler’s laws were derived from data; Newton’s were derived from a physical principle, and they predicted the data.

3 The model: bodies as points

The solar system contains the Sun, eight planets, their moons, and millions of asteroids and comets, \(n\) bodies in all. Each is an extended, rotating body whose density varies inside it. We cannot write equations for that. We need an idealisation, and the simplest one is to treat each body as a point mass: all of its mass concentrated at one point.

Why should that be acceptable? The natural guess is that a body looks like a point when it is small compared with the distances involved. Let us test that guess.

Compute the ratio (radius of the body)/(distance to the body it influences) for the three pairs below. Take \(R_\odot=6.96\times10^{5}\) km (Sun), \(R_\oplus=6378\) km (Earth), \(1\) AU for the Earth–Sun distance, \(384\,400\) km for the Earth–Moon distance, and a satellite at \(420\) km altitude (the International Space Station).

  1. the Sun, seen from the Earth; (b) the Earth, seen from the Moon; (c) the Earth, seen from the space station.
What you should find
  1. \(R_\odot/1~\text{AU}=0.0047\); (b) \(R_\oplus/384\,400~\text{km}=0.017\); (c) \(R_\oplus/(6378+420)~\text{km}=0.94\).
The first two are small, so the point-mass picture looks safe. The third is not small at all: from a low orbit the Earth is a disc \(140^\circ\) across, filling about a third of the whole sky. By the “small body” argument, we could not treat the Earth as a point for satellites.

The way out of case (c) is a theorem rather than an approximation. A spherically symmetric body attracts every point outside it exactly as if all its mass were at its centre (Newton’s shell theorem). Size does not matter, only symmetry. The planets are very nearly spherically symmetric, so the point-mass model is good both for the planets about the Sun and for satellites about the Earth. What the Earth’s flattening does to a satellite is the subject of a later note (gravity of the Earth).

History: the shell theorem. Newton proved it in Book I, Section XII of the Principia. It is the reason the pull of the whole Earth on the Moon can be computed as if the Earth were a point.

4 Newton’s law of gravitation

4.1 The force between two points

Fix an inertial frame (we return to what that means in Section 5) and let \(\mathbf R_i\) be the position of body \(i\), of mass \(m_i\), in that frame. For two bodies \(i\) and \(j\) define

\[ \mathbf r_{ij}=\mathbf R_j-\mathbf R_i,\qquad r_{ij}=|\mathbf r_{ij}|,\qquad \hat{\mathbf r}_{ij}=\frac{\mathbf r_{ij}}{r_{ij}} . \]

So \(\mathbf r_{ij}\) points from \(m_i\) to \(m_j\), \(r_{ij}\) is the distance between them and \(\hat{\mathbf r}_{ij}\) is the unit vector from \(m_i\) towards \(m_j\). The gravitational force on \(m_i\) due to \(m_j\) is

\[ \mathbf F_{ij}=\frac{G\,m_i m_j}{r_{ij}^{2}}\,\hat{\mathbf r}_{ij} =\frac{G\,m_i m_j}{r_{ij}^{3}}\,\mathbf r_{ij}, \tag{1}\]

where \(G=6.674\times10^{-11}~\text{m}^3\,\text{kg}^{-1}\,\text{s}^{-2}\) is the gravitational constant. The sign is positive because gravity is attractive and \(\hat{\mathbf r}_{ij}\) already points from \(m_i\) towards \(m_j\). Many books carry a minus sign here: they measure the unit vector the other way, from the attracting body to the attracted one. The physics is the same.

Figure 1: The force \(\mathbf F_{ij}\) on \(m_i\) due to \(m_j\) acts at \(m_i\) and points along \(\mathbf r_{ij}\), towards \(m_j\). Script: fig-gravity-force.py.

Two quick checks. (a) Use Equation 1 to check the units of \(G\). (b) Write down \(\mathbf F_{ji}\), the force on \(m_j\) due to \(m_i\), and show that \(\mathbf F_{ji}=-\mathbf F_{ij}\). Which of Newton’s laws is this?

Answer
  1. \([G]=[F][r^2]/[m^2]=\text{kg\,m\,s}^{-2}\cdot\text{m}^2/\text{kg}^2=\text{m}^3\,\text{kg}^{-1}\,\text{s}^{-2}\).

  2. Swapping the labels, \(\mathbf F_{ji}=G m_j m_i\,\mathbf r_{ji}/r_{ji}^3\). Since \(\mathbf r_{ji}=\mathbf R_i-\mathbf R_j=-\mathbf r_{ij}\) and \(r_{ji}=r_{ij}\), we get \(\mathbf F_{ji}=-\mathbf F_{ij}\). The forces are equal, opposite and along the line joining the bodies: Newton’s third law, in its strong form. We will use both halves of this (“opposite” and “along the line”) in Section 7.

4.2 Which body dominates? A surprise

It is tempting to think that the Moon moves under the Earth’s gravity and that the Sun is a small correction. Let us check.

Compute the acceleration of the Moon (a) due to the Sun, \(GM_\odot/(1~\text{AU})^2\), and (b) due to the Earth, \(GM_\oplus/(384\,400~\text{km})^2\). Use \(GM_\odot=1.327\times10^{20}\) m\(^3\)/s\(^2\) and \(GM_\oplus=3.986\times10^{14}\) m\(^3\)/s\(^2\). Which is larger?

What you should find
  1. \(5.93\) mm/s\(^2\); (b) \(2.70\) mm/s\(^2\). The Sun pulls the Moon 2.2 times harder than the Earth does.

So why does the Moon go round the Earth and not wander off? Because the Sun pulls the Earth almost exactly as hard as it pulls the Moon: the two are at nearly the same distance from the Sun. What changes the Moon’s motion relative to the Earth is only the difference of the Sun’s pulls on the two, which at the Moon’s distance is about \(3\times10^{-5}\) m/s\(^2\), a hundredth of the Earth’s pull. Two lessons follow, and both will return. First, it is relative motion that matters, so we should look for equations of relative motion. Second, “which body dominates” is a question about differences of accelerations; it is answered properly in the patched-conics note. Figure 2 shows the numbers.

Figure 2: Left: at new Moon the Sun pulls the Moon (\(5.96\) mm/s\(^2\)) harder than the Earth does (\(2.70\) mm/s\(^2\)), but it pulls the Earth almost as hard (\(5.93\) mm/s\(^2\)). Right: the difference of the Sun’s pulls on the Moon and on the Earth, round the Moon’s orbit, greatly enlarged: it stretches the orbit along the Sun line and squeezes it across, and it is about \(1\%\) of the Earth’s pull. Script: fig-sun-pull-difference.py.

5 An inertial frame

Newton’s second law, \(m\ddot{\mathbf R}=\mathbf F\), holds only in an inertial frame. So before writing equations we must decide where to put the origin and the axes.

What is a good inertial frame for the solar system? Is the centre of the Sun a good origin?

Answer

No frame we can actually build is exactly inertial. In practice the origin is taken at the solar-system barycentre (the centre of mass of the whole system) and the axes are fixed with respect to distant quasars (the International Celestial Reference Frame, ICRF).

The barycentre beats the Sun’s centre because the Sun itself moves about the barycentre, mostly under the pull of the giant planets, by up to about two solar radii (Jupiter alone accounts for about one; Section 7.1 shows how to compute this). The barycentric frame is itself falling towards the centre of the Galaxy, at about \(2\times10^{-10}\) m/s\(^2\). But the Galaxy’s pull is very nearly uniform across the solar system, so it accelerates every body equally and drops out of their relative motion. “Inertial” always means inertial enough for the accuracy you need.

For now, we only assume that some inertial frame exists and that the \(\mathbf R_i\) are measured in it. We will not choose the origin by hand: the equations of motion will tell us where to put it (Section 7.1).

6 The equations of motion

Body \(i\) feels the pull of every other body. Adding the forces Equation 1 and applying Newton’s second law,

\[ m_i\ddot{\mathbf R}_i=\sum_{\substack{j=1\\ j\ne i}}^{n}\mathbf F_{ij} =G\sum_{\substack{j=1\\ j\ne i}}^{n}\frac{m_i m_j}{r_{ij}^{3}}\,\mathbf r_{ij}, \qquad i=1,2,\dots,n. \tag{2}\]

The sum skips \(j=i\) because a body does not attract itself.

Divide Equation 2 by \(m_i\). On what does the acceleration of body \(i\) depend, and on what does it not depend?

Answer \(\ddot{\mathbf R}_i=G\sum_{j\ne i}m_j\mathbf r_{ij}/r_{ij}^3\). It depends on the positions of all the bodies and on the masses of the other bodies, but not on \(m_i\). A feather and a planet at the same place fall with the same acceleration. This is why we will be able to compute a spacecraft’s trajectory without knowing its mass.

Equation 2 is a set of \(3n\) second-order equations, coupled because every right-hand side contains every position. To integrate them we need, at \(t=0\), every position and every velocity. Introducing the velocities \(\mathbf V_i=\dot{\mathbf R}_i\) as unknowns turns the system into first-order form,

\[ \dot{\mathbf R}_i=\mathbf V_i,\qquad \dot{\mathbf V}_i=G\sum_{j\ne i}\frac{m_j}{r_{ij}^{3}}\,\mathbf r_{ij},\qquad \mathbf R_i(0)=\mathbf R_{i0},\quad \mathbf V_i(0)=\mathbf V_{i0}, \tag{3}\]

which is \(6n\) first-order ordinary differential equations (ODEs) with \(6n\) initial conditions. The number \(6n\) is called the order of the system.

What is the order of the system for the Sun and the eight planets? For the Sun, the planets, the Moon and Jupiter’s four large moons? How many distinct pairs \((i,j)\) must be evaluated per time step in each case?

Answer \(n=9\): order \(54\), and \(n(n-1)/2=36\) pairs. \(n=14\): order \(84\), and \(91\) pairs. The cost of each step grows like \(n^2\), which is why nobody integrates the asteroid belt body by body.

7 The ten integrals

Before trying to solve Equation 3, it pays to ask a simpler question: is anything constant? A function of the positions and velocities that does not change along a solution is called an integral of the motion (or a constant of the motion). Integrals are worth hunting for, for three reasons.

  • Each independent integral removes one unknown. If a system of order \(k\) had \(k-1\) independent integrals, its trajectories would be fixed curves in the state space and only the timing would remain.
  • Integrals tell us things about every solution at once, without solving anything.
  • A numerical solution must conserve them. If it does not, the numerical solution is wrong.

We look for integrals by the standard trick: combine the equations of motion so that one side becomes an exact time derivative.

7.1 Linear momentum and the centre of mass

Sum Equation 2 over all bodies:

\[ \sum_{i=1}^{n}m_i\ddot{\mathbf R}_i=\sum_{i=1}^{n}\sum_{j\ne i}\mathbf F_{ij}. \]

The double sum on the right contains every ordered pair \((i,j)\) with \(i\ne j\). Group each pair with its mirror image \((j,i)\):

\[ \sum_{i=1}^{n}\sum_{j\ne i}\mathbf F_{ij}=\sum_{\text{pairs }i<j}\left(\mathbf F_{ij}+\mathbf F_{ji}\right)=\mathbf 0, \]

because \(\mathbf F_{ji}=-\mathbf F_{ij}\). The internal forces cancel in pairs.

Write the double sum out in full for \(n=3\). How many terms are there, and which ones cancel?

What you should find Six terms: \(\mathbf F_{12}+\mathbf F_{13}+\mathbf F_{21}+\mathbf F_{23}+\mathbf F_{31}+\mathbf F_{32}\). They cancel as \(\mathbf F_{12}+\mathbf F_{21}=\mathbf 0\), \(\mathbf F_{13}+\mathbf F_{31}=\mathbf 0\) and \(\mathbf F_{23}+\mathbf F_{32}=\mathbf 0\). In general there are \(n(n-1)\) terms in \(n(n-1)/2\) cancelling pairs.

So \(\sum_i m_i\ddot{\mathbf R}_i=\mathbf 0\). Integrating once and then once more,

\[ \sum_{i=1}^{n}m_i\dot{\mathbf R}_i=\mathbf C_1,\qquad \sum_{i=1}^{n}m_i\mathbf R_i=\mathbf C_1t+\mathbf C_2 , \tag{4}\]

where \(\mathbf C_1\) and \(\mathbf C_2\) are constant vectors: six scalar constants. The first is the conservation of total linear momentum. To read the second, define the total mass and the centre of mass (or barycentre),

\[ M=\sum_{i=1}^{n}m_i,\qquad \mathbf R_{\rm cm}=\frac{1}{M}\sum_{i=1}^{n}m_i\mathbf R_i . \]

Then Equation 4 says \(\mathbf R_{\rm cm}(t)=(\mathbf C_1t+\mathbf C_2)/M\): the centre of mass moves in a straight line at constant speed. A frame moving with it is therefore also inertial, and in that frame \(\mathbf C_1=\mathbf C_2=\mathbf 0\). This is the origin the equations chose for us, and it is the barycentric frame of Section 5.

Take only the Sun and Jupiter, with \(M_\odot/M_J=1047.35\) and Jupiter at \(778.5\times10^{6}\) km from the Sun. How far from the centre of the Sun is their barycentre? Compare with the Sun’s radius, \(6.96\times10^{5}\) km.

What you should find With the origin at the barycentre, \(M_\odot\mathbf R_\odot+M_J\mathbf R_J=\mathbf 0\), so the distance from the Sun’s centre is \(778.5\times10^{6}\times M_J/(M_\odot+M_J)=742\,600\) km, which is \(1.07\) solar radii. The Sun–Jupiter barycentre lies just outside the Sun. The Sun is not fixed: it wobbles about the barycentre once every Jupiter year (and, because of the other planets, in a more complicated pattern).

7.2 Angular momentum and the invariable plane

The internal forces do more than cancel in pairs: each pair also acts along the line joining the two bodies. A pair of equal and opposite forces along the same line exerts no net torque. So we expect the total angular momentum to be conserved too. Let us prove it.

Take the cross product of Equation 2 with \(\mathbf R_i\) and sum over \(i\):

\[ \sum_{i=1}^{n}m_i\,\mathbf R_i\times\ddot{\mathbf R}_i=\sum_{i=1}^{n}\sum_{j\ne i}\mathbf R_i\times\mathbf F_{ij}. \]

Group the right-hand side into pairs again. Using Equation 1 and \(\mathbf r_{ji}=-\mathbf r_{ij}\), the pair \((i,j)\) contributes

\[ \mathbf R_i\times\mathbf F_{ij}+\mathbf R_j\times\mathbf F_{ji} =\frac{Gm_im_j}{r_{ij}^{3}}\left(\mathbf R_i-\mathbf R_j\right)\times\mathbf r_{ij} =-\frac{Gm_im_j}{r_{ij}^{3}}\,\mathbf r_{ij}\times\mathbf r_{ij}=\mathbf 0 , \]

since \(\mathbf R_i-\mathbf R_j=-\mathbf r_{ij}\) and the cross product of a vector with itself vanishes. Every pair gives zero, so the right-hand side vanishes. On the left,

\[ \frac{d}{dt}\left(\mathbf R_i\times\dot{\mathbf R}_i\right) =\dot{\mathbf R}_i\times\dot{\mathbf R}_i+\mathbf R_i\times\ddot{\mathbf R}_i =\mathbf R_i\times\ddot{\mathbf R}_i , \]

so the left-hand side is an exact derivative and

\[ \mathbf H=\sum_{i=1}^{n}m_i\,\mathbf R_i\times\dot{\mathbf R}_i=\mathbf C_3 . \tag{5}\]

The total angular momentum \(\mathbf H\) is constant in magnitude and in direction: three more scalar constants.

Where in the proof did we use that the force acts along the line joining the bodies, rather than merely that \(\mathbf F_{ji}=-\mathbf F_{ij}\)?

Answer In the step \((\mathbf R_i-\mathbf R_j)\times\mathbf r_{ij}=\mathbf 0\). If the pair of forces were equal and opposite but not along \(\mathbf r_{ij}\), they would form a couple and \(\mathbf R_i\times\mathbf F_{ij}+\mathbf R_j\times\mathbf F_{ji}=(\mathbf R_i-\mathbf R_j)\times\mathbf F_{ij}\) would not vanish. Momentum would still be conserved; angular momentum would not.

Because \(\mathbf H\) is fixed, it defines a fixed plane: the plane through the barycentre perpendicular to \(\mathbf H\). It is called the invariable plane. For this definition take the \(\mathbf R_i\) from the barycentre. About any other fixed origin \(\mathbf H\) is still constant, but it differs by the constant \(M\,\mathbf C_2\times\mathbf C_1\) (with \(M\) the total mass), so its direction would depend on where the origin was put. Two other planes are used as references in astronomy, and it helps to name them now.

  • The ecliptic is the plane of the Earth’s orbit about the Sun.
  • The solar equator is the plane through the Sun’s centre perpendicular to the Sun’s rotation axis.

The invariable plane is inclined at about \(1.58^\circ\) to the ecliptic and about \(6^\circ\) to the solar equator. (The more familiar \(23.44^\circ\) is a different angle: the tilt of the Earth’s equator to the ecliptic.)

Figure 3: The ecliptic (grey), the total orbital angular momentum \(\mathbf H\) of the eight planets, and the invariable plane perpendicular to it (green). The vertical scale is exaggerated by a factor of 2.8 so that the \(1.58^\circ\) tilt can be seen. Drag to rotate. Script: fig-invariable-plane.py.

Which planets decide where \(\mathbf H\) points? In the two-body note we will show that a planet of mass \(m\) on an orbit of semi-major axis \(a\) and eccentricity \(e\) about the Sun carries angular momentum \(m\sqrt{GM_\odot\,a(1-e^2)}\). Since \(GM_\odot\) is common to all planets, each planet’s share is proportional to \(m\sqrt{a(1-e^2)}\).

Using the masses (in Earth masses) \(m_J=317.8\), \(m_S=95.2\), \(m_U=14.5\), \(m_N=17.1\) and \(a\) from the table in Section 2 (with \(a_U=19.19\), \(a_N=30.07\) AU), and ignoring \(e\), estimate the share of the planets’ orbital angular momentum carried by each giant planet. What carries the Earth?

What you should find \(317.8\sqrt{5.203}=725\), \(95.2\sqrt{9.537}=294\), \(14.5\sqrt{19.19}=64\), \(17.1\sqrt{30.07}=94\), against \(1\) for the Earth. Jupiter carries about \(62\%\), Saturn \(25\%\), Neptune \(8\%\), Uranus \(5\%\), and the four inner planets together less than \(0.3\%\). So the invariable plane is essentially Jupiter’s orbital plane tilted a little towards Saturn’s. Indeed, Jupiter’s orbit is inclined only \(0.32^\circ\) to it.

History: the invariable plane. Laplace proposed the invariable plane as a reference plane that, unlike the ecliptic, does not move. The ecliptic itself drifts slowly because the other planets perturb the Earth’s orbit. A modern determination (Souami and Souchay, 2012) found that Pluto and Ceres must be included to fix its orientation at the milliarcsecond level. The name “Laplace plane” is best avoided: it now means a different plane, the one about which a satellite’s orbit pole precesses under the combined pull of an oblate planet and the Sun.

7.3 Energy

Two vector integrals came from adding the forces and their moments. The third integral is a scalar. To find it we first show that the gravitational force is the gradient of a scalar function. That fact matters on its own: one scalar function of the positions is far easier to handle than \(3n\) force components, and it is what makes an energy integral possible.

Four tools from vector calculus are used from here on.

  • Gradient. For a scalar \(f(\mathbf x)\), \(\nabla f=(\partial f/\partial x,\,\partial f/\partial y,\,\partial f/\partial z)\). It points the way \(f\) increases fastest, and \(df=\nabla f\cdot d\mathbf x\) for any small step.
  • Curl. For a vector field \(\mathbf F\), \(\nabla\times\mathbf F\) has \(z\)-component \(\partial F_y/\partial x-\partial F_x/\partial y\) (and the others by cycling \(x\to y\to z\)). The curl of a gradient is always zero.
  • Line integral. \(\int_A^B\mathbf F\cdot d\mathbf r\) adds up the work along a path. If \(\mathbf F=-\nabla\phi\) it equals \(\phi(A)-\phi(B)\), whatever the path.
  • Triple products. \(\mathbf a\cdot(\mathbf b\times\mathbf c)\) is unchanged by a cyclic shift and vanishes when two vectors are parallel; \(\mathbf a\times(\mathbf b\times\mathbf c)=\mathbf b\,(\mathbf a\cdot\mathbf c)-\mathbf c\,(\mathbf a\cdot\mathbf b)\).

The gradient of a distance. All gradients below are taken with respect to the position of the body that feels the force, with the other body held fixed:

\[ \nabla_i\equiv\frac{\partial}{\partial\mathbf R_i}. \]

Let \(X_{ik}\) be the \(k\)-th Cartesian component of \(\mathbf R_i\), so \(\mathbf R_i=X_{i1}\hat{\mathbf i}+X_{i2}\hat{\mathbf j}+X_{i3}\hat{\mathbf k}\). Then

\[ r_{ij}^{2}=\mathbf r_{ij}\cdot\mathbf r_{ij}=\sum_{k=1}^{3}\left(X_{jk}-X_{ik}\right)^{2}. \]

Differentiating both sides with respect to \(X_{ik}\),

\[ 2r_{ij}\frac{\partial r_{ij}}{\partial X_{ik}}=2\left(X_{jk}-X_{ik}\right)(-1) \qquad\Longrightarrow\qquad \frac{\partial r_{ij}}{\partial X_{ik}}=-\frac{X_{jk}-X_{ik}}{r_{ij}} . \]

Collecting the three components,

\[ \nabla_i\,r_{ij}=-\frac{\mathbf r_{ij}}{r_{ij}}=-\hat{\mathbf r}_{ij}. \]

This is geometrically obvious once written down: moving body \(i\) towards \(j\) (along \(\hat{\mathbf r}_{ij}\)) shortens the distance fastest. One more application of the chain rule gives

\[ \frac{\partial}{\partial X_{ik}}\left(\frac{1}{r_{ij}}\right) =-\frac{1}{r_{ij}^{2}}\frac{\partial r_{ij}}{\partial X_{ik}} =\frac{X_{jk}-X_{ik}}{r_{ij}^{3}} \qquad\Longrightarrow\qquad \nabla_i\left(\frac{1}{r_{ij}}\right)=\frac{\mathbf r_{ij}}{r_{ij}^{3}} . \]

The force as a gradient. Comparing with Equation 1,

\[ \mathbf F_{ij}=\frac{Gm_im_j}{r_{ij}^{3}}\,\mathbf r_{ij} =\nabla_i\left(\frac{Gm_im_j}{r_{ij}}\right)=-\nabla_i\Phi_{ij}, \tag{6}\]

where

\[ \Phi_{ij}=-\frac{Gm_im_j}{r_{ij}} . \]

\(\Phi_{ij}\) is the mutual potential energy of the pair; note that it contains both masses. (The gravitational potential of \(m_j\) is a field defined per unit mass at every point \(\mathbf x\): \(\phi_j(\mathbf x)=-Gm_j/|\mathbf x-\mathbf R_j|\). Evaluated at body \(i\) it gives \(\Phi_{ij}=m_i\,\phi_j(\mathbf R_i)\).) Summing over \(j\), the total force on body \(i\) is

\[ \mathbf F_i=\sum_{j\ne i}\mathbf F_{ij}=-\nabla_i\Phi_i,\qquad \Phi_i=\sum_{j\ne i}\Phi_{ij}=-G\sum_{j\ne i}\frac{m_im_j}{r_{ij}} , \]

and the equation of motion becomes \(m_i\ddot{\mathbf R}_i=-\nabla_i\Phi_i\).

The energy integral. Take the dot product of \(m_i\ddot{\mathbf R}_i=-\nabla_i\Phi_i\) with \(\dot{\mathbf R}_i\) and sum over the bodies:

\[ \sum_{i=1}^{n}m_i\,\dot{\mathbf R}_i\cdot\ddot{\mathbf R}_i=-\sum_{i=1}^{n}\dot{\mathbf R}_i\cdot\nabla_i\Phi_i . \tag{7}\]

The left-hand side is an exact derivative: it is \(dT/dt\), where

\[ T=\frac12\sum_{i=1}^{n}m_i\,\dot{\mathbf R}_i\cdot\dot{\mathbf R}_i \]

is the total kinetic energy. We would like the right-hand side to be the time derivative of a single function too. The natural guess, \(\sum_i\Phi_i\), is wrong by a factor of two, and it is worth seeing why before going on.

Take \(n=2\). Write out \(\Phi_1\) and \(\Phi_2\). What is \(\Phi_1+\Phi_2\)? What is the potential energy of the pair, i.e. the work needed to bring the two masses together from infinite separation?

What you should find \(\Phi_1=\Phi_{12}=-Gm_1m_2/r_{12}\) and \(\Phi_2=\Phi_{21}=-Gm_2m_1/r_{12}\), so \(\Phi_1+\Phi_2=-2Gm_1m_2/r_{12}\). But the pair has a single bond, of energy \(-Gm_1m_2/r_{12}\). The sum over bodies counts each pair twice, once from each end.

So we define the potential energy of the system as a sum over pairs. We call it \(U\), not \(V\), because \(\mathbf V_i\) already denotes the velocities:

\[ U=-G\sum_{\text{pairs }i<j}\frac{m_im_j}{r_{ij}} =-\frac{G}{2}\sum_{i=1}^{n}\sum_{j\ne i}\frac{m_im_j}{r_{ij}} =\frac12\sum_{i=1}^{n}\Phi_i . \tag{8}\]

\(U\) depends on time only through the positions, so by the chain rule

\[ \frac{dU}{dt}=\sum_{i=1}^{n}\nabla_iU\cdot\dot{\mathbf R}_i . \]

Which terms of \(U\) depend on \(\mathbf R_i\)? Exactly the pairs that contain body \(i\), i.e. the terms \(\Phi_{ij}\) for \(j\ne i\), each appearing once in the pair sum. Hence

\[ \nabla_iU=\sum_{j\ne i}\nabla_i\Phi_{ij}=\nabla_i\Phi_i . \]

(The factor \(\tfrac12\) in Equation 8 and the double counting in the double sum cancel exactly.) Substituting into Equation 7,

\[ \frac{dT}{dt}=-\sum_{i=1}^{n}\dot{\mathbf R}_i\cdot\nabla_iU=-\frac{dU}{dt} \qquad\Longrightarrow\qquad T+U=C_4 . \tag{9}\]

The total energy is constant: the tenth scalar constant.

A student integrates Equation 3 numerically for \(10^4\) years and finds that \(T+U\) has changed by one part in \(10^{6}\). What can be concluded? What if it had stayed constant to \(10^{-14}\)?

Answer Since the exact solution conserves \(T+U\), a change of \(10^{-6}\) is pure numerical error, and it gives a rough measure of how inaccurate the solution is. The converse does not hold: conservation to \(10^{-14}\) is necessary but not sufficient. An integrator can conserve energy well and still put a planet at the wrong place along its orbit (a timing error does not change the energy).

7.4 A closer look at conservative forces

A force that is the gradient of a scalar is called conservative. The name comes from what it does to work. Take a point mass \(m_i\) moving from point \(A\) to point \(B\) in the field of a fixed \(m_j\). Along any path, \(\mathbf F_{ij}\cdot d\mathbf r=-\nabla_i\Phi_{ij}\cdot d\mathbf r=-d\Phi_{ij}\), so the work done by gravity is

\[ W=\int_A^B\mathbf F_{ij}\cdot d\mathbf r=\Phi_{ij}(A)-\Phi_{ij}(B). \]

It depends only on the end points, not on the route.

Figure 4: The work done by a conservative force in moving from \(A\) to \(B\) is the same along every path: \(W_1=W_2=W_3=\Phi(A)-\Phi(B)\). Script: fig-conservative-paths.py.

Does this mean that if I move a satellite from one orbit to another, every route costs the same?

Answer

The same work, yes; the same fuel, no. The gap between those two statements is where mission design lives.

The work done by gravity is \(-\Delta U\), fixed by the end points. The two orbits also fix the energy at each end, so the energy the engine must supply is fixed too. What is not fixed is the velocity change \(\Delta v\) needed to deliver that energy, and \(\Delta v\) is what costs propellant. A burn along the velocity raises the energy per unit mass by \(\Delta\varepsilon=\tfrac12(v+\Delta v)^2-\tfrac12v^2=v\,\Delta v+\tfrac12\Delta v^2\), so the same energy is bought with less \(\Delta v\) where the speed \(v\) is already large. Where you burn, how you change the plane, and how long the burn lasts all change the bill, though the work does not change.

Since the curl of a gradient is zero, a conservative force is also irrotational: \(\nabla_i\times\mathbf F_{ij}=-\nabla_i\times(\nabla_i\Phi_{ij})=\mathbf 0\). It is instructive to check this directly, without the potential. Let a point mass \(M\) sit at the origin; its field (force per unit mass) at \(\mathbf r=(x,y,z)\) is

\[ \mathbf g=-GM\,\frac{\mathbf r}{r^{3}},\qquad r=\sqrt{x^2+y^2+z^2},\qquad \frac{\partial r}{\partial x}=\frac xr . \]

Show that the \(z\)-component of \(\nabla\times\mathbf g\), which is \(\partial g_y/\partial x-\partial g_x/\partial y\), vanishes. You need only the derivative \(\partial(r^{-3})/\partial x=-3x/r^{5}\).

What you should find

\[ \begin{aligned} \frac{\partial g_y}{\partial x}&=-GM\,y\,\frac{\partial}{\partial x}\left(r^{-3}\right)=\frac{3GM\,xy}{r^{5}},\\[2pt] \frac{\partial g_x}{\partial y}&=-GM\,x\,\frac{\partial}{\partial y}\left(r^{-3}\right)=\frac{3GM\,xy}{r^{5}}, \end{aligned} \]

so their difference is zero. The other two components follow by relabelling the axes.

More generally, every central field \(\mathbf g=g(r)\,\hat{\mathbf r}\) is irrotational, whatever the function \(g\). Irrotationality says the field comes from a potential; it does not single out the inverse square. We will meet properties that do single out the inverse square in the two-body note.

8 Counting: why two bodies are easy and three are not

We now have ten scalar integrals, valid for every \(n\):

integral equation scalar constants
centre-of-mass velocity \(\sum m_i\dot{\mathbf R}_i=\mathbf C_1\) \(3\)
centre-of-mass position \(\sum m_i\mathbf R_i-\mathbf C_1t=\mathbf C_2\) \(3\)
angular momentum \(\mathbf H=\mathbf C_3\) \(3\)
energy \(T+U=C_4\) \(1\)

The system has order \(6n\). Each independent integral lowers the order by one. Two further reductions are classical (eliminating the time, and eliminating the orientation of the line in which the plane of the motion cuts the invariable plane, known as the node), and together they reduce the order from \(6n\) to \(6n-12\).

  • \(n=2\). Order \(12\), and \(6n-12=0\): the integrals alone already reduce the problem to quadratures (integrals of known functions). Removing the centre of mass (six constants) leaves the relative motion, of order \(6\). Angular momentum fixes its plane and its areal rate, energy then gives the radial speed as a function of \(r\), and two quadratures give \(t(r)\) and the angle as a function of \(r\). This works for any central force, as the two-body note shows. What the inverse-square law adds is one more integral, the eccentricity vector. It turns the orbit equation into an algebraic one, the conic, and makes every bound orbit close: Kepler’s ellipse.
  • \(n=3\). Order \(18\). After all reductions an order-\(6\) problem remains, and there are no more integrals to use.

History: the impossibility theorems. Heinrich Bruns proved in 1887 that the three-body problem has no integrals that are algebraic functions of the positions and velocities other than the ten classical ones (Bruns 1887). Henri Poincaré, in his 1890 prize memoir for King Oscar II of Sweden, extended this to a wide class of analytic integrals, and in the process discovered what we now call chaos (Poincaré 1890). Painlevé (1898) strengthened Bruns’ result for \(n\) bodies: every integral that is algebraic in the velocities, however it depends on the positions, is a combination of the classical ten. (Both theorems are discussed in Whittaker’s Analytical Dynamics.)

In 1912 Karl Sundman did find a convergent power series for the three-body problem (for non-zero angular momentum) (Sundman 1913). It converges so slowly that it is useless in practice, which shows that “no general solution” must be stated with care: what does not exist is a solution in terms of integrals and known functions.

Bruns, Heinrich. 1887. “Über Die Integrale Des Vielkörper-Problems.” Acta Mathematica 11: 25–96.
Poincaré, Henri. 1890. “Sur Le Problème Des Trois Corps Et Les équations de La Dynamique.” Acta Mathematica 13: 1–270.
Sundman, Karl F. 1913. “Mémoire Sur Le Problème Des Trois Corps.” Acta Mathematica 36: 105–79.

So for \(n\ge3\) there is no general solution in closed form: no formula, built from the ten integrals and known functions, that gives the positions at time \(t\) for arbitrary initial conditions. (Special solutions do exist; we will see one shortly.)

The ten integrals hold for any \(n\). Why do they nearly solve the two-body problem, but leave the three-body problem wide open?

Answer Because the order grows with \(n\) and the number of integrals does not. For \(n=2\), ten integrals against an order of \(12\) leaves little to do, and the extra inverse-square integral finishes the job. For \(n=3\) the order is \(18\), and ten integrals (plus the two classical reductions) leave a sixth-order problem with nothing to reduce it further.

9 Solving numerically, and what chaos means

If no formula exists, we can still integrate Equation 3 numerically with any standard ODE integrator (Runge–Kutta methods, for example), from given initial conditions. Figure 5 shows two such solutions for three equal masses, in units where \(G=1\) and each mass is \(1\).

Figure 5: Two solutions of the three-body problem with equal masses. Left: generic initial conditions; the motion never repeats. Right: the figure-eight, a special periodic solution in which the three bodies chase each other round one curve. Script: three-body-animation.py.

The left panel looks messy, but messy is not the same as unpredictable. To see what is special about it, run it twice.

Figure 6 shows the left-panel system integrated twice. In run B, body 1 starts \(10^{-6}\) to the right of where it starts in run A (in units where the bodies start about \(1\) apart). Read off from the right panel: (a) roughly how large the difference between the two runs is at \(t=10\) and at \(t=40\); (b) how large the integrator error is, measured by the change in energy. Then run fig-nbody-sensitivity.py with a smaller offset (give it the argument \(10^{-9}\); its header explains how), and note the separation it prints at \(t=45\).

What you should find
  1. A few times \(10^{-4}\) at \(t=10\) and a few times \(10^{-2}\) just before \(t=40\): the offset has grown ten-thousandfold. At the close encounter near \(t=40\) it jumps to order \(1\), and by \(t=45\) the two copies of body 1 are more than \(3\) units apart. (b) The energy error stays below \(10^{-9}\) throughout, so the divergence is not numerical error: it is a property of the equations.
With an offset of \(10^{-9}\) the printed separation at \(t=45\) is \(0.013\) instead of \(3.3\). A thousand times smaller starting error postpones the divergence, but the offset is still amplified about \(10^{7}\) times. In both runs bodies 1 and 3 end up as a tight binary and body 2 is thrown out; what the offset changes is the direction in which the binary leaves (the left panel) and how tight it is.
Figure 6: The chaotic case of Figure 5, integrated twice; run B starts with body 1 moved by \(10^{-6}\). Left: the path of body 1 in each run. Right: the distance between the two copies of body 1 (maroon) and the energy error of run A (green). Each jump in the maroon curve is a close encounter between two bodies. Script: fig-nbody-sensitivity.py.

This is what chaos means here. A solution is chaotic if solutions that start arbitrarily close together separate, on average exponentially fast, until the separation is as large as the system itself. The solution is still exactly determined by its initial conditions; but since initial conditions are only known approximately, prediction beyond some horizon becomes meaningless.

History: chaos in the solar system and the figure-eight. Jacques Laskar showed in 1989, by integrating averaged equations for the planets over \(200\) million years, that the inner solar system is chaotic, with errors growing by a factor \(e\) roughly every \(5\) million years.

The figure-eight solution was found numerically by Cris Moore in 1993, and its existence was proved by Alain Chenciner and Richard Montgomery in 2000.

The time over which a small error grows by a factor \(e\approx2.7\) is called the Lyapunov time; it is the natural clock of a chaotic system. The solar system is chaotic too, but its chaos is slow: for the inner planets the Lyapunov time is about five million years.

If the solar system is chaotic, how can a mission team plan a Mars launch window twenty years in advance?

Answer Twenty years is about \(4\times10^{-6}\) of the five-million-year growth time, so an error grows by a negligible factor over a mission’s lifetime. Chaos limits predictions over millions of years, not decades. The planetary ephemerides that missions use are numerical solutions of the \(N\)-body problem, fitted to observations and updated regularly.

The right panel of Figure 5 shows the other side of the story. The figure-eight is an exact periodic solution: the three bodies follow one another round the same curve, forever. Such special solutions exist, but they are rare, and finding them takes either cleverness or a computer.

10 The way forward

Where does this leave us? The \(N\)-body problem has no general closed-form solution. Numerical solutions are accurate, but they are expensive for many bodies, and they give numbers rather than understanding: a table of positions does not tell you why a burn in one place raises the orbit on the other side, or what changes if you burn a little earlier.

What extra assumption could reduce the \(N\)-body problem to something solvable, while keeping the essential dynamics of the solar system or of a satellite about the Earth?

Answer

Exploit how uneven the masses are. The Sun holds about \(99.87\%\) of the mass of the Sun and planets together; the Earth outweighs a satellite by a factor of order \(10^{21}\). So:

  1. keep two bodies, and treat everything else as a small disturbance: the two-body problem, which can be solved in closed form;
  2. treat them as point masses, which is exact for spherically symmetric bodies (shell theorem);
  3. when one mass is negligible, ignore its pull on the other: the restricted problem.
Every model in the rest of the course is this idealisation, or a correction to it.

How small is “everything else”? A quick estimate settles it.

Jupiter is the most massive planet, \(M_\odot/M_J=1047\). At its closest, it is \(5.20-1.00=4.20\) AU from the Earth. Compute the ratio of Jupiter’s pull on the Earth to the Sun’s pull on the Earth.

What you should find \(\dfrac{GM_J/(4.20~\text{AU})^2}{GM_\odot/(1~\text{AU})^2}=\dfrac{1}{1047\times4.20^2}=5.4\times10^{-5}\). Even the largest planet, at its closest, pulls on the Earth about twenty thousand times more weakly than the Sun. (What actually perturbs the Earth’s orbit about the Sun is the difference between Jupiter’s pulls on the Earth and on the Sun, which is of the same order.)

The consequences are the following.

  • The Sun barely moves. With \(M_\odot/M_J\approx1047\), the Sun’s motion about the barycentre is about a thousand times smaller than Jupiter’s. So we may treat the Sun as fixed at the barycentre, with the planets moving about it.
  • The planets barely disturb one another. Each planet’s motion is decided almost entirely by the Sun, so we may treat each planet as moving in the field of the Sun alone.

Both together give the restricted two-body problem: one small body moving in the field of one large one. It is what we solve next, in the two-body note, and it turns out to contain an astonishing amount: Kepler’s three laws, escape, flybys, and the timing of every orbit.

11 Summary

  1. The bodies of the solar system may be treated as point masses: because they are small compared with their separations, and, more fundamentally, because a spherically symmetric body attracts like a point (shell theorem).
  2. Newton’s law gives \(n\) coupled second-order vector equations Equation 2, or \(6n\) first-order ODEs. Each body’s acceleration is independent of its own mass.
  3. Because the internal forces are equal, opposite and along the line of centres, the system has ten integrals: centre-of-mass velocity and position (\(6\)), angular momentum (\(3\)) and energy (\(1\)). The centre of mass moves uniformly, so the barycentric frame is inertial; \(\mathbf H\) defines the invariable plane, \(1.58^\circ\) from the ecliptic.
  4. Gravity is conservative: \(\mathbf F_{ij}=-\nabla_i\Phi_{ij}\), the work done is independent of path, and the field is irrotational. The system’s potential energy is a sum over pairs.
  5. For \(n=2\) the integrals (plus one special to the inverse square) solve the problem. For \(n\ge3\) there are no further algebraic integrals (Bruns), and the problem has no general closed-form solution.
  6. Numerical solutions are routine, but generic three-body motion is chaotic: nearby solutions diverge exponentially. The solar system is chaotic on a time scale of millions of years.
  7. The extreme mass ratios of the solar system justify the restricted two-body problem, the subject of the next note.

12 Exercises

  1. Weighing the Earth with the Moon. The Moon’s orbit has \(a=384\,400\) km and sidereal period \(27.32\) days. Assuming \(T^2/a^3=4\pi^2/(GM)\), compute \(GM\) for the Earth (ignore the Moon’s own mass). How far off is the answer from \(3.986\times10^{5}\) km\(^3\)/s\(^2\), and why?
  2. The Earth–Moon barycentre. With \(M_\oplus/M_{\rm Moon}=81.3\), find the distance of the Earth–Moon barycentre from the centre of the Earth. Is it inside or outside the Earth?
  3. Momentum without angular momentum. Construct two forces \(\mathbf F_{12}=-\mathbf F_{21}\) that are not along the line of centres. Show that \(\sum m_i\dot{\mathbf R}_i\) is still conserved but \(\mathbf H\) is not.
  4. The pair sum. For \(n=4\), write \(U\) as a pair sum and as \(\tfrac12\sum_i\Phi_i\), and verify that they agree term by term. Then compute \(\nabla_1U\) and show it equals \(\nabla_1\Phi_1\).
  5. Order counting. How many first-order ODEs describe the Earth–Moon–spacecraft system? Which of the ten integrals survive if the spacecraft fires its engine?
  6. Chaos and the integrator. In Figure 6 the energy error jumps at the same times as the separation. Explain why close encounters are hard for an integrator with a fixed tolerance, and why that does not explain the divergence of the two runs.

All the numbers in this note, and the identities used in the derivations, are checked by n-body-verify.py.