Steply

Use Euler's method on dy/dx = y - x^2, y(0) = 2, step 0.5, 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.5, to find y(2).

dydx = y − x2
y(0) = 2, 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 = y − x2 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, 2): put x and y into y − x².

It is 2.

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

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

Now we are at x = 0.5.

y1 = 2 + 0.5 × 2 = 3

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₁ = 2 + 2 ✗

4 Go to x = 1

The slope at (0.5, 3) is 2.75.

slope at (0.5, 3) = 3 − 0.5 × 0.5 = 2.75

New y: 3 + 0.5 × 2.75 = 4.375.

y2 = 3 + 0.5 × 2.75 = 4.375

5 Go to x = 1.5

The slope at (1, 4.375) is 3.375.

slope at (1, 4.375) = 4.375 − 1 × 1 = 3.375

New y: 4.375 + 0.5 × 3.375 = 6.0625.

y3 = 4.375 + 0.5 × 3.375 = 6.0625

6 Go to x = 2

The slope at (1.5, 6.0625) is 3.8125.

slope at (1.5, 6.0625) = 6.0625 − 1.5 × 1.5 = 3.8125

New y: 6.0625 + 0.5 × 3.8125 = 7.9688.

y4 = 6.0625 + 0.5 × 3.8125 = 7.9688

All the points in a table.

2
3
4.375
6.0625
7.9688

So y(2) ≈ 7.9688.

y(2) ≈ 7.9688

7 Check

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

Close to our 7.9688.

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

Smaller steps get closer.

Right!

tiny steps: y(2) ≈ 10

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) ≈ 7.9688

Your turn

Try this one yourself, then check:

dydx = y − x2
Show the answer
y(2) ≈ 13.0313

More from Euler's method

The whole lesson: Euler's method →