Skip to content

Euler's method, step by step

5 min read

Short answer

From (xn,yn)(x_n,y_n), take a step of size hh along the tangent: yn+1=yn+h f(xn,yn)y_{n+1}=y_n+h\,f(x_n,y_n), xn+1=xn+hx_{n+1}=x_n+h. Repeat. The error shrinks roughly in proportion to hh, so halving the step about halves the error.

Bar charth=1h=0.5h=0.25h=0.1Approximations to y(1) for y′ = y, y(0) = 1. Exact: e ≈ 2.718.
Smaller steps move the estimate toward the exact value e.

The idea

The ODE tells you the slope at the current point. Pretend the slope stays constant for a short step hh, move along it, and recompute the slope at the new point. It replaces a curve by a polyline.

Error and better methods

Euler's method has global error of order hh: you lose a small amount each step, and the errors accumulate. Methods like improved Euler (Heun) and Runge-Kutta evaluate the slope more cleverly and reach order 2 and 4.

Worked example

For y′=yy'=y, y(0)=1y(0)=1, estimate y(1)y(1) with h=0.5h=0.5.

y1=1+0.5(1)=1.5y_1=1+0.5(1)=1.5 at x=0.5x=0.5. y2=1.5+0.5(1.5)=2.25y_2=1.5+0.5(1.5)=2.25 at x=1x=1. The exact value is e≈2.718e\approx2.718, so the estimate is too low (the curve bends upward, so tangents underestimate).

Try it yourself

For y′=x+yy'=x+y, y(0)=1y(0)=1, take two steps of h=0.1h=0.1 to estimate y(0.2)y(0.2).

Show the answer

y1=1+0.1(0+1)=1.1y_1=1+0.1(0+1)=1.1. y2=1.1+0.1(0.1+1.1)=1.22y_2=1.1+0.1(0.1+1.1)=1.22.

Keep going with practice

Vidi's numerical-methods lessons build on this step to simulate motion in mechanics.