Apps Part of Proofline

N-Body & Three-Body Orbit Simulator

Three-body periodic orbits and your own planar n-body systems, with an energy-drift report.

One body per line: an optional name, then mass, x, y, vx and vy (G = 1 units unless you change G). At most 12 bodies. Used when “My own bodies” is selected.

More options

Empty: one period for the periodic presets, 70 for the Pythagorean problem, 10 for your own bodies.

Relative error per step of the adaptive method.

Empty: the period (or the duration) divided by 20,000.

Plummer softening ε: the force uses r² + ε², which tames close encounters but changes the physics slightly.

Try an example: · · · ·

More about this tool

How it works

Simulate point masses under Newtonian gravity in a plane: published three-body periodic orbits (figure-eight, butterflies, moths, yin-yang and more from Šuvakov & Dmitrašinović 2013 and the 10-digit refinements of Li & Liao 2017), Lagrange’s triangle, the chaotic Pythagorean problem, or up to 12 bodies of your own. Choose an adaptive Dormand–Prince RK45 or a symplectic Verlet or Yoshida integrator and get the orbit plot, the energy, momentum and angular-momentum drift, the closest approach and how far a periodic orbit is from its start after each full period. Part of the Proofline math notebook.

  • Each body feels a = Σ G·mⱼ·(rⱼ − rᵢ)/(|rⱼ − rᵢ|² + ε²)^{3/2} from all others (pairwise, O(n²)); positions and velocities form one state vector.
  • RK45 is the numerical engine’s Dormand–Prince 5(4) with adaptive steps (relative tolerance as set, absolute tolerance 100× smaller). Velocity Verlet (kick–drift–kick) and Yoshida’s fourth-order composition of three Verlet steps (weights 1/(2 − 2^{1/3}) and −2^{1/3}/(2 − 2^{1/3})) are symplectic: their energy error stays bounded instead of drifting, as long as the step resolves the closest approaches.
  • Conservation checks: total energy E = Σ ½mv² − Σ G·mᵢmⱼ/r, momentum and angular momentum are compared with their initial values at every output point. For periodic presets the step is aligned with the period and the phase-space distance |state(k·T) − state(0)| is reported for each whole period.
  • Verified: the Chenciner–Montgomery figure-eight returns to within 1e-7 after one period; the 10-digit Li–Liao orbits close to about 1e-8; the 5-digit Šuvakov–Dmitrašinović values close to about 1e-3, as their precision allows; Lagrange’s triangle rotates rigidly; and in the Pythagorean problem the lightest body (m = 3) escapes while the other two form a binary, as Szebehely and Peters found.

A teaching and exploration tool: planar point masses only (no collisions, no relativity, no tides). Chaotic systems amplify every rounding error, so long runs show one possible future, not the future.

Sources

Part of Proofline

Related tools

Simulate three-body orbits and check the energy drift

Run published periodic three-body orbits or your own planets with an adaptive or symplectic integrator and see how well energy is conserved and whether the orbit closes.

What it is for

Three bodies pulling on each other have no general formula for their motion, but some special starting conditions give orbits that repeat exactly. This tool integrates Newton's law of gravity in the plane for up to 12 bodies and tells you how trustworthy the run is.

You can pick a preset or enter your own bodies. The presets are the equal-mass periodic orbits published by Šuvakov and Dmitrašinović in 2013 (butterfly, moth, bumblebee, goggles, dragonfly, yarn, yin-yang), refined family members from Li and Liao (2017) with ten digits, the figure-eight of Chenciner and Montgomery, the Lagrange triangle and Burrau's Pythagorean problem. Units are G = 1 unless you change Gravitational constant G.

Three integrators are available: Dormand–Prince RK45 with an adaptive step, the fourth-order symplectic method of Yoshida, and velocity Verlet. The report gives the energy, momentum and angular momentum drift, the closest approach and, for periodic presets, how far the system is from its starting state after each period. The same engine runs in the Sim Gallery of Proofline, where the orbits are animated.

Worked example

Choose the figure-eight preset and leave everything else. RK45 at tolerance 1e-11 takes 1093 steps over one period of 6.32591398 time units. The largest relative energy error is 1.47e-11, and the three bodies end 7.56e-8 away from where they started in phase space. The closest approach of two bodies is 0.6905.

Switch Integrator to Yoshida: with 20,000 fixed steps the energy error drops to 4.5e-14, but the return distance stays at 7.54e-8. That remaining gap comes from the eight-digit initial conditions, not from the integrator. Velocity Verlet with the same steps gives an energy error of 5.9e-8.

The refined butterfly (I.A.2) from Li and Liao closes to 9.35e-9 after a period of 6.239930361, although two bodies come as close as 0.011. The five-digit moth I, run with Yoshida at step 0.0002, misses by 3.6e-4, and the tool warns that published five-digit orbits drift apart after a few periods.

How to read the result

Largest relative energy error is the biggest |E − E₀|/|E₀| along the run. Below about 1e-8 the trajectory is numerically sound; a sudden jump usually marks a close encounter. Distance from the start after one period measures how well a periodic orbit closes. Closest approach warns you about near-collisions, where fixed-step methods fail.

The tables list the initial conditions and the final state; the CSV download has the sampled positions and the energy error over time.

Tips and common mistakes

  • Enter custom bodies one per line as name, mass, x, y, vx, vy. The name is optional.
  • Use RK45 for close encounters, such as the Pythagorean problem: the fixed-step methods step straight through them and the energy error explodes.
  • Use Yoshida for long, smooth runs; its energy error stays bounded instead of growing.
  • Softening length above zero removes the singularity at close range, but it changes the physics. Keep it at zero for the published orbits.
  • Leaving Duration empty runs exactly one period for periodic presets.

FAQ

Why does a periodic orbit not close exactly?

The published initial conditions are rounded, and periodic three-body orbits are unstable. Small errors grow every period.

What does the Pythagorean problem show?

Masses 3, 4 and 5 start at rest on a 3-4-5 triangle. After 70 time units of chaotic encounters, two bodies leave as a binary while the lightest one escapes. The closest approach is 0.00041.

Is this a real solar system simulator?

No. It is planar Newtonian gravity without relativity, tides or real ephemerides.

Can I use SI units?

Yes. Set G to 6.674e-11 and enter masses in kg, positions in m and velocities in m/s.

Guide last updated:

For scripts and AI agents

  • JSON API: POST https://prooflinenbody.usefulweb.app/api/v1/calculate (same calculation as this page)
  • Interface description: OpenAPI 3.1 · AI guide: llms.txt
  • MCP server (Streamable HTTP): https://prooflinenbody.usefulweb.app/mcp · tool name proofline_nbody
Example request
curl -s -X POST https://prooflinenbody.usefulweb.app/api/v1/calculate \
  -H 'content-type: application/json' \
  -d '{"preset":"figure-eight"}'
Feedback · ideas & bug reports welcome