Menu
Sign up Sign in

AI HL · AHL 9

Differential Equations

AHL 9.7

Euler's method: accuracy and contexts

AHL 9.7

Euler's method: accuracy and contexts

Target: I can use Euler's method to estimate y for dy/dx = f(x) and dy/dx = f(x, y), with different step lengths and from a start that is not at x = 0. (+5 more)

By the end of this section

Key points

The method, and what to watch

  • Euler's method follows tangent lines: \(x_{n+1}=x_n+h\), \(y_{n+1}=y_n+h\,f(x_n,y_n)\). The gradient is taken at the start of each step.
  • The start point need not be at x = 0. Count the steps from where you start to where you must finish.
  • Keep the unrounded values in the calculator and round only the final answer, to 3 significant figures.

Accuracy

  • A smaller step length h gives a more accurate estimate. Halving h roughly halves the error.
  • Percentage error = \(\dfrac{|\text{estimate}-\text{exact}|}{|\text{exact}|}\times100\). The exact value comes from separating the variables.
  • If the solution curve is concave up, the tangents lie below it and Euler underestimates. If it is concave down, Euler overestimates.
  • The error grows the further you go from the start.

Contexts

  • If the step is not given, choose a sensible h, then check that a smaller step gives the same answer to the accuracy asked for.
  • To find when a quantity reaches zero, keep iterating until it changes sign, then give the time to the accuracy asked for.
  • For a coupled model, both new values use the old x and the old y.
  • From a table of speeds at equal intervals, the distance is \(h\times\) the sum of the speeds at the start of each interval (the last speed is not used).

On the calculator

Euler's method in a spreadsheet

  • Put x in column A and y in column B. Type the start values in the first row.
  • In the second row type the formula for the next x (add h) and the next y (y plus h times the gradient), using the cells of the row above. Fill it down.
  • Check the first two rows by hand before you trust the column.
  • For a time-to-zero question, scroll down column B until the sign changes.

Screenshot and video to come

Graph and maximum from the table

  • Plot column B against column A as a scatter plot with the points joined.
  • The largest value in column B is the maximum. Read it to the accuracy asked for (1 decimal place), and note the x-value it happens at.
  • For a coupled system, use three columns: t, x and y, and update both x and y from the row above.

Screenshot and video to come

Explore: Euler's method, one step at a time

Choose an equation and a step length h. Drag the orange start point if you like. Press Next: the gradient at the point you are leaving gives one straight piece. Tick the box to compare with the true curve.

Step length h


nxydy/dxnew y
Step length h
Steps taken
Euler's y
True value of y
Error
Percentage error

The table shows 4 decimal places; the calculation keeps more. Dots and ink line: Euler's method. Orange: the start point and the latest piece. Teal: the true curve, with its error at the last point.

Press Next to take the first step.

  1. Press Next once with h = 0.5. Which point's gradient made the first piece: the one you left or the one you reached? How does the working show it?
  2. Tick the true curve. Run to x = 2 with h = 1, then 0.5, 0.2 and 0.1. What happens to the error each time? Why does a shorter step follow the curve more closely?
  3. Choose 0.5y and look at the true curve. Is Euler's estimate above or below it? What does the bend of the curve have to do with that?
  4. Choose 3x − y. Where is the Euler path closest to the true curve, and where is it furthest away? Why?

Worked examples

Problems like the ones in class. Pick one, try it, then open the working.
Two step lengths

\(\dfrac{dy}{dx}=4x\) and \(y=1\) when \(x=0\). Use Euler's method with step length \(h=0.5\) and then \(h=0.25\) to estimate \(y(1)\) and \(y(2)\).

Working
  1. The rule

    \(x_{n+1}=x_n+h,\quad y_{n+1}=y_n+h\,f(x_n)\)

    f(x) = 4x. Each step uses the gradient at the start of the step.

  2. h = 0.5

    \(y_1=1+0.5(0)=1,\ y_2=1+0.5(2)=2,\ y_3=2+0.5(4)=4,\ y_4=4+0.5(6)=7\)

    x goes 0, 0.5, 1, 1.5, 2: four steps.

  3. Read off

    \(y(1)\approx2,\quad y(2)\approx7\)

    y(1) is the value of y at x = 1, after two steps.

  4. h = 0.25

    \(y(1)\approx2.5,\quad y(2)\approx8\)

    Eight steps now. Both estimates are larger than before.

Video walkthrough coming
Exact value and percentage error

\(\dfrac{dy}{dx}=0.5y\) and \(y=4\) when \(x=0\). (a) Use Euler's method with \(h=1\) and then \(h=0.5\) to estimate \(y(2)\). (b) Solve the equation exactly. (c) Find the percentage error of each estimate, and say which is further from the true value.

Working
  1. Euler, h = 1

    \(y_1=4+1(2)=6,\ y_2=6+1(3)=9\)

    The gradient is 0.5y, so use the y-value at the start of each step.

  2. Euler, h = 0.5

    \(y: 4, 5, 6.25, 7.8125, 9.7656\quad y(2)\approx9.766\)

    Four steps of 0.5.

  3. Separate

    \(\int\frac1y\,dy=\int0.5\,dx\Rightarrow\ln y=0.5x+c\Rightarrow y=4e^{0.5x}\)

    y = 4 when x = 0 gives the constant.

  4. True value

    \(y(2)=4e^{1}=10.87\)

    This is the value to compare with.

  5. Percentage error

    \(h=1:\ \dfrac{10.87-9}{10.87}\times100=17.2\%,\quad h=0.5:\ 10.2\%\)

    The h = 1 estimate is further from the true value.

  6. More accurate

    A smaller step length gives a smaller error.

    Halving h roughly halved the error here.

Video walkthrough coming
A nonlinear equation from x = 1

\(\dfrac{dy}{dx}=xe^{-y}\) and \(y=0.5\) when \(x=1\). Use Euler's method with \(h=0.25\) to estimate \(y(2)\).

Working
  1. Set up

    \(x_0=1,\ y_0=0.5,\ h=0.25;\quad y_{n+1}=y_n+0.25\,x_ne^{-y_n}\)

    The start is x = 1, not 0. Four steps reach x = 2.

  2. Step 1

    \(y_1=0.5+0.25(1)e^{-0.5}=0.6516\)

    x_1 = 1.25.

  3. Step 2

    \(y_2=0.6516+0.25(1.25)e^{-0.6516}=0.8145\)

    Use the unrounded y in the calculator.

  4. Steps 3 and 4

    \(y_3=0.9806,\quad y_4=1.145\)

    x_4 = 2.

  5. Answer

    \(y(2)\approx1.14\)

    Give 3 significant figures.

Video walkthrough coming
Why the estimate is too small

\(\dfrac{dy}{dx}=xy\) and \(y=2\) when \(x=0\). (a) Use Euler's method with \(h=0.5\) to estimate \(y(2)\). (b) The exact solution is \(y=2e^{x^2/2}\). Explain, using the graph, why the Euler estimate is smaller than the true value.

0.511.52246810121416xyexact
Working
  1. Euler

    \(y_1=2,\ y_2=2.5,\ y_3=3.75,\ y_4=6.5625\)

    y_{n+1} = y_n + 0.5 x_n y_n.

  2. True value

    \(y(2)=2e^{2}=14.78\)

    The estimate is far below.

  3. Concavity

    \(\dfrac{d^2y}{dx^2}=y+x\dfrac{dy}{dx}=y+x^2y>0\)

    The solution curve is concave up for y > 0.

  4. The explanation

    A tangent to a concave up curve lies below it.

    Each Euler step follows a tangent, so each new point is below the curve, and the error builds up.

Video walkthrough coming
A long interval with technology

\(\dfrac{dy}{dx}=3\cos x-y\) with \(y=0\) when \(x=0\) (\(x\) in radians). Use Euler's method with \(h=0.1\) for \(0\le x\le6\) to sketch the solution, and estimate the largest value of \(y\) in this interval to 1 decimal place.

123456−2−112xymax
Working
  1. The columns

    x in column A, y in column B; start row: 0 and 0

    Sixty steps of 0.1 reach x = 6, so use technology.

  2. The formula

    Next y = y + 0.1 × (3cos(x) − y), using the cells of the row above

    Fill down for 60 rows. Check the first rows by hand: y_1 = 0.3, y_2 = 0.5685.

  3. Sketch

    Plot column B against column A, points joined

    The curve rises, turns, falls below the axis and then oscillates.

  4. The maximum

    \(y_{\max}\approx1.615\ \text{at}\ x=1.1\)

    Read the largest value in column B.

  5. Answer

    \(y_{\max}\approx1.6\)

    1 decimal place, as asked.

Video walkthrough coming
When does the tank empty?

The volume \(V\) m³ of water in a tank, \(t\) minutes after a valve is opened, is modelled by \(\dfrac{dV}{dt}=-0.25\sqrt{V}-0.1t\). At the start \(V=12\). Use Euler's method with a step length you choose to estimate the time, to the nearest minute, when the tank is empty.

Working
  1. Choose h

    \(h=1:\ V_{n+1}=V_n+1(-0.25\sqrt{V_n}-0.1t_n)\)

    The question leaves the step to you. A step of 1 minute is sensible.

  2. Iterate

    t: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11; V: 12, 11.1, 10.2, 9.2, 8.14, 7.03, 5.87, 4.66, 3.42, 2.16, 0.892, −0.344

    Keep going until V changes sign.

  3. Sign change

    \(V(10)=0.892>0,\quad V(11)=-0.344<0\)

    The tank empties between 10 and 11 minutes, very close to 11.

  4. Check with h = 0.5

    The estimate is still 11 minutes (V first negative at t = 11)

    A smaller step gives the same answer to the nearest minute, so the estimate is reliable.

Video walkthrough coming
Predator and prey

The numbers of perch \(x\) and pike \(y\) in a lake, \(t\) years after monitoring starts, are modelled by \(\dfrac{dx}{dt}=0.6x-0.01xy\) and \(\dfrac{dy}{dt}=0.004xy-0.3y\). At the start there are 120 perch and 30 pike. Use Euler's method with \(h=0.1\) to estimate the numbers of perch and pike after 0.4 years.

Working
  1. The rule

    \(x_{n+1}=x_n+h\,f_1,\quad y_{n+1}=y_n+h\,f_2,\quad t_{n+1}=t_n+h\)

    Both new values use the old x and the old y.

  2. Step 1

    \(x_1=120+0.1(0.6(120)-0.01(120)(30))=123.6,\ y_1=30.54\)

    Work out both before moving on.

  3. Step 2

    \(x_2=127.24,\ y_2=31.134\)

    Use the unrounded values.

  4. Steps 3 and 4

    \(x_3=130.91,\ y_3=31.784;\ x_4=134.61,\ y_4=32.495\)

    t = 0.4 after four steps.

  5. Answer

    About 135 perch and 32.5 pike

    Perch to 3 significant figures.

Video walkthrough coming
Distance from a table of speeds

The table shows the speed of a cyclist as she accelerates from rest, measured every 2 seconds. Use Euler's method to estimate the distance travelled in the first 10 seconds.

t (s)0246810Speed (m/s)03.15.47.28.38.9
Working
  1. The idea

    \(\dfrac{ds}{dt}=v\ \Rightarrow\ s_{n+1}=s_n+h\,v_n\)

    The distance gained in each interval is about h times the speed at its start.

  2. Add up

    \(s=2(0+3.1+5.4+7.2+8.3)\)

    Five intervals of 2 s. Leave out the last speed (8.9): it is the start of no interval.

  3. Answer

    \(s\approx48\text{ m}\)

    The cyclist is speeding up, so these start-of-interval speeds are too low: this is an underestimate.

Video walkthrough coming