This simulation needs WebAssembly, and it could not start in this browser.
The image is a frame from a real run. Check that JavaScript is on, or try another browser.
Three bodies under gravity have no general closed-form solution, and most starting conditions end in chaos, with one body thrown out sooner or later. This page collects starts that behave differently: a periodic orbit, an exact solution that does not survive, and a hierarchical system that holds together. All use and unit masses unless noted.
What you see
Three bodies, labeled Body A, B and C and drawn in red, teal and yellow, leave pale trails behind them. Arrows on a grid show the gravitational field; switch them off with Force field. Each preset sets its own time step, softening and zoom, and every start is shifted into the center-of-mass frame, with zero total momentum, so the center of mass stays at the center of the view. Without a preset, the page starts with the figure-eight.
Governing equation
The softening length removes the singularity at zero distance. Energy, momentum and angular momentum are conserved, and the default leapfrog integrator keeps the energy error bounded.
Presets
Figure-8: the choreography that Cristopher Moore found numerically in 1993 and Alain Chenciner and Richard Montgomery proved to exist in 2000. Bodies A and B start at and , both with velocity ; Body C starts at the origin with , so the total momentum is zero. The three masses then chase each other around one figure-eight curve, a third of a period apart, with period . The orbit is linearly stable and keeps its shape over many periods.
Lagrange triangle: three equal masses at the corners of an equilateral triangle of side , each moving at speed so that the triangle rotates rigidly. Lagrange showed in 1772 that this is an exact solution for any three masses. Gascheau found in 1843 that it is linearly stable only if , which requires one body to dominate; for equal masses the left side is 81 and the right side 9. The rounding of the starting values is enough to break it: within two or three turns the triangle distorts, and the bodies fall into a chaotic exchange.
Figure-8, chaotic: the figure-eight start with Body C made 50 percent heavier (mass 1.5). Within about one period a close encounter flings the bodies apart. The view is zoomed out to 3 units from the center.
The two chaotic presets, Lagrange triangle and Figure-8, chaotic, run with , 32 substeps per frame and . Their bodies pass very close to each other, and with a coarser step or a smaller softening the integrator cannot follow those passes: the total energy jumps at each one, and bodies fly apart on energy the simulation made up. At these settings the energy stays within half a percent, so the exchanges and ejections are the system’s own.
Hierarchical triple: a tight binary, two unit masses 0.4 apart on a circular orbit, with a third unit mass starting 3 units away. The outer body moves on an eccentric orbit while the inner pair goes round about ten times per outer orbit, and the wide separation keeps both orbits intact. Stable triple stars in nature are built like this.
Perturbed figure-8 (stable): the figure-eight with Body A moved 0.001 to the right. In a chaotic orbit such an offset would grow exponentially, with a positive Lyapunov exponent . The figure-eight is linearly stable, so the offset stays small and the curve only wobbles around the original; compare Figure-8, chaotic, where the disturbance is large.
Parameters
Time step dt: the integration step, 0.0005 to 0.04 (default 0.005); the presets use 0.001 to 0.005. Steps per frame (1 to 32, default 8) is the number of steps per drawn frame.
Integrator: leapfrog (velocity Verlet) by default; yoshida4, rk4, rk2 and euler are the alternatives. Close encounters need small steps with any of them.
Softening ε: default ; Hierarchical triple uses , Lagrange triangle and Figure-8, chaotic 0.1.
The other controls change only the drawing: trails, labels, the center-of-mass marker, a view locked to the center of mass, velocity arrows and the field overlays.