Steply

Use Euler's method on dy/dx = 1 - y, y(0) = 0, step 0.5, to find y(2)

Step by step, with the reason for every step · Euler's method · Differential Equations

Step by step

The question

Question: use Euler's method on dy/dx = 1 − y, with y(0) = 0, step 0.5, to find y(2).

dydx = 1 − y
y(0) = 0, step h = 0.5

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.

new y = old y + h × slope
slope = 1 − y at the old point

2 The step size

From x = 0 to x = 2, in steps of 0.5: that is 4 steps.

steps = 2 − 00.5 = 4

3 Go to x = 0.5

The slope at our point (0, 0): put x and y into 1 − y.

It is 1.

slope at (0, 0) = 1 − 0 = 1

New y = old y + h times the slope: 0 + 0.5 × 1, which is 0.5.

Now we are at x = 0.5.

y1 = 0 + 0.5 × 1 = 0.5

Careful!

Times the step size h!

We only move 0.5 to the right, so y changes by 0.5 times the slope.

Careful: not y₁ = 0 + 1 ✗

4 Go to x = 1

The slope at (0.5, 0.5) is 0.5.

slope at (0.5, 0.5) = 1 − 0.5 = 0.5

New y: 0.5 + 0.5 × 0.5 = 0.75.

y2 = 0.5 + 0.5 × 0.5 = 0.75

5 Go to x = 1.5

The slope at (1, 0.75) is 0.25.

slope at (1, 0.75) = 1 − 0.75 = 0.25

New y: 0.75 + 0.5 × 0.25 = 0.875.

y3 = 0.75 + 0.5 × 0.25 = 0.875

6 Go to x = 2

The slope at (1.5, 0.875) is 0.125.

slope at (1.5, 0.875) = 1 − 0.875 = 0.125

New y: 0.875 + 0.5 × 0.125 = 0.9375.

y4 = 0.875 + 0.5 × 0.125 = 0.9375

All the points in a table.

0
0.5
0.75
0.875
0.9375

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(2) ≈ 0.9375.

y(2) ≈ 0.9375

7 Check

Let's check: a calculator with very tiny steps gives about 0.8647.

Close to our 0.9375.

Euler is a bit high: the slope changes during each step.

Smaller steps get closer.

Right!

tiny steps: y(2) ≈ 0.8647

Let's look back.

First: the idea.

Then: the step size.

Then: go to x = 0.5.

Then: go to x = 1.

Then: go to x = 1.5.

Then: go to x = 2.

Last: check.

Answer
y(2) ≈ 0.9375

Your turn

Try this one yourself, then check:

dydx = 2 − 2y
Show the answer
y(2) ≈ 1

More from Euler's method

The whole lesson: Euler's method →