Algorithm: Explicit Euler Method
Given: a time step h, an initial condition (t0, y0), and a maximum number of iterations N.
For 0 ≤ n ≤ N:
- yn+1 = yn + h f(tn, yn)
- tn+1 = tn + h
- Display tn+1 and yn+1
Stop.
Example
Consider the differential equation (from Fortin & Pierre):
y′(t) = −y(t) + t + 1
with the initial condition y(0) = 1. Therefore, t0 = 0 and y0 = 1, and we choose a time step h = 0.1.
The function is:
f(t, y) = −y + t + 1
We apply the explicit Euler method to obtain successive approximations of y(0.1), y(0.2), y(0.3), … denoted y₁, y₂, y₃, …
First step
y₁ = y₀ + h f(t₀, y₀) = 1 + 0.1 f(0, 1) = 1 + 0.1(−1 + 0 + 1) = 1
Second step
y₂ = y₁ + h f(t₁, y₁) = 1 + 0.1 f(0.1, 1) = 1 + 0.1(−1 + 0.1 + 1) = 1.01
Third step
y₃ = y₂ + h f(t₂, y₂) = 1.01 + 0.1 f(0.2, 1.01) = 1.01 + 0.1(−1.01 + 0.2 + 1) = 1.029
The following table shows the first ten steps, along with the analytical solution y(t) = e−t + t, which allows us to compare the numerical and exact values and observe the growth of the error.
Explicit Euler Method: Numerical Results
| ti | y(ti) | yi | |y(ti) − yi| |
|---|---|---|---|
| 0.0 | 1.000000 | 1.000000 | 0.000000 |
| 0.1 | 1.004837 | 1.000000 | 0.004837 |
| 0.2 | 1.018731 | 1.010000 | 0.008731 |
| 0.3 | 1.040818 | 1.029000 | 0.011818 |
| 0.4 | 1.070302 | 1.056100 | 0.014220 |
| 0.5 | 1.106531 | 1.090490 | 0.016041 |
| 0.6 | 1.148812 | 1.131441 | 0.017371 |
| 0.7 | 1.196585 | 1.178297 | 0.018288 |
| 0.8 | 1.249329 | 1.230467 | 0.018862 |
| 0.9 | 1.306570 | 1.287420 | 0.019150 |
| 1.0 | 1.367879 | 1.348678 | 0.019201 |
Definition
A numerical method for solving differential equations is called a one-step method if it has the form:
yn+1 = yn + h φ(tn, yn)
where φ is any function. Such an expression is called a difference equation.
A method is called a multistep method if computing yn+1 requires the numerical solution at earlier times tn−1, tn−2, tn−3, …