Three-Body Problem Simulator
Simulate the three-body problem online and in 3D: drag three stars, add a planet among three suns, and watch a ghost started 150 km away part company.
Simulator
Drag a star or the planet to move its start, or at day 0 the dot on its arrow to change how it starts moving. Drag empty space to turn the view; keys 1 to 4 pick a body and the arrows move it. Space plays and pauses.
Start from
- Ghost visibly apart after The first day any body and its ghost are more than a tenth of the stars’ starting size apart, 0.1 AU here. The ghost is the same system with star A started 150 km further along x. Worked out by computing both ahead of the animation, so it is known before you press Play.
- …
- Gap doubles every How fast the gap between the system and its ghost grows, once there is a parting or a full run to measure it from.
- …
- A star escapes No star is moving away faster than the escape speed, at least three times the other two’s separation from them, by the end of the 12 years computed.
- …
- Closest pass The smallest distance between two stars over the whole run.
- …
- Energy drift How far the computed total energy, −2.27 × 10³⁹ J, has moved from its starting value, as a fraction of it. The true motion keeps it exactly, so this is the integrator’s error, not physics.
- 0
- Momentum drift How far the total momentum has moved, against the largest sum of the bodies’ own momenta so far. Each pair’s pulls cancel exactly, so only rounding moves it.
- 0
- Angular momentum drift The same for the total angular momentum. Runge-Kutta does not keep it exactly, so this one shows the method’s error as well as rounding.
- 0
- Shortest step Each step is 0.005 of the shortest timescale in the system at that moment, 1/Ω, and never longer than a day, so the steps shrink wherever two bodies pass close.
- …
Working out the run…
Citing this tool
Last updated . Add the date you accessed it as well, which a citation of a page that can change asks for. If a specific result matters, cite the permalink from the tool’s share row instead of this page: it reproduces the exact parameters.
The equation
Newton (1687), with the special solutions of Lagrange (1772) and of Chenciner and Montgomery (2000)
What is the three-body problem?
It is the question of how three bodies move when each pulls on the other two by gravity and nothing else acts on them. Given where they start and how they are moving, where will they be later? For two bodies Isaac Newton answered it in 1687: each follows an ellipse, a parabola or a hyperbola about their shared centre of mass, the orbit the orbit simulator draws. Add a third body and there is no formula for the answer at all, and for most starts the motion is chaotic: two starts 150 km apart, nothing on the scale of stars, end in completely different places.
This simulator computes the motion step by step for three stars, and a planet if you add one, and runs a ghost of the whole system alongside it, the same in every way except that its star A starts 150 km further along, or from whatever moment you press Nudge the ghost. Drag any star to move where it starts, or, paused at the start, drag the dot at the tip of its arrow to change how it starts moving; the dashed look ahead shows what a drag does before you let go. Five starting arrangements cover the problem’s famous cases, from the figure of eight, which repeats lap after lap, to the Pythagorean problem, which ends with one star thrown out.
Why there is no formula
Energy, momentum and angular momentum are conserved, as in any isolated system, but they are not enough to pin down three bodies’ motion. In 1887 Heinrich Bruns proved that the problem has no further conserved quantities of the simple algebraic kind that would turn it into a formula, and in 1890 Henri Poincaré, working on a prize question for King Oscar II of Sweden, found why: nearby orbits wind round one another in a tangle so fine that tiny differences grow without limit, the behaviour now called chaos. In 1912 Karl Sundman did find a series that converges for all time, but so slowly that it is no use for computing anything. So the motion is computed numerically, and the conserved quantities become the check: the true motion keeps them exactly, so any drift in the computed values is the computation’s own error.
The five starting arrangements
- Figure of eight. Three equal masses chase one another round one figure-of-eight curve, a third of a lap apart. Cris Moore found it by computer in 1993 and Alain Chenciner and Richard Montgomery proved in 2000 that it exists. With one solar mass each, the stars between 0.69 and 2 AU apart and no speed over 38 km/s, it repeats every 1.0068 years, 367.7 days. It is stable: nudge it and it stays close to the same eight.
- Lagrange triangle. Joseph-Louis Lagrange showed in 1772 that three bodies at the corners of an equilateral triangle can turn together as if it were rigid. It is an exact solution, but for equal masses an unstable one: Edward Routh showed in 1875 that the triangle survives a disturbance only if 27(m₁m₂ + m₂m₃ + m₃m₁) is less than (m₁ + m₂ + m₃)², and equal masses give 81 against 9.
- Pythagorean 3-4-5. Masses of 3, 4 and 5 solar masses are released from rest at the corners of a 3-4-5 right triangle, each opposite the side of its own length, a problem Carl Burrau posed in 1913. Victor Szebehely and Frederick Peters followed it to its end in 1967: after a long, violent dance the lightest star is thrown out and the other two leave the other way as a tight binary. Here that happens at 9.57 years, after stars B and C have passed within 4.14 × 10⁻⁴ AU of each other, 61,900 km centre to centre.
- Three suns and a planet. Three Sun-like stars a few AU apart and a planet of no mass, starting on a circular orbit 0.806 AU from sun A. Over 25 years the suns hand it from A to B, back to A and on to C, and then fling it out of the system.
- Three stars in 3D. Equal masses whose velocities point out of any one plane, so the motion fills space. Tilt and turn the view, or drag an empty part of the scene, to see it.
Worked example: why Lagrange’s triangle turns in 211 days
Put three stars of one solar mass at the corners of a triangle with sides of 1 AU. Each feels the other two pull it towards the triangle’s centre, and the triangle turns as one if that pull is exactly what a circular orbit about the centre needs.
- The pull. Each of the other two stars is 1 AU away and pulls with Gm/a². The two pulls are 60° apart, so their sum points at the centre with size 2 × cos 30° × Gm/a² = √3 Gm/a².
- The circle. The centre of an equilateral triangle is a/√3 from each corner,
0.577 AU here, and a circle of radius r at angular speed ω needs a pull of ω²r per unit mass.
Setting ω²a/√3 = √3 Gm/a² gives
ω² = 3Gm/a³ = GM/a³, where M = 3m is the total mass. - The period. In astronomical units, solar masses and years, G is 4π², so ω = √(4π² × 3 / 1) = 2π√3 radians a year and the period is 2π/ω = 1/√3 = 0.5774 years, which is 210.9 days.
- The speed. v = ωr = 2π√3 × (1/√3) = 2π AU a year, 29.8 km/s, the speed the Earth moves round the Sun. Select the Lagrange triangle and the editor shows star A starting at −29.78 km/s along x.
Watch the triangle and it does turn in 211 days, holding its shape for nearly four years. Then it breaks up on its own, at about 4.4 years. Nothing nudged it except the rounding in the computer’s arithmetic, errors of about one part in 10¹⁶, and because the triangle is unstable those grow like any other disturbance until they tear it apart.
Chaos and the ghost
The ghost is the system again with one change: star A starts a little further along x, by 150,000 km, 150 km or 150 m, each a thousandth of the last. Watch the gap between the two in the first plot, on a logarithmic scale. In a chaotic system it rises in a ragged straight line, which is exponential growth, until the two are visibly apart, more than a tenth of the stars’ starting size.
| Starting arrangement | 150,000 km | 150 km | 150 m |
|---|---|---|---|
| Figure of eight | 8.22 | Not in 12 | Not in 12 |
| Lagrange triangle | 0.756 | 1.65 | 2.55 |
| Pythagorean 3-4-5 | 5.95 | 7.91 | 11.0 |
| Three suns and a planet | 3.47 | 17.1 | 25.9 |
| Three stars in 3D | 2.43 | 13.3 | 19.3 |
For the chaotic arrangements, each thousandfold better start buys only a little more time: about 0.9 years for the Lagrange triangle, whose gap doubles every 33 days once it is growing, two to five for the Pythagorean problem, and 6 to 14 for the slower dances of the three suns and the 3D stars. If the gap grows as eλt, shrinking its start a thousandfold delays any given gap by only ln(1000)/λ, which is why no achievable precision predicts a chaotic system for long. The figure of eight behaves quite differently. Its gap grows only in proportion to time, because the ghost starts with very slightly different energy, laps very slightly faster or slower, and falls behind steadily: 150 km becomes 22,000 km in 12 years, while 150,000 km takes 8.2 years to reach the line.
Press Nudge the ghost and it starts again from the system as it is at that moment, with star A moved by the head start, so the parting can be watched from any point in a run. Nudged on day 0, 200 or 400, the Lagrange triangle’s ghost parts 1.654 years later every time, because the turning triangle is the same at every moment. The Pythagorean ghost nudged on day 300 or day 1,200 still parts at 7.91 years, the same moment as one nudged at the start: a small difference grows little until one of the dance’s close passes magnifies it.
The table’s numbers were checked against a second, independent method, an algorithmically regularised integrator of the kind written for close encounters, and agree to the day, with one exception. The Pythagorean ghost 150 m out parts at 11.0 years here and at 12.6 years by that method, because a difference that small is no longer large next to the computation’s own error, which grows at the same exponential rate. The model notes below give the measured figures.
How the simulator computes the motion
Every body pulls on every other with Newton’s inverse-square law, so the acceleration of body i is
d²rᵢ/dt² = Σⱼ Gmⱼ(rⱼ − rᵢ)/|rⱼ − rᵢ|³, summed over the other bodies j. The simulator
steps those equations with the classical fourth-order Runge-Kutta method, and the step is what
makes it work. A fixed step cannot do this problem: in the Pythagorean problem two stars pass
61,900 km apart at over 6,000 km/s relative to each other, while for most of the run the closest
pair is thousands of times further apart and moving about a hundredth as fast. So every step is a
two-hundredth of the shortest timescale in the system at that moment, 1/Ω, where
Ω² = Σ [G(mᵢ + mⱼ)/rᵢⱼ³ + vᵢⱼ²/rᵢⱼ²] over every pair. The step is never longer than a
day and in that close pass shrinks to 40 milliseconds; the Shortest step readout shows it for
whatever you set.
Both the system and its ghost are stored once a day, the last step of each day cut short to land on it, and everything on the page plays back from those days: the animation, the scrubber, the plots and the readouts. So the outcome is known before you press Play, and the readouts and the picture can never disagree. The energy drift readout is the check. Round the figure of eight the energy stays within one part in a trillion over 12 years; through the Pythagorean problem’s close pass it moves by under two parts in a billion. Momentum moves only by rounding, about one part in 10¹⁴, since every pair’s pulls cancel exactly.
The runs also match an independent integrator: the Pythagorean stars to a millionth of an AU for five years, then out along the same line after the escape, and the three suns of the planet’s system to within a few kilometres over 30 years. Like all chaotic runs, the Pythagorean one is the true motion only for so long: run again at half the step it begins to differ visibly at 9.6 years, the moment of the ejection, although its ending, which star leaves and which two stay together, does not change. The arithmetic is only addition, subtraction, multiplication, division and square roots, which the engines behind Chrome and Safari round identically, so one link gives the same run in both to the last binary digit, checked by running them side by side.
A planet among three suns
In Liu Cixin’s novel The Three-Body Problem, a civilisation lives on a planet among three suns, through Stable Eras when one sun holds the planet and Chaotic Eras when the suns throw it about. The fourth starting arrangement shows how that plays out in Newton’s gravity. The planet starts on a circular orbit 0.806 AU from sun A, in 1.58 times the sunlight the Earth gets. At 3.2 years sun B takes it; at 10.4 years A takes it back; at 17.0 years C takes it; and at 24.9 years a pass 0.185 AU from sun B scorches it with 29 times the Earth’s sunlight and flings it away. Within two years it gets less than a hundredth of the Earth’s sunlight, and it never comes back.
While one sun holds it, its sunlight swings between three quarters and six times the Earth’s, as the other two pass by and stretch its orbit. A sun counts as holding the planet when it pulls on the planet harder than either other sun and the planet is moving slowly enough to orbit it. The planet orbits readout follows which sun holds it, and the third plot its sunlight. Real triple stars that last are not like this. They are hierarchical: a close pair and a distant third, which never come near enough to trade planets. Alpha Centauri is one. Its stars A and B circle each other every 80 years, and Proxima Centauri, which has planets of its own, orbits far beyond them.
What this model leaves out
- The size of stars. The bodies are points, so they can pass closer than real stars could. The Pythagorean stars’ pass at 61,900 km is far inside any real star, since the Sun’s radius alone is 696,000 km; real stars that close would collide. Newton’s gravity has no built-in scale, though: multiply every distance by k and every time by k3/2 and the same motion repeats, so the same problem with its distances in thousands of AU would be a perfectly physical triple star, taking about 32,000 times as long.
- Collisions. If two bodies come within 10⁻⁵ AU, about 1,500 km, the run stops and says so. Point masses that close cannot be followed accurately this way, and no starting arrangement here comes within forty times that.
- The planet’s pull. The planet has no mass, so it moves the suns not at all. The Earth is three millionths of the Sun’s mass; given that much, the planet would shift the suns by up to about 120,000 km over the 30 years, far too little to see at this scale.
- Relativity and tides. Close passes of real stars raise tides, lose energy to them and, for compact stars, to gravitational waves, and general relativity turns their orbits slightly. None of that is in Newton’s law.
Common mistakes
- Thinking chaos means randomness. Nothing here is random. The same start always gives the same run, which is why a shared link reproduces it exactly. The trouble is that the same start has to be exactly the same.
- Saying the three-body problem has no solutions. It has no general formula, but it has exact special solutions, such as Lagrange’s triangle and the figure of eight, and its motion can be computed as accurately as the arithmetic allows.
- Assuming every three-body system is chaotic. The figure of eight is stable, and so are hierarchical triples such as Alpha Centauri, where a distant third star circles a close pair.
- Expecting a better computer to predict it for ever. Precision buys time only logarithmically: a start known a thousand times better buys the Lagrange triangle less than a year.
- Reading the energy drift as the chaos. The drift is the integrator’s error, a few parts in a billion at worst in the five starting arrangements. The chaos is in the gap between the system and its ghost, which grows from 150 km to whole AU.
Model and assumptions
- Method
- Runge-Kutta 4th order
- Largest step
- 1 day
- Repeatability
- Deterministic. The same link gives the same numbers on any machine.
What it assumes
- Three point masses under Newton’s inverse-square gravity in three dimensions, each pulling on the other two, with nothing else acting: no collisions, no tides, no relativity and no loss of mass.
- A planet, when there is one, has no mass: the stars pull it and it pulls nothing, so the stars move exactly as they would without it.
- Each step is classical fourth-order Runge-Kutta lasting a two-hundredth of the system’s shortest timescale at that moment, 1/Ω, where Ω² sums G(mᵢ + mⱼ)/r³ + v²/r² over every pair, so the steps shrink wherever two bodies pass close.
- No step is longer than a day, because the last step of each day is cut short to land on it, and the system and its ghost are stored and compared on that daily grid.
- The ghost is the same system with star A moved a set distance along x, at the start or on the day Nudge the ghost is pressed, and stepped separately with its own steps, so its head start cannot change the system’s own run.
- Lengths are in AU, masses in solar masses and times in years, with G equal to 4π² AU³ per solar mass per year squared, the orbit simulator’s convention.
- Only addition, subtraction, multiplication, division and the square root touch the state, so a shared link gives the same run, bit for bit, in the engines behind Chrome and Safari, where it was checked.
Where it stops holding. Close passes of real stars, which have size: the Pythagorean problem’s 61,900 km pass is far inside any real star, and the run stops if two bodies come within 10⁻⁵ AU, about 1,500 km. A chaotic run is also the exact motion only for so long: run again at half the step, the Pythagorean run’s path differs visibly from the ejection 9.6 years in, though which star escapes does not.
Numerical accuracy
- Estimated error
- 1.2e-11 AU in the position of star A, about 1.1e-11 of the largest value reached
- How that was obtained
- Running the lap again with every step half as long moved star A by at most 1.1e-11 AU. Richardson extrapolation of that difference gives the figure above.
- Observed order
- 3.79, measured from a second halving rather than assumed
- Conditions
- the figure of eight: three stars of one solar mass from the starting values Chenciner and Montgomery give, lapping every 1.0068 years
The figure of eight is the easy case. Through the Pythagorean problem’s closest pass, where two stars come within 61,900 km at over 6,000 km/s and the steps shrink to 40 ms, the energy moves by 1.8e-9 of itself, and from the ejection 9.6 years in, the exact path the escaping star takes depends on the step, though which star escapes does not.
Common questions
What is the three-body problem?
It is the problem of predicting how three bodies move under their mutual gravity, from where they start and how they are moving. Newton solved it for two bodies, which follow an ellipse, a parabola or a hyperbola about their shared centre of mass, but for three there is no general formula, so the motion has to be computed step by step. For most starts it is chaotic: in this simulator a ghost of the system started just 150 km away ends up somewhere completely different.
Has the three-body problem been solved?
Not with a formula. Heinrich Bruns proved in 1887 that it has no conserved quantities of the simple algebraic kind beyond energy, momentum and angular momentum, and Henri Poincaré showed in 1890 that nearby orbits tangle in what is now called chaos. Karl Sundman found a series that converges for all time in 1912, but it converges far too slowly to use. What the problem does have are exact special solutions, such as Lagrange’s turning triangle of 1772 and the figure of eight found in 1993, and numerical methods as accurate as the arithmetic allows.
What is the figure-eight solution?
Three equal masses chasing one another round one figure-of-eight curve, a third of a lap apart. Cris Moore found it by computer in 1993, and Alain Chenciner and Richard Montgomery proved in 2000 that it exists. In the units where G and each mass are 1 its period is 6.3259; with solar masses and distances in AU it repeats every 1.0068 years. It is stable: a ghost started 150 km away is only 22,000 km behind after 12 years, its gap growing in proportion to time rather than exponentially.
What happens in the Pythagorean three-body problem?
Masses of 3, 4 and 5 are released from rest at the corners of a 3-4-5 right triangle, each opposite the side of its own length, a problem Carl Burrau posed in 1913. They fall into a long chaotic dance in which, with the masses in solar masses and the sides in AU, the two heaviest pass within 61,900 km of each other, and in the end the lightest is thrown out while the other two leave the other way as a tight binary, as Victor Szebehely and Frederick Peters found in 1967. In those units the escape comes 9.6 years in.
Could a planet survive among three suns, as in The Three-Body Problem?
Only while the suns stay far apart compared with its orbit. In the simulator’s three suns and a planet, three Sun-like stars a few AU apart hand a planet from one sun to another three times in 25 years, its sunlight swinging between three quarters and six times the Earth’s, until a close pass flings it out of the system for good. Triple stars that last are hierarchical instead, a close pair with a distant third, as at Alpha Centauri, where A and B circle each other every 80 years and Proxima Centauri, with planets of its own, orbits far beyond them.
Why does a tiny change make such a difference?
Because the motion is chaotic: a small difference between two starts is stretched by a roughly constant factor in every equal stretch of time, so it grows exponentially. In the Lagrange triangle the gap between the system and its ghost, once it is growing, doubles every 33 days, so a ghost started 150 km away is visibly apart after 1.65 years, and one started 150 m away only 0.9 years later. A thousandfold more precise start buys less than a year. A stable orbit such as the figure of eight is different: its gap grows only in proportion to time.
How accurate is this simulator?
Each step is fourth-order Runge-Kutta, lasting a two-hundredth of the system’s shortest timescale at that moment, so steps shrink from a day to 40 milliseconds through the Pythagorean problem’s closest pass. Energy stays within one part in a trillion round the figure of eight and two parts in a billion through that pass, and the runs match an independent high-precision method: the Pythagorean stars to a millionth of an AU for five years. Chaos limits every method, though: run at half the step, the Pythagorean run’s exact path differs from 9.6 years on, though not which star escapes.