Differential equations · CMNA Laboratory

Turn a derivative into a trajectory.

Euler trusts one slope. Midpoint samples again halfway through the step. Fourth-order Runge-Kutta asks four questions before deciding where to land.

One differential equation, three stepping rules

Give the laboratory any R function f(x,y) describing (y' = f(x,y)). The three CMNA methods start from the same initial condition and step size, so their different trajectories come entirely from how much slope information each method uses.

Bring your own ODE

Write the derivative in R.

Then watch three numerical methods advance the same initial value problem.

RuntimePreparing R…
RDefine f(x,y)
EulerMidpointRK4

stepxys₁s₂s₃s₄next y
Book§7.1.1–7.1.2 · Euler and Runge-Kutta Methods · pp. 200–208Book details
CMNA packageeulermidptivprungekutta4
TeachingInstructor notes and chapter contextOpen teaching material
Numerical ZooWorked problems