Euler Walks One Slope-Step at a Time
A differential equation tells you, at every point, which way and how fast things change — the slope. It is the very field of slopes you met in the direction-fields lesson. The trouble is that most differential equations have no clean formula solution. So how do you solve one? Euler's answer is almost crudely simple. Read the slope where you are, walk one short step (h) straight in that direction, read the slope again at the new point, and step once more. Repeat, and you trace the solution curve as a chain of little line segments. Shorter steps land closer to the true solution but cost more steps to compute. Accuracy versus cost, in a tug of war. This one-line idea is the starting point of nearly every simulation, from weather forecasts to game physics engines to rocket trajectories.
The gray ticks are the direction field — the slope the differential equation assigns at each point. Here the equation is y'=y, growing in proportion to its own value, so the ticks steepen as you go up. Euler takes one straight step along a tick from the start, reads the tick again where it lands, steps once more, and so on, drawing a chain of segments. The true solution is ex (the gray curve). Shrink the step h and the dots crowd together while the chain clings to the curve. Enlarge h and the dots thin out and the chain sags below the curve, because straight pieces cannot keep up with the way the curve bends upward.
Take just the endpoint of the same equation. The gray dot is the true value e³≈20.1; the gold dot is where Euler lands. The red bar between them is the accumulated (global) error. Drag the h slider up and the bar and the number shoot up in real time. This is the explosion of truncation error: at every step the straight line misses the curve by a little, and those little errors pile up step by step into a large gap at the end. Conversely, halve h and the error roughly halves too, because Euler is first-order accurate — its error is proportional to h. The fuller the bar below, the louder the warning.
This time the equation is y'=cos x, whose true solution is sin x. Because the solution oscillates, Euler's weakness shows clearly. With a large h the gold chain inflates the peaks above the gray sine curve and its phase lags a little. Follow the oscillation over one period, then two, and the mismatch accumulates. Shrink h and the two curves gradually overlap. The lesson here is that the same method shows error differently depending on the character of the solution. A solution that bends fast and oscillates needs small steps more urgently than one that grows smoothly.
Now the truly scary case. The equation is y'=−ky, whose true solution is a decay that fades smoothly to 0. Euler multiplies y by (1−hk) at each step. But once h·k exceeds 2, the absolute value of that factor passes 1, so even though the true solution heads to 0, the numerical solution flips sign and grows larger and larger. That is blow-up. Between 1 and 2 it oscillates while fading; below 1 it decays tamely. This is not an accuracy problem but a stability problem. It means shrinking the step is not only about precision; it is also a safety catch that prevents divergence. This matters especially for stiff equations.
Is there a smarter step rather than just a smaller one? Yes. Euler trusts only the slope at the start and marches straight. RK2 (the midpoint method) first goes halfway, samples the slope again at the midpoint, and takes a full step using that better slope. The cost doubles, but the accuracy jumps. Compare gold (Euler) and blue (RK2) at the same h: blue hugs the true ex far more closely. Euler's error is proportional to h (first order), while RK2's is proportional to h² (second order), so halving the step cuts the error to a quarter. RK4, the workaday standard, uses this idea four times to reach h⁴ accuracy. The next lesson shows the same principle at work in integration.