Making Physics / Mechanics / Kepler Orbits
Chapter 04

Kepler Orbits

How does a body move under inverse-square gravity, and which integrators keep the orbit closed?

Interactive · live simulation

Drag from the planet to aim and size its launch velocity, then release. Toggle the integrator: explicit Euler bleeds energy and spirals out, while velocity-Verlet keeps the orbit closed.

Kepler Orbits — simulation render
fig 1. Circular and elliptical orbits under a fixed central mass. Explicit Euler spirals outward as it leaks energy; velocity-Verlet keeps the ellipse closed over many periods.

One constant, two invariants

The orbiting body needs only \mu = GM. A central force conserves angular momentum, and a time-independent potential conserves energy — so any drift in either is pure numerical error. From the specific energy and angular momentum the lab reads back the semi-major axis, eccentricity, and period analytically.

Energy and angular momentum traces. Verlet oscillates within a bounded band; exp
fig 2. Energy and angular momentum traces. Verlet oscillates within a bounded band; explicit Euler drifts monotonically — the visible cost of a non-symplectic step on a Hamiltonian system.

Why Velocity-Verlet

Hamiltonian flow preserves a geometric structure (the symplectic form). A symplectic integrator preserves it too: energy then oscillates around the true value with no long-term drift, because the method exactly conserves a slightly perturbed "shadow" Hamiltonian. Explicit Euler and even RK4 have no such guarantee and drift over long horizons.

See it spiral

Run an ellipse with explicit Euler and it spirals outward — energy climbing — within a few orbits. Switch to velocity-Verlet (kick-drift-kick) and the same ellipse closes on itself indefinitely. Push the launch speed to \sqrt2 at r=1 and the orbit opens into a parabolic escape.

This chapter is drawn from the physics-lab study notes and renders. The longer write-ups and project essays live on the blog.

Read more on the blog →