When an ODE can't be solved exactly, we can still approximate the solution step by step.
At $(x_n,y_n)$ the slope of the solution curve is known exactly: it's $f(x_n,y_n)$. Euler's method moves forward a small step $h$ along that slope, treating the curve as if it were straight over that short distance.
exact solution Euler approximation (step $h$)
Iteration Steps
1
Choose a step size $h$, and set $x_0,y_0$ from the initial condition.
2
Evaluate the slope at the current point: $f(x_n,y_n)$.
3
Advance one step
$$x_{n+1} = x_n + h$$
4
Repeat until reaching the desired $x$.
$$y_{n+1} = y_n + h\,f(x_n,y_n)$$
Example
$y' = x+y, \quad y(0)=1, \quad h=0.1$
$n$
$x_n$
$y_n$
$f(x_n,y_n)=x_n+y_n$
$y_{n+1}=y_n+h f(x_n,y_n)$
0
0.0
1.000
1.000
1.100
1
0.1
1.100
1.200
1.220
2
0.2
1.220
1.420
1.362
3
0.3
1.362
1.662
1.528
Each row's $y_{n+1}$ becomes the $y_n$ of the next row. $x_n$ simply grows by $h$ every step.
Step Size and Error
1
Local error per step: order $h^2$.
2
Accumulated error over the full interval: order $h$: Euler's method is first-order.
3
Trade-off: smaller $h$ gives a more accurate approximation, but requires more steps (more computation).
More accurate alternatives (Improved Euler / Heun, Runge-Kutta) reduce this error without shrinking $h$ as much.