Three Body Problem
Three Body Problem
July, 2021
Abstract
Orbital mechanics describes the motion of systems in orbit with respect to each other, mainly
described using Newton’s laws. In this paper, I will be deriving the equations of motion of three
hypothetical planets orbiting each other, and solve the problem numerically using visual Python
(vpython). The model assumes that the planets are perfectly spherical, and neglects the effects
of external agents.
1 Introduction
Physics, and arguably all of science, changed forever in 1687 when Sir Isaac Newton published his
Principia Mathematica. Within it, were equations transformed our erratic-seeming cosmos into a
perfectly tuned machine of clockwork predictability: Given the current positions and velocities of
the bodies of the solar system, Newton’s equations could be used in principle to calculate their
locations at any distant time, future or past. I say in principle because the reality is not so simple.
Despite the beauty of Newton’s equations, they lead to a simple solution for planetary motion in
only one case: when two and only two bodies orbit each other; Add just one more body and all
motion becomes fundamentally chaotic.
Newton’s laws of motion and his law of universal gravitation give us a set of differential equa-
tions. Solving these equations using Newton’s other great invention, calculus, along with the
knowledge of the initial positions and velocities, will give us the state of the system at that time,
no matter how far in the past or future. Such simple exactly solvable equation is called an analytic
expression, that means that it can be written out with a finite number of mathematical operations
and functions.
In the case of two gravitating bodies, the solution to Newton’s laws is just the equations for the
path traveled by the bodies: A parabola, a circle, an ellipse of a planetary orbit, or the hyperbola
of an interstellar comet.
Three gravitating bodies was the natural next step. However, the additional influence caused
by a single extra body appeared to make the problem impossible to solve. The three-body problem
became the obsession for many great mathematicians. Over the following three centuries, solutions
have been found only for few specialized cases. In the late 1800s, mathematicians Ernst Bruns and
Henri Pointcarré convincingly asserted that a general analytic solution does not exist. The reality
of the three-body problem is that the evolution of almost all starting configurations is dominated
by chaotic dynamics, where the future states are highly dependent on small changes in the initial
conditions. It tends towards unpredictable patterns and almost inevitably one of the bodies is
1
eventually ejected from the system.
The three-body problem for the most part does not have a useful analytic solution. However,
approximate solutions can be found. If the bodies are far enough apart, one can approximate the
many body system as a series of two body systems. For example, each planet of our solar system
can be thought of as a separate two body system with the sun. This, in result, gives us a series of
simple elliptical orbits like those predicted by Kepler. However, those orbits eventually shift due
to the interactions between the planets.
Another useful approximation is when one of the three bodies has a relatively low mass compared to
the other two. Then, we can ignore the effect of the smaller body and assume that it moves within
the completely solvable 2 body orbits of its larger companions. It is called the reduced 3 body
problem and works well for tiny bodies like artificial satellites around the earth. These approxi-
mate solutions are useful but ultimately fail to perfectly predict the motion of the gravitating bodies.
The legendary status of the three-way problem inspired generations of physicists and mathe-
maticians to continue to seek exact analytic solutions, and some succeeded but in specialized cases.
The first was Leonhard Euler, who found a family of solutions for three bodies orbiting around a
mutual center of mass where all bodies remain in a straight line, as in the case of a permanent
eclipse. Moreover, Joseph Lewis Lagrange found solutions in which the three bodies form an equi-
lateral triangle. In fact, for any two bodies orbiting each other, the Euler-Lagrange solutions define
five additional orbits for a third body that can be described with simple equations. The mentioned
five points are called the Lagrange points and they are useful places to park our spacecraft.
As for now, to get an accurate prediction for the three-body system as a whole, one needs to
break its motion into tiny enough path segments or time steps and solve them one at a time. A
sufficiently small section of any gravitational trajectory can be approximated with an exact analytic
solution, perhaps a straight line or a segment of a two-body path around the center of mass of the
entire system. By doing so, the small motions of all bodies in the system can be updated step
by step. This method is called numerical integration, and it is the method I will approach in this
project. Instead of doing the calculation by hand, I will leave the honor for the computer to model
the motion of a three-body system.
With modern computers, N body simulations can accurately predict the motion of the planets into
the distant future or solve for millions of objects to simulate the formation and evolution of entire
galaxies.
Gm1 m2
F⃗12 = − r̂ (1)
r2
where G is the universal gravitational constant, r is the distance separating A and B, and r̂ is
the unit vector defined as:
⃗r
r̂ =
r
This will come in handy for the derivative, as it is easier to evaluate the derivative of the unit
2
vector since it doesn’t change in magnitude. Therefore, equation 1 can be re-written as:
Gm1 m2
F⃗12 = − ⃗r (2)
r3
According to Newton’s third law, for every action, there is a equal reaction in the opposite direction.
The force exerted by A on B is thus equal to:
Gm1 m2 Gm1 m2
F⃗21 = − (−r̂) = r̂ (3)
r2 r2
The net force working on the system A and B is therefore equal to zero, since no external force
is acting upon it. Figure 1 below summarizes what have been discussed so far:
Figure 1: Bodies A and B with respective masses m1 and m2 , position vectors R⃗1 and R⃗2
In a 3D orthogonal coordinate system, R⃗1 and R⃗2 are respectively the position vectors of A and
⃗ can be represented as a function of the unit vectors î, ĵ, and k̂ as
B. In fact, any position vector R
follows:
⃗ = Rx î + Ry ĵ + Rz k̂
R
Therefore,
R⃗1 = x1 î + y1 ĵ + z1 k̂
R⃗2 = x2 î + y2 ĵ + z2 k̂
More easily, any vector can be represented in a 1D matrix form, which is also called a vector
or array:
R⃗1 = x1 y1 z1
R⃗2 = x2 y2 z2
Now, this is the equation that characterizes Newton’s second law, in scalar form:
F = ma
With only the gravitational force working on the system A, the acceleration can expressed as:
m1
a=G
r2
3
m1
⃗a = −G ⃗r (5)
r3
⃗ is the velocity vector ⃗v , whose derivative is the acceler-
The derivative of the position vector R
ation ⃗a. Newton’s law can be therefore written as:
d(m⃗v ) d⃗v
F⃗ = m⃗a = =m
dt dt
The other way around would be:
Z
F dt = m(v + v0 ) = p + p0 (6)
And also, Z
a.dt = v + v0 (7)
Z
v.dt = r + r0 (8)
And as demonstrated above, the sum of the forces on both A and B will result in a net of zero.
This implies:
Xn Xn
pij = p0 = m̄v0
i=1 j=1
This is a mathematical way to say that the two body system is moving with a constant velocity
since the net external force is equal to zero. This also implies that the motions and the forces
within the system do not result in a change of velocity or change in momentum. Linear momentum
is conserved in the system.
Now, we have to resort to some estimations in order to solve the problem. The key is to start
with the initial conditions, and step through small time increments to advance the orbital motions.
The time increment will be dt.
In calculus, integrals are summations of a variable over infinitesimal intervals. Therefore, equa-
tions 6, 7, and 8 can be written as:
X
F⃗ dt = p⃗
X
⃗
⃗v dt = R
It is helpful to write the above equations in an arithmetic way; it will allow us to calculate the
new momentum and position vectors from the previous ones by adding a time increment:
⃗ = p⃗n + F⃗ dt
pn+1 (9)
⃗ = R⃗n + ⃗v dt = R⃗n + p⃗ dt
Rn+1 (10)
m
These approximations are straight line approximations of continuous motion. The precision
gets better as the time increment dt is reduced to infinitesimal values compared to the order of the
forces and radii. It is also important to visualize the motion of the center of mass of the system.
In general, the position of the center of mass of an N particles-system is expressed as:
PN ⃗
⃗ W eightedposition i=1 mi R̄i
R̄ = = P n
T otalmass i=1 mi
4
For our particular case:
⃗ ⃗
⃗ = m1 R1 + m2 R2
R̄
m1 + m2
Since no resultant force acts on the system, the center of mass will remain rotation free, however,
it will with a constant velocity v0 , equal to the initial velocity (as p = p0 = constant).
Vpython Code
5
GlowScript 3.2 VPython
G = 6.7e-11
dt = 1e5
while True:
rate(200)
r = Moon.pos - Earth.pos
F = G * Earth.mass * Moon.mass * r.hat / mag2(r)
Earth.p = Earth.p + F*dt
Moon.p = Moon.p - F*dt
Earth.pos = Earth.pos + (Earth.p / Earth.mass) * dt
Moon.pos = Moon.pos + (Moon.p / Moon.mass) * dt
weighted_pos = vector(0,0,0)
total_mass = 0
1
Figure 2: Two bodies A and B orbiting their common center of mass in an elliptic orbit
3 Three-Body System
Now, let us introduce a third body to our already existing two-body system, namely C with mass
m3 . C will exert a force on both A and B, and consequently, A and B will respectively exert an
equal force in the opposite direction (See Figure 3).
As done previously, the vectors r⃗12 , r⃗13 , and r⃗23 can be written as:
Now that the unit vectors are defined, we can start working on the forces acting on A, B, and
C. According to Figure 3, the total force F⃗1 acting on body A is the sum of the vectors F⃗21 and
F⃗31 , respectively exerted by B and C:
Gm1 m2 Gm1 m3
F⃗1 = F⃗21 + F⃗31 = − 2
rˆ21 − rˆ31 (11)
r21 r31 2
Gm2 m1 Gm2 m3
F⃗2 = F⃗12 + F⃗32 = − 2
rˆ12 − rˆ32 (12)
r12 r32 2
Gm3 m1 Gm3 m2
F⃗3 = F⃗13 + F⃗23 = − 2
rˆ13 − rˆ23 (13)
r13 r23 2
If we sum the three resulting forces F⃗1 , F⃗2 , and F⃗3 , we will get:
With the absence of an external force acting on the system, it is only logical that the resulting
force is null. Moreover, the arithmetic equations that will be used in the code can be found in
equations 9 and 10 above.
Vpython Code
6
GlowScript 3.2 VPython
AlphaA=sphere(color=color.yellow, make_trail=True)
AlphaA.pos=vector(-50e6,0,0) #Position vector
AlphaA.radius = 6.5e6 #Radius in meters
AlphaA.mass = 6e24 #Mass in kg
AlphaA.v = vector(1e3, -1e3, 0) #Speed vector
AlphaA.v_arrow = arrow(color=color.magenta, shaftwidth=0.5e6)
AlphaA.p = AlphaA.v * AlphaA.mass #Momentum vector
AlphaB=sphere(color=color.orange, make_trail=True)
AlphaB.pos=vector(50e6,0,0)
AlphaB.radius = 6e6
AlphaB.mass = 4e24
AlphaB.v = vector(1e3, 1e3, -1e3)
AlphaB.v_arrow = arrow(color=color.magenta, shaftwidth=0.5e6)
AlphaB.p = AlphaB.v * AlphaB.mass
Proxima=sphere(color=color.red, make_trail=True)
Proxima.pos=vector(0,sqrt((100e6)**2 - (50e6)**2),0)
Proxima.radius = 4e6
Proxima.mass= 6.5e24
Proxima.v = vector(-2e3, 1e3, 1e3)
Proxima.v_arrow = arrow(color=color.magenta, shaftwidth=0.5e6)
Proxima.p = Proxima.mass * Proxima.v
while True:
rate(200)
1
r_A_Proxima.hat / mag(r_A_Proxima)**2
arrow(pos=Proxima.pos, axis=force_A_Proxima/ 5e17, color=color.blue,
shaftwidth=0.5e6)
AlphaA.p += AlphaA.F * dt
AlphaA.v = AlphaA.p / AlphaA.mass
AlphaB.p += AlphaB.F * dt
AlphaB.v = AlphaB.p / AlphaB.mass
Proxima.p += Proxima.F * dt
Proxima.v = Proxima.p / Proxima.mass
for i in Planet_list:
i.pos = i.pos + (i.p / i.mass) * dt
AlphaA.v_arrow.pos = AlphaA.pos
AlphaA.v_arrow.axis = AlphaA.v * 1e4
AlphaB.v_arrow.pos = AlphaB.pos
AlphaB.v_arrow.axis = AlphaB.v * 1e4
Proxima.v_arrow.pos = Proxima.pos
Proxima.v_arrow.axis = Proxima.v * 1e4
weighted_pos = vector(0,0,0)
total_mass = 0
for a in Planet_list:
weighted_pos += a.pos * a.mass
2
total_mass += a.mass
scene.center = Center_of_mass.pos
3
Figure 3: Bodies A, B, and C of respective masses m1 , m2 , and m3 , exerting gravitational forces
on each other
Figure 4: Three bodies A,B, and C, with the forces acting on each. The magenta sphere
represents the center of mass of the system (Digital reproduction of figure 3)
References
Magali Billen, Orbital Mechanics, Libretexts, 2021.
John R. Taylor, Classical Mechanics, University Science Books, 2005, pages 293-320.
Hannu Karttunen, Pekka Kroger, Heikki Oja, Markku Poutanen, Karl Johan Donner, Fundamental
Astronomy, Sixth Edition, Springer, 2017.
7
Figure 5: A
Figure 6: B
Figure 7: C
8
Figure 8: D