anthropocene
Computational Physics
← Computational Physics

ODE Solvers, One by One

Given the slope everywhere, how do you find the path?

Every integrator here is a different answer to one question: you know f, and you want y. We build them in order - Euler, Heun, RK4, then implicit methods - and each one exists because the previous one failed in a specific, reproducible way you will have seen for yourself.

01Forward Euler, and why it is not enoughcore25 min

The simplest possible integrator. Worth studying not because you will use it, but because every failure mode of every later method is already visible here in its purest form.

02RK4, and where the magic numbers come fromcore30 min

Four slope samples per step, weighted 1-2-2-1, and suddenly the error falls as the fourth power. The coefficients are not arbitrary — they are what you get when you demand that error terms cancel.

03Stiffness, and evaluating the slope where you are goingadvanced30 min

When the fastest mode in the system forces a step size thousands of times smaller than accuracy needs. The fix costs a nonlinear solve per step and is worth it.

04Letting the solver choose the stepadvanced25 min

Fixed steps waste effort where the solution is smooth and under-resolve where it is not. Estimate the local error each step and resize.