Astrophysics · Mathematics
📅 July 2026 ⏱ ≈ 9 min read 🎯 Intermediate

The Two-Body Problem: the Analytic Solution

Two gravitating bodies can be solved exactly, in closed form, for all time — no numerical integration required. Add a third body and that exact solution vanishes forever. This is why the two-body problem is the one clean island in an ocean of chaotic N-body dynamics.

TL;DR: Two orbiting bodies reduce exactly to one body (mass μ = m₁+m₂) orbiting a fixed point, via reduced mass and a single relative-motion equation — no approximation needed. Splitting that relative orbit by mass ratio recovers each body's real path around the shared barycentre. Add a third body and this exact reduction fails permanently, forcing numerical simulation instead.

1. Why N-body gravity is hard, and two bodies aren't

Newton's law of gravitation is simple to write down for any number of bodies — each pair attracts each other with a force proportional to G·m₁·m₂/r². The trouble is solving the resulting system of differential equations. For three or more mutually gravitating bodies, no general closed-form solution exists — this is the famous three-body problem, proven by Poincaré in 1889 to be non-integrable in the general case. That's exactly why simulations like N-body gravity exist: when there's no formula, you step forward numerically instead.

Two bodies are the one exception. With only two masses, the problem can be reduced to something we already know how to solve: a single body orbiting a fixed centre — exactly the Kepler problem from the orbital-mechanics article.

2. The reduction: from two bodies to one

Let two bodies of mass m₁ and m₂ have position vectors r₁ and r₂. Newton's second law and law of gravitation give two coupled vector equations:

m₁ · r̈₁ = G·m₁·m₂ · (r₂ − r₁) / |r₂ − r₁|³
m₂ · r̈₂ = G·m₁·m₂ · (r₁ − r₂) / |r₁ − r₂|³

Define the relative position r = r₂ − r₁. Dividing each equation by its mass and subtracting the first from the second collapses both equations into one:

r̈ = −G(m₁ + m₂) · r / |r|³ ← identical in form to a single body orbiting a fixed mass M = m₁+m₂

This is the entire trick: the relative separation vector r behaves exactly like a test particle orbiting a fixed centre with combined mass m₁ + m₂. Every tool from the Kepler problem — ellipses, the vis-viva equation, Kepler's equation — applies unchanged.

3. Reduced mass μ

A more formal (and more general, extending cleanly to other two-body force problems) way to reach the same result uses the reduced mass:

μ_red = (m₁ · m₂) / (m₁ + m₂) ← NOT the gravitational parameter μ = GM used elsewhere

The two-body Lagrangian separates cleanly into centre-of-mass motion (trivial — it moves at constant velocity or stays fixed) plus relative motion of a fictitious particle of mass μ_red at position r in the potential −G·m₁·m₂/r. This split — one easy piece, one Kepler piece — is why the two-body problem is called integrable.

Sanity check: when m₂ ≪ m₁ (e.g. Earth around the Sun), μ_red → m₂ and the combined mass m₁ + m₂ → m₁ — recovering exactly the fixed-Sun approximation used in the 50-line orbit tutorial.

4. The relative-motion equation

With μ = G(m₁ + m₂) as the gravitational parameter of the combined system, the relative orbit obeys the identical Kepler machinery: it traces a conic section (ellipse, parabola or hyperbola depending on total energy) with

r(ν) = a(1 − e²) / (1 + e·cos ν) ← same polar ellipse equation as the single-body Kepler orbit

T² = 4π² · a³ / [G(m₁ + m₂)] ← Kepler's third law, now with BOTH masses in the denominator

This last line is the crucial correction over the single-body Kepler problem: the period depends on the sum of both masses, not just the central one. For a star system this matters — a binary of two Sun-mass stars orbits faster at a given separation than a planet would around one Sun-mass star alone, because μ doubles.

5. Reconstructing each real orbit

Solving for r(t) gives the relative separation, not the actual paths of the two bodies. To recover each body's real position around the shared barycentre (centre of mass), split r in inverse proportion to mass:

r₁ = −(m₂ / (m₁+m₂)) · r ← body 1's position relative to the barycentre
r₂ = +(m₁ / (m₁+m₂)) · r ← body 2's position relative to the barycentre

Both bodies trace similar ellipses (same eccentricity, same orientation, same period) around the barycentre, but scaled by the opposite mass fraction — the heavier body traces the smaller ellipse. This is exactly what the binary-star simulation renders: two stars swinging around a shared, usually invisible, point.

// Given relative separation r = {x, y} from solving the Kepler orbit
// with mu = G*(m1 + m2):
const f1 = m2 / (m1 + m2);
const f2 = m1 / (m1 + m2);
const r1 = { x: -f1 * r.x, y: -f1 * r.y };  // heavier body → smaller orbit
const r2 = { x:  f2 * r.x, y:  f2 * r.y };  // lighter body → bigger orbit
Equal-mass case: if m1 = m2, then f1 = f2 = 0.5 — both stars trace identical ellipses, always diametrically opposite each other across the barycentre.

6. The barycentre and centre-of-mass frame

The centre-of-mass position itself,

R_cm = (m₁·r₁ + m₂·r₂) / (m₁ + m₂)

moves at constant velocity (or stays fixed, in the frame most simulations use) because there are no external forces on the two-body system — Newton's third law makes the two internal gravitational forces exactly cancel in the sum. This is why we can split the problem into "boring" centre-of-mass motion plus "interesting" relative motion without losing any information: the two pieces are completely independent.

QuantityFormulaBehaviour
Centre of massR_cmConstant velocity — no dynamics
Relative separationr = r₂ − r₁Kepler ellipse, μ = G(m₁+m₂)
Body 1 orbitr₁ = R_cm − (m₂/M)·rScaled ellipse, mass fraction m₂/M
Body 2 orbitr₂ = R_cm + (m₁/M)·rScaled ellipse, mass fraction m₁/M

7. Why three bodies break everything

The trick that made two bodies solvable — subtracting the two equations of motion to get one clean relative equation — simply doesn't work with three bodies. Each body now feels two separate, non-parallel gravitational pulls, and no algebraic substitution collapses the system back down to a single two-body-like equation. The general three-body problem has no closed-form solution in elementary functions; only special symmetric cases (like the restricted three-body problem used for Lagrange points and Hill spheres) admit partial analytic treatment, and even those require numerical root-finding for exact equilibrium positions.

In practice: the moment a simulation needs a third mutually-interacting mass — a moon perturbing a planet, a third star in a system, an asteroid near Jupiter — the exact two-body formulas above stop being sufficient, and you need a numerical integrator like the velocity-Verlet method or full N-body simulation.

⭐ Binary Stars simulation

Watch two stars trace their scaled ellipses around a shared barycentre in real time.

Open simulation →

🔗 Related Simulations

☀️Solar System Binary Stars ☄️N-Body 🌑Orbital Mechanics