N-Body Simulation vs Restricted Three-Body Problem: What's the Difference?
The N-body simulator computes full Newtonian gravity between every pair of bodies and lets you add as many as you like. The restricted three-body problem is a special, simplified case — two massive primaries plus one massless test particle — viewed in a rotating frame to expose Lagrange points and Roche lobes.
🧪 Try both simulations
⚡ Quick answer
The N-body simulator computes full Newtonian gravity between every pair of bodies (an O(n²) sum), letting you add any number of massive bodies — solar systems, binary stars, galaxy collisions, the figure-8 orbit — and integrates their motion with RK4 in a fixed inertial frame. The restricted three-body problem is a special, more constrained case: exactly two massive primaries orbit their common barycentre, and a third, massless test particle moves in their combined field without affecting them. That simulation is viewed in a rotating (corotating) frame, which turns the moving primaries into two fixed points and reveals five equilibrium Lagrange points (L1-L5), Roche lobes, and zero-velocity curves bounded by the conserved Jacobi constant.
📊 N-Body Gravitational Simulation vs Restricted Three-Body Problem
| N-Body Simulation | Restricted Three-Body Problem | |
|---|---|---|
| Number of massive bodies | Unlimited — click to add bodies, or load solar system (5), binary (2+1), figure-8 (3) or random-cloud presets | Exactly two — the "primaries" (masses 1−μ and μ), plus one massless test particle that doesn't affect them |
| Reference frame | Fixed inertial frame — every body's absolute position and velocity is tracked directly | Corotating (rotating) frame — the two primaries appear stationary, revealing centrifugal and Coriolis effects in the effective potential |
| Gravitational coupling | Full pairwise sum: every body pulls on every other body simultaneously (O(n²) per frame) | One-way: the two primaries pull on the test particle, but the particle's negligible mass means it can never pull back on them |
| Integration method | Fourth-order Runge–Kutta (RK4), with adjustable softening ε to tame close-encounter singularities | RK4 in the rotating frame, with the conserved Jacobi integral C_J = 2U*−v² used to check accuracy live |
| Signature feature drawn | Coloured trails showing each body's path — orbital resonances, slingshot deflections, collisions | Shaded Roche equipotential bands, a highlighted zero-velocity curve, and five marked Lagrange points L1-L5 |
| Adjustable parameters | New body mass, G (gravity strength), dt (time step), trail length, softening ε | Mass ratio μ, Jacobi constant C_J, trail length, step size |
| Real-world examples it maps to | Solar systems, binary star pairs, galaxy mergers, the numerically-discovered figure-8 three-body orbit | Trojan asteroids at Jupiter's L4/L5, JWST's halo orbit at Sun-Earth L2, Roche-lobe mass transfer in binary stars and X-ray binaries |
| Best for learning | Why gravity has no general closed-form solution beyond two bodies, and how RK4 out-performs simple Euler stepping | Why the three-body problem is chaotic near L1-L3, and how a rotating frame turns orbital motion into a static potential landscape |
The N-body simulator on this site is the general case: click anywhere to drop in a new body, and every body in the scene exerts Newtonian gravity F = G·mᵢ·mⱼ/r² on every other body, all summed together each frame. There is no upper limit on how many bodies you add, and no restriction on their masses — load the five-body Solar preset, a Binary pair with a light third body, the exact Figure-8 orbit (numerically discovered in 1993, proven to exist by Chenciner and Montgomery in 2000), or a Random cloud, and watch RK4 integration advance every position and velocity with far less energy drift than simple Euler stepping. A softening parameter ε keeps the 1/r² force from blowing up during close encounters. This generality comes at a cost: because even three mutually-gravitating bodies have no algebraic solution (Poincaré proved this in the 1890s), the only way to see what happens is to integrate step by step, and outcomes are highly sensitive to starting conditions.
The restricted three-body problem trades that generality for tractability and insight. It fixes the awkward part — three mutually-interacting masses — by making the third body massless, so it can never perturb the two "primaries" that orbit their common barycentre in perfect circles. Switching to a frame that rotates along with those primaries turns them into two fixed points, and the combined gravitational-plus-centrifugal "effective potential" U* has exactly five equilibrium positions: the unstable collinear points L1, L2, L3, and the stable triangular points L4 and L5. The conserved Jacobi constant C_J = 2U*−v² draws a zero-velocity curve the particle can never cross, whose shape directly explains Roche-lobe overflow in binary stars — the mechanism behind novae and Type Ia supernovae — as well as why JWST parks in a halo orbit around Sun-Earth L2 rather than sitting exactly on the unstable point itself.
Want to explore more? Browse the full library of 1000+ interactive, browser-based simulations, or see other side-by-side comparisons.