If you want to understand all the best physics jokes (yes, these do exist), you should probably know about the spherical cow and the three-body problem.

Two-Body Problem

Before looking at the three-body problem, let’s start of with something simpler—the two-body problem. Suppose I have two objects (two stars would work) that are both moving and both interacting with each other.

Spring 2016 Sketches key

The goal is to find an expression for the position of both objects (that are interacting gravitationally) for all future times. I’m not going to go through a full derivation, but solving the two-body problem isn’t impossible. Here’s what you do.

  • In order to keep track of both stars, you would need six coordinates. There are three coordinates for the location of each star (assuming we don’t care about their rotational orientation).
  • We can make this a three-coordinate problem by considering the motion relative to the center of mass of the two-star system. This means the problem can be reduced to two problems. There is the motion of the center of mass (which isn’t too interesting) and then a reduced mass (a combination of the two stars) orbiting the center of mass.
  • In the reduced mass system, there is only the gravitational force pulling towards the center of mass. There is no torque on the reduced mass. This means that the angular momentum vector is constant. So, we can pick a plane of motion to coincide with the x-y plane. This means that we only need two coordinates to describe this system (we are getting somewhere).
  • When you get to the actual physics (in Lagrangian mechanics) you can create a potential due to the angular motion (we can call this the centrifugal potential). This means that you will have a gravitational plus centrifugal potential and turn it into a 1-D problem (only motion in the r direction).

Yes, I skipped all the details—but the point is that you can actually solve this problem. Here is a plot for a planet orbiting a star showing the total effective potential in one dimension.

With this effective potential in 1-D, it’s just like a ball on a hill. You can see that there is a small dip in this potential—that is where you could put an object and it would be in a stable circular orbit. You can also see how much energy you would need to add to get it to escape or do whatever you like.

This is the two-body problem. It’s solvable.

Three-Body Problem

Why do we even care about the three-body problem? What if you want to model the motion of the moon? You could say that the moon orbits the Earth and that it’s a two-body problem, but this is clearly not completely true. Instead, the moon’s motion is governed both by its gravitational interaction with the Sun and Earth. Moon plus Earth plus Sun equals three bodies, the three-body problem.

But let me at a different three-body problem. Suppose there are two stars orbiting each other (a binary star system) and a planet. What would the motion of the planet be like? Let’s start with a diagram (not to scale).

Spring 2016 Sketches key

I didn’t show all the labels, but now each object has two forces on it. Also, if you want to keep track of all three objects, that is now nine coordinates. Maybe you can see that this is a tough problem. In fact, this is problem with a non-analytical solution. You can’t solve this completely like you can for the two-body problem.

Numerical Solution for the Three-Body Problem

Although there isn’t an analytical solution to the three-body problem, we can solve it numerically. I won’t go over all the details behind a numerical calculation (see this for a better start), but let me just cover the basics.

In a numerical calculation, the problem is broken into small time steps. During each step, we can approximate the force as being constant (even though it isn’t). During each one of these times steps, we will do the following.

  • Use the position of the objects to calculate the forces on all three objects.
  • With the net forces, find the new momentum of each object at the end of the time interval.
  • Using the momentum, find the new position of the object at the end of the time interval.
  • Update the time and repeat the process until you are happy.

That’s it. Of course there are some technical issues implementing this strategy for three objects. Let’s start off with just two stars (binary stars) and look at some of the details. (Click “play” to run and “pencil” to edit)

I think the comments in the code can help you figure things out, but let me point out a few things.

  • Instead of making real stars, I just dropped the units and used make believe constants.
  • Line 13: the momentum of star 1 plus star 2 is the zero vector. This means the center of mass for this system stays in place. Go ahead and change these if you like. It won’t break the program.
  • I think the rest is clear enough to follow. I wrote things in a way that it will be easier to add in a planet.

Now that we have two bodies working, let’s add another. Here is the program with notes to follow.

Now for the notes.

  • Now there are three positions to calculate along with three forces.
  • I still set the total momentum to the zero vector.
  • I just guessed at the starting values for the position and velocity of the planet, but it wasn’t too difficult to find one that gives a fairly stable orbit.
  • Really, this is just the same as the two body program but there are three bodies.

But the most important note—BOOM, we just solved the three-body problem and wasn’t even that difficult.


Don’t think of this as homework, think of this as Rhett’s “to do” list.

  • Are stable planetary orbits really that stable? What range of velocities will give a stable (even though non-circular) orbits?
  • What if our Sun was a binary star system (but same total mass as our star)? Would the Earth’s current velocity/position produce a stable orbit?
  • Can you make a four-body system? Hint: yes, you can.
  • Could there be a three-star system? I don’t know. See if you can make it.
  • Oh, did you try just changing the initial starting conditions for the above 3 body program? You should, it’s fun.
  • Use the code from the Captain America shield bounce program and create a starting arrow to represent the initial momentum of the planet. Allow the user to click-drag to adjust this starting momentum and then run the code. Really, it could be a game to see if humans can “guess” a stable orbit.

Continue reading:

This Is the Only Way to Solve the Three-Body Problem