seegongsik
engineering mathematics

Euler method ODE explained

Step straight along a differential equation's slope; a big step makes the error explode

A differential equation tells, at every point, which way things change and how fast. That is the slope map of a direction field. Most differential equations have no tidy closed-form solution. Euler's method is plain. Read the slope where you are, walk a short straight step (h) in that direction, then read the slope again at the new point and take another step. Repeat this and the solution curve is drawn as a polyline. A shorter step stays closer to the true solution, but there are more steps and the cost rises. Accuracy and cost pull against each other. This one line is where almost every simulation starts, from a weather forecast to game physics to a rocket trajectory. The slider in the pictures chooses that step length. Denser points mean the polyline stays closer to the true curve, and a long step is cheaper only until the line sags away from the truth.

The gray ticks are the direction field. Each one is the slope the differential equation assigns at that point. Here the equation is y'=y, growth proportional to the value itself, so the ticks get steeper as you go up. Euler takes one straight step along the tick at the start, reads the tick at the arrival, and takes another step, drawing a polyline. The true solution is the gray curve ex. Shrink the step h and the points get dense and the polyline hugs the curve. Grow h and there are fewer points and the polyline sags below the curve. A straight line cannot follow the curve as it bends upward.

Look only at the endpoint of the same equation. The gray point is the true value e³≈20.1, and the gold point is where Euler arrives. The orange bar between them is the accumulated global error. Raise the h slider and the bar and the number shoot up at once. That is the truncation error blowing up. A small miss, where the straight line leaves the curve at each step, piles up into a large gap at the end. Cut h in half and the error is roughly halved too. Euler has accuracy of order 1, so the error is proportional to h. The fuller the band under the bar, the louder the warning.

This equation is y'=cos x, and the true solution is sin x. It oscillates, which shows Euler's weakness. With a large h the gold polyline inflates the peaks above the gray sin curve and its phase lags a little. Follow the oscillation for one period and then another and the mismatch piles up. Shrink h and the two curves lie closer and closer. The same method shows its error differently depending on the character of the solution. A solution that bends and oscillates needs a short step more than a solution that grows smoothly.

Now a harder case. The equation is y'=−ky, and the true solution is a decay that settles gently toward 0. Euler multiplies y by (1−hk) at every step. When h·k exceeds 2, the absolute value of that factor exceeds 1, so the numerical solution flips sign and grows even while the true solution goes to 0. It explodes in red. Between 1 and 2 it oscillates in orange as it settles, and below 1 it decays quietly in green. This is not an accuracy problem. It is a stability problem. Shortening the step is not only about precision. It is also the safety catch that stops a blow-up. It matters especially for a stiff equation.

There is a smarter step, not only a smaller one. Euler trusts only the slope at the start and walks straight. RK2, the midpoint method, walks halfway, measures the slope there once more, and then takes the full step with that better slope. The work doubles, but the accuracy jumps. Compare gold Euler with blue RK2 at the same h and the blue one stays much closer to the true solution ex. Euler's error is order 1, proportional to h, while RK2 is order 2, proportional to h², so cutting the step in half cuts the error to 1/4. The practical standard RK4 uses the same idea four times and reaches a higher order. The same principle shows up when numerical integration measures area in pieces. The blue curve in that comparison is the one that spends an extra slope reading in order to stay on the true solution.

In PracticeEuler's method takes the slope from a differential equation and walks forward in straight steps of size (h), drawing the solution as a polyline. The error of one step is the remainder of a Taylor polynomial of order 1, and those misses pile up into the global error. Euler has accuracy of order 1, so the error is proportional to h. A shorter step is more accurate and costs more. If h·k is too large, the numerical solution diverges even on a decaying problem, which is a stability issue separate from accuracy. The smarter RK2 and RK4 measure extra slopes along the way and reach a higher order. A direction field hands over the slope map, Euler walks it, and Taylor explains the error of each step.
← engineering mathematics
Was this helpful? Support seegongsik