Steply

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

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 = y − x, with y(0) = 2, step 0.1, to find y(0.3).

dydx = y − x
y(0) = 2, step h = 0.1

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 = y − x at the old point

2 The step size

From x = 0 to x = 0.3, in steps of 0.1: that is 3 steps.

steps = 0.3 − 00.1 = 3

3 Go to x = 0.1

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

It is 2.

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

New y = old y + h times the slope: 2 + 0.1 × 2, which is 2.2.

Now we are at x = 0.1.

y1 = 2 + 0.1 × 2 = 2.2

Careful!

Times the step size h!

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

Careful: not y₁ = 2 + 2 ✗

4 Go to x = 0.2

The slope at (0.1, 2.2) is 2.1.

slope at (0.1, 2.2) = 2.2 − 0.1 = 2.1

New y: 2.2 + 0.1 × 2.1 = 2.41.

y2 = 2.2 + 0.1 × 2.1 = 2.41

5 Go to x = 0.3

The slope at (0.2, 2.41) is 2.21.

slope at (0.2, 2.41) = 2.41 − 0.2 = 2.21

New y: 2.41 + 0.1 × 2.21 = 2.631.

y3 = 2.41 + 0.1 × 2.21 = 2.631

All the points in a table.

2
2.2
2.41
2.631

So y(0.3) ≈ 2.631.

y(0.3) ≈ 2.631

6 Check

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

Close to our 2.631.

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

Smaller steps get closer.

Right!

tiny steps: y(0.3) ≈ 2.6499

Let's look back.

First: the idea.

Then: the step size.

Then: go to x = 0.1.

Then: go to x = 0.2.

Then: go to x = 0.3.

Last: check.

Answer
y(0.3) ≈ 2.631

Your turn

Try this one yourself, then check:

dydx = y − x
Show the answer
y(0.3) ≈ 3.962

More from Euler's method

The whole lesson: Euler's method →