Orbital precession (GR) — live canvas animation example

motion & easing8+
trig, angles & vectors8+
collision detection11+
numbers in motion7+
geometry & shapes8+
generative showpieces13-
handy helpers7+
GR ε:800speed:4
🪐 Orbital Precession — What's going on? Newton's law of gravity predicts that a planet in a two-body system traces a perfect, closed ellipse — the same ellipse, forever. This is exactly right for a simple sun + one planet system. But Mercury doesn't do this. Its orbit slowly rotates. The axis of Mercury's ellipse drifts by 575 arcseconds per century. Most of that (532") is explained by the gravitational pull of other planets. The remaining 43 arcseconds per century stumped astronomers for 50 years. Einstein's general relativity explained those 43 arcseconds exactly. It was one of the first experimental confirmations of the theory. WHY DOES GR CAUSE PRECESSION? In Newtonian gravity, the force falls off as exactly 1/r². This produces a perfectly closed orbit (Bertrand's theorem). General relativity adds a tiny extra attractive term: F_GR = GM/r² + 3GML²/(c²r⁴) The extra term is strongest at periapsis (closest approach), where r is smallest. It gives the planet a slightly stronger "slingshot" than Newtonian physics predicts, so the orbit overshoots closure by a small angle each revolution. That small angle accumulates over centuries into the measurable drift called perihelion precession. THE SIMULATION This animation integrates two planets from identical starting conditions: BLUE — Newtonian gravity: F = GM/r² (orbit closes perfectly) GOLD — GR gravity: F = GM/r² · (1 + ε/r²) The ε slider exaggerates the GR correction so it's visible in seconds rather than centuries. You can watch the gold ellipse slowly rotate while the blue ellipse stays fixed. The algorithm is Euler integration: a = −F/m · r_hat (acceleration toward sun) v += a · dt (update velocity) pos += v · dt (update position) Run multiple steps per frame for a stable, smooth orbit. CONTROLS • GR ε — size of the relativistic correction (0 = pure Newton) • speed — integration steps per frame • reset — return both planets to their starting positions