3-Body Problem Simulator

chaotic gravity, twin-run divergence, and numerical stability

Loading interactive simulation...

why does it look the same on every refresh? 🖖

The three-body problem is chaotic but not random. Chaos means tiny differences in initial conditions grow exponentially β€” but refreshing the page changes nothing: same initial positions, same velocities, same dt, same algorithm, same result every time. Deterministic chaos and computational reproducibility are two different things. To actually see the chaos: set perturbation to 0.000001 and watch the dashed twin trajectory. Both trajectories start 10⁻⁢ apart and eventually diverge into completely different paths. That exponential separation is the chaos β€” the Lyapunov exponent at work. The divergence chart below the orbits plots log₁₀ of that separation over time; a straight rising line means exponential growth.

why three is the hard number 🖖

Two bodies pulling on each other trace simple, endlessly repeating ellipses β€” that case Newton solved with pen and paper. Add a third body and the neat formula disappears: there is no general equation for where everyone ends up, so the only way forward is to advance the simulation one tiny dt at a time, exactly as this tool does. Click the figure-8 preset to meet one of the rare exceptions β€” three equal masses forever chasing each other along a single looping path.

the solution that exists but is useless 🖖

People often call the three-body problem 'unsolvable', yet in 1912 Karl Sundman proved a convergent power series in t1/3 that yields the bodies' positions for all time (barring triple-collision starts). The catch: it converges so slowly that astronomical accuracy would demand on the order of 108000000 terms β€” hopelessly beyond any computer. A formal solution truly exists; stepping the simulation forward, as here, is simply the only usable route.

Problem solved in full

  1. Energy of the figure-8 choreography for 3 equal masses from initial conditions 7 steps

    The figure-8 choreography sends 3 equal masses around a single closed curve. Work out its energy at t = 0 from the initial conditions alone. This is the figure-8 orbit preset: G = 1, m1 = m2 = m3 = 1, softening Ξ΅ = 0. Positions r1 = (βˆ’0.97000436, 0.24308753), r2 = βˆ’r1, r3 = (0, 0); velocities v1 = v2 = (0.466203685, 0.43236573), and the total momentum is 0.

    1. Those long decimals look arbitrary. Square them and add, and they are not: bodies 1 and 2 each sit exactly 1 unit from the origin, which is where body 3 is.

    2. Body 2 is body 1 reflected through the origin, so at this instant all 3 bodies lie on a single straight line with body 3 at its midpoint. Every separation follows from that, with no second square root.

    3. Newton's law now needs nothing but those separations. Body 3 is 1 unit from each of the others, while bodies 1 and 2 are twice as far apart, so the pull between them is weaker by a factor of 4.

    4. Spend the collinearity. Body 3 is pulled equally in opposite directions, so its net force vanishes exactly. Bodies 1 and 2 are pulled the same way by both partners, because body 3 sits between them, so their 2 forces add as plain numbers with no components to resolve.

    5. Zero total momentum, plus bodies 1 and 2 moving identically, pins body 3's velocity at βˆ’2v1. That makes its kinetic energy 4 times theirs, and the sum over all 3 collapses to a single term.

    6. Squaring the 2 components of v1 and tripling is the whole of the kinetic-energy calculation for 3 bodies.

    7. Potential energy needs no vectors either β€” just the reciprocals of the 3 separations, and with Ξ΅ = 0 those reciprocals are exact.

    Answer

    E = βˆ’1.2871, and every row of the panel's t = 0 table β€” separations, pair forces, net forces, both energies and the total β€” came out of those 4 decimals and the vanishing of the total momentum. Watch what happens to the parts: by t = 25.0 the kinetic energy has climbed to 1.305 and the potential has fallen to βˆ’2.592, and the total has not moved. The sign is what carries a consequence. A bound trio can still lose a member, but not for free: if 1 body drifts away with nothing to spare, the pair left behind has to hold the entire βˆ’1.2871, and 2 unit masses with that energy have a semi-major axis of 1/(2 Γ— 1.2871) = 0.3885 β€” under 1/5 of the 2.0000 that separates them now. Ejection and hardening are the same event, and the energy budget is why.

References (1)

Example problems

  • figure-8 orbit - Three equal masses chase each other around a single figure of eight, every one of them tracing the same closed path. Orbits that come back to where they started are so rare among three-body solutions that the known ones are named individually.
  • near collision - Two of the bodies pass close enough that, for a moment, they feel each other far more than they feel the third. Close approaches are where the chaos is manufactured: the nearer the miss, the harder a tiny difference in the starting point is amplified on the way out.
  • pythagorean - Masses of three, four and five at the corners of a right triangle, all released from rest. They fall inward, scramble for a long while, and the lightest is eventually thrown clear while the other two settle into a pair. The ending is not visible from the first half.
  • butterfly orbit - Three equal masses on one closed loop shaped like a pair of wings. The outer two set off with identical velocities and the middle one exactly cancels them, which is what keeps the whole figure from drifting off the screen while it draws.
  • Euler collinear - Three masses in a straight line, turning about their common centre and staying in line for ever. This is the arrangement the Lagrange points on the Sun-Earth axis come from, so the James Webb telescope is parked inside a solution to this problem.
  • binary + intruder - A tight pair meets a lighter body falling in from the right. Usually the intruder leaves faster than it arrived and the pair draws closer together, because the energy it carries off came out of the binary’s own binding. Globular clusters stay puffed up on exactly this.