ODE Solver Comparison

Error scaling of Euler, RK2, and RK4 integrators

Settings

Final Errors

Euler (O(h)):
Heun/RK2 (O(h²)):
RK4 (O(h⁴)):

Legend

Exact
Euler
Heun (RK2)
RK4

Bottom: error vs h on log-log axes. Slopes reveal order.

About

Global error of Euler = O(h), Heun = O(h²), RK4 = O(h⁴). On a log-log plot of error vs h, the slopes are 1, 2, 4. RK4 uses 4 function evaluations per step — an excellent tradeoff between cost and accuracy.