Step by step
The question
Question: use Euler's method on dy/dx = x − 2y, with y(1) = 0, step 0.5, to find y(3).
1 The idea
We cannot solve it exactly here.
So we walk: from a point, follow its slope for a short step h.
Then look at the slope again.
New y = old y + h times the slope.
2 The step size
From x = 1 to x = 3, in steps of 0.5: that is 4 steps.
3 Go to x = 1.5
The slope at our point (1, 0): put x and y into x − 2y.
It is 1.
New y = old y + h times the slope: 0 + 0.5 × 1, which is 0.5.
Now we are at x = 1.5.
Careful!
Times the step size h!
We only move 0.5 to the right, so y changes by 0.5 times the slope.
4 Go to x = 2
The slope at (1.5, 0.5) is 0.5.
New y: 0.5 + 0.5 × 0.5 = 0.75.
5 Go to x = 2.5
The slope at (2, 0.75) is 0.5.
New y: 0.75 + 0.5 × 0.5 = 1.
6 Go to x = 3
The slope at (2.5, 1) is 0.5.
New y: 1 + 0.5 × 0.5 = 1.25.
All the points in a table.
On a graph:
Euler's steps: straight lines, each with the slope at its start.
The true solution, in green, bends away a little.
So y(3) ≈ 1.25.
7 Check
Let's check: a calculator with very tiny steps gives about 1.2454.
Close to our 1.25.
Euler is a bit high: the slope changes during each step.
Smaller steps get closer.
Right!
Let's look back.
First: the idea.
Then: the step size.
Then: go to x = 1.5.
Then: go to x = 2.
Then: go to x = 2.5.
Then: go to x = 3.
Last: check.