Loading...
Loading...
Differential Equations · Axiom Academy
One slope can mislead you. Watch what happens when a method samples the slope four times before it commits to a step. Same step size, two very different answers For the equation with y(0)=1 (true solution y=e^ -x^2/2 ), Euler's method takes one slope reading per step and walks in a straight line. Watch it fall away from the true curve — then watch RK4, using the same step size, stay locked on. Press play: the blue path is Euler (one slope sample per step, h=0.5 ). The green path is RK4 (four slope samples per step, same h=0.5 ). Both start from the same point. At the last step ( x=2.5 ), Euler's error is about 0.044 — RK4's is about 0.002, roughly 22× smaller, using the exact same step size. Walk through the four samples yourself Slide through RK4's four slope samples for the step from with h=0.8 : k_1=f(x_0,y_0) at the start; and , both at the midpoint but using different slope estimates to get there; at the end. The midpoint samples k_2,k_3 count double because they're the best single-point guess at how the slope behaves across the whole step — that 1:2:2:1 pattern is what makes RK4 fourth-order accurate. Shrink the step size — watch the errors fall at different rates Both methods integrate the same equation from x=0 to x=2 . Drag the step-size slider h down: Euler's error drops roughly in proportion to h itself, but RK4's error drops in proportion to h^4 — halving h shrinks Euler's error by about 2×, but shrinks RK4's error by about 16×.
This is the written version of the interactive lesson above. See the full Differential Equations course.