Euler's methods for differential equations

Euler's methods for differential equations

Spec J2–J3 · AQA A-Level Further Maths: Revision notes

Studying this course? Keep your progress in one place.

Key facts

  • Euler's method: yr+1=yr+hf(xr,yr)y_{r+1}=y_r+hf(x_r,y_r) and xr+1=xr+hx_{r+1}=x_r+h, with the gradient taken at the start of each step.
  • Set results out in a table of xrx_r, yry_r and f(xr,yr)f(x_r,y_r) and keep full calculator values.
  • Improved Euler: yr+1=yr−1+2hf(xr,yr)y_{r+1}=y_{r-1}+2hf(x_r,y_r); find y1y_1 by ordinary Euler first.
  • Euler's method underestimates for a convex curve (y′′>0y''>0) and overestimates for a concave one.
  • Smaller hh is more accurate; percentage error is ∣estimate−exact∣exact×100\dfrac{|\text{estimate}-\text{exact}|}{\text{exact}}\times100.

Euler's method

Follow the tangent at the current point for a step of width hh, using the gradient at the start of the step.

A first order differential equation dydx=f(x,y)\frac{dy}{dx}=f(x,y) with a starting point (x0,y0)(x_0,y_0) can be solved step by step when no exact solution is available.

Euler's method follows the tangent at the current point for a step of width hh:

yr+1=yr+hf(xr,yr),xr+1=xr+h.y_{r+1}=y_r+hf(x_r,y_r),\qquad x_{r+1}=x_r+h.

The gradient is worked out at the start of each step and then treated as constant across it.

0.050.10.150.20.250.30.911.11.21.31.41.5xy(0, 1)(0.1, 1.1)exact: y = 2eˣ − x − 1tangent at (0, 1)
One Euler step from (0, 1), h = 0.1: the tangent lands just below the curve.

For dydx=2x+y\frac{dy}{dx}=2x+y with y(1)=3y(1)=3 and h=0.5h=0.5, what is y1y_1?

Worked example

Work in a table of xrx_r, yry_r and f(xr,yr)f(x_r,y_r), keeping full calculator values between steps.

Take dydx=x+y\frac{dy}{dx}=x+y, y(0)=1y(0)=1, h=0.1h=0.1, and estimate y(0.2)y(0.2). Present results in a table of xrx_r, yry_r and f(xr,yr)f(x_r,y_r).

0.050.10.150.20.250.30.911.11.21.31.41.5xy(0, 1)exact y(0.2) ≈ 1.2428exact solution
For dy/dx = x + y, y(0) = 1 the exact solution is y = 2eˣ − x − 1, so y(0.2) = 1.2428. Euler with h = 0.1 gives 1.22, just below it.

xrx_r

r=0r=0:
0
r=1r=1:
0.1
r=2r=2:
0.2

yry_r

r=0r=0:
1
r=1r=1:
1.1
r=2r=2:
1.22

f(xr,yr)f(x_r,y_r)

r=0r=0:
1
r=1r=1:
1.2
r=2r=2:
1.42

Worked example

dydx=x+y\frac{dy}{dx}=x+y, y(0)=1y(0)=1, h=0.1h=0.1. Estimate y(0.2)y(0.2).

Continue the table one more step. What is y3y_3 at x3=0.3x_3=0.3?

The improved Euler method

It uses the gradient at the midpoint of two steps, which is more accurate, but needs two starting values.

The improved Euler method uses the gradient at the midpoint of two steps, which is more accurate:

yr+1=yr−1+2hf(xr,yr),xr+1=xr+h.y_{r+1}=y_{r-1}+2hf(x_r,y_r),\qquad x_{r+1}=x_r+h.

It needs two starting values, y0y_0 and y1y_1, so the first step uses ordinary Euler.

0.511.522.533.54−2246810121416xy(1, 1)(2, 4)(3, 9)y = x²tangent at x = 2chord, x = 1 to 3
Illustrative curve y = x²: the chord from x = 1 to x = 3 has the same gradient (4) as the tangent at x = 2, which is why the formula uses y at r−1 and r+1.
  • Improved Euleryr+1=yr−1+2hf(xr,yr)y_{r+1}=y_{r-1}+2hf(x_r,y_r)

Example

For dydx=x+y\frac{dy}{dx}=x+y with h=0.1h=0.1, y0=1y_0=1 and y1=1.1y_1=1.1, find y2y_2.

Using the same data and the improved formula, find y3y_3 at x3=0.3x_3=0.3.

Accuracy and error

Tangents lie below a convex curve and above a concave one, so Euler's method under- or over-estimates accordingly.

Euler's method follows tangent lines, so the error grows with each step. Reducing hh makes it more accurate, but more steps are needed.

If the exact curve is convex (y′′>0y''>0) the tangents lie below it and Euler's method underestimates; if concave it overestimates.

Because the improved Euler method uses the gradient at the middle of the interval it is usually much more accurate for the same hh.

Measure accuracy with the percentage error:

∣estimate−exact∣exact×100.\frac{|\text{estimate}-\text{exact}|}{\text{exact}}\times100.

0.20.40.60.811.21.41.61.822.22.4−1123456xy(1, 1)Euler (2, 3)exact (2, 4)exact curvetangent at x = 1
Illustrative curve y = x² (convex) from x = 1 with h = 1: the tangent gives 3, below the exact value 4, so Euler underestimates.

Convex, y′′>0y''>0

  • Tangents lie below the curve
  • Euler underestimates

Concave, y′′<0y''<0

  • Tangents lie above the curve
  • Euler overestimates

For dydx=x+y\frac{dy}{dx}=x+y we have y′′=1+y′=1+x+y>0y''=1+y'=1+x+y>0 near (0,1)(0,1). What does Euler's method do?

Try an exam question

Use Euler's method with step length h=0.5h=0.5 to estimate y(1)y(1), given dydx=x2+y\dfrac{dy}{dx}=x^2+y and y(0)=1y(0)=1.

[3 marks]

That's the notes covered.

Carry on to the next subtopic.

Try a question

Use Euler's method to find y1y_1, the estimate of yy when x=0.1x=0.1.

1 mark, marked against the mark scheme

Revision notes