Brief
Newton's law of gravity gives the acceleration of every planet from where all the others are:
That is an ordinary differential equation (ODE): the rate of change of the state, here all positions and velocities, is a function of the state. With more than two bodies there is no formula for the answer, so you step forward in time.
Euler's method is the simplest step, . It follows the current velocity in a straight line for a time . On a curved orbit, a straight line always ends up a little too far out, so Earth spirals away and its energy drifts. RK4 samples the slope four times per step (at the start, twice at the midpoint, and at the end) and combines them: .
Stepping an ODE forward is a kind of integration. If the slope depends only on time, Euler becomes the left-rectangle rule and RK4 becomes Simpson's rule. That's why the project starts with quadrature: the error orders you measure there, , and , are the same ones you'll see again in the orbits.
DATA · planet positions from public ephemeris tables
Objectives
Read-only. Log in to update progress.
VICTORY CONDITIONS
- Over 100 years, your RK4 energy drift is no larger than that of `scipy.integrate.solve_ivp` on the same system, with its settings stated. Record both with `python tools/mlarena.py record BM-20 "<RK4 drift> vs <solve_ivp drift>"`.
- A log-log plot shows Euler's drift shrinking like h and RK4's like h⁴.
- The README has a plot or animation of the eight orbits over 100 years.
Side quests
Terms in plain words
- ODE (ordinary differential equation)
- A rule that gives the rate of change of a state from the state itself, like y′ = f(t, y). Simulating it means stepping forward in time.
- Euler's method
- y_next = y + h·f(t, y): follow the current slope for one step. Its error over a fixed time span shrinks like h.
- RK4
- The classic Runge–Kutta method. It samples the slope four times per step and averages them with weights 1, 2, 2, 1. Its error shrinks like h⁴.
- Quadrature
- Numerical integration of a function, for example with the trapezoid rule or Simpson's rule.
- Energy drift
- How far the total energy (kinetic plus potential) wanders from its starting value. Real gravity conserves energy, so drift measures the integrator's error.