Resonance (outer : inner period)
Playback
Orbits
Model checks
The science
Kepler's third law and resonance
Both planets move under the star's gravity with a = −GM r / |r|³ and are advanced by a symplectic leapfrog step. The period grows as T = 2π √(a³/GM), so a period ratio Tout : Tin = p : q needs aout = ain (p/q)2/3. In a p:q resonance the planets line up (conjunction) again after the synodic period Tsyn = Tin Tout / (Tout − Tin), and successive conjunctions fall at only a few fixed longitudes: a pattern, not a random walk.
Conserved quantities
Energy E = ∑ (½ m v² − GM m / r) − G m1m2/r12 and angular momentum L = ∑ m r × v about the star are conserved. The readouts show their relative drift; the leapfrog scheme keeps it tiny.
Honest simplifications: the star is held fixed, planet masses are tiny (the Planet mass slider sets the mutual pull, default 0.001 of the star so the resonance stays visibly locked), no tides, relativity or other bodies. Real resonant locking (Neptune-Pluto, Jupiter's moons) depends on slow secular exchange that this short demo only hints at. Sizes and distances are not to scale.
What to try
- Set Planet mass to 0: the orbits are exact Kepler ellipses and conjunctions land on exactly p fixed spots.
- Raise Planet mass to 0.02 and watch the conjunction longitudes drift.
- Raise eccentricity to 0.3 in a 3:2 resonance: the conjunctions cluster away from the planets' close approach.