Euler’s method for differential equations: formula and examples

An initial condition gives us one point on a solution curve, and the differential equation gives us the slope there. Euler’s method uses that slope to take a short step toward the next point. We’ll repeat the process to see how the approximation builds.

Euler’s method formula

Suppose y′ = f(t, y) and y(t₀) = y₀. To approximate y at t = T in n equal steps, use h=T-t0n. Starting from the initial point, compute

tk+1=tk+hyk+1=yk+hf(tk,yk)

The term h f(tₖ, yₖ) is the change in y predicted by the slope at the start of the step. At the next point, we compute a new slope using the new t and the approximate y.

Example: Approximate y(1) in two steps

Suppose y′ = y − t and y(0) = 2. The interval goes from 0 to 1, so two equal steps give h=12.

At (0, 2), the slope is 2 − 0 = 2. Use that slope for the first half-step.

y1=2+0.5(2-0)=3

Now we’re at (0.5, 3), so the new slope is 3 − 0.5 = 2.5. Use that slope for the second step.

y2=3+0.5(3-0.5)=4.25
Euler’s method with h = 0.5
SteptApproximate y
002
10.53
214.25

Why the approximation works

Over a short step, a smooth solution curve stays close to its tangent line. Euler’s method uses that local linear approximation, then repeats it at the estimated point. In our example, the exact solution is y(t) = t + 1 + eᵗ, so y(1) = 2 + e ≈ 4.7183. The Euler result 4.25 is an underestimate here.

Two Euler steps below the exact curveThe solid line is y equals t plus one plus e to the t. Two dashed Euler steps connect (0, 2), (0.5, 3), and (1, 4.25).234500.51tyExact solutionEuler approximation
In this example, the two Euler steps end below the exact solution.

The exact curve is convex because y″(t) = eᵗ > 0. A step started at the exact point is therefore below the curve at the next time. Here the update is increasing in y, since its coefficient on y is 1 + h, so starting below the curve also keeps the next approximation below it. The sign of the error can differ in other problems.

Example: Use a given step size

Now suppose y′ = y − 3t + t² and y(0) = 5, with a step size of h = 0.2. We use yk+1=yk+0.2(yk-3tk+tk2), keeping the intermediate values as we work.

Five Euler steps from the initial point
tApproximate y
05
0.26
0.47.088
0.68.2976
0.89.66912
111.250944

How accurate is Euler’s method?

If we start a step on the exact curve and |y″| is bounded by M on that step, the error from replacing the curve by its tangent is at most Mh22. That is a bound for one step from the exact solution. Over many steps, the errors also carry forward from one step to the next.

Under the usual smoothness and Lipschitz conditions on a fixed interval, the accumulated error is of order h. For example, using four steps of size 0.25 in our first problem gives about 4.4414, closer to 4.7183 than the two-step result. The slope must be defined at each point we use, and steps that are too large can give poor or unstable results.