5.16 · AHL · HL onlyPaper 1Paper 2Paper 3

Euler's method

In a minute

estimates the solution of a that you can't solve exactly. From a known point, you follow the gradient for a short step, then repeat. A spreadsheet or GDC does the repeating, for one equation or for a pair of such as a .

You'll be able to

  • Explain Euler's method as a chain of short tangent steps, and use its formula by hand for dydx=f(x,y)\frac{\mathrm{d}y}{\mathrm{d}x} = f(x, y).
  • Run many steps on a spreadsheet or GDC, and say how the step length affects the estimate.
  • Use Euler's method on a coupled system dxdt=f1(x,y,t)\frac{\mathrm{d}x}{\mathrm{d}t} = f_1(x, y, t), dydt=f2(x,y,t)\frac{\mathrm{d}y}{\mathrm{d}t} = f_2(x, y, t), such as a predator–prey model.
  • Interpret Euler estimates in context, and comment on how far they can be trusted.
Before you start3 quick questions on what this builds on
Check yourself
For dydx=x2−2y\frac{\mathrm{d}y}{\mathrm{d}x} = x^{2} - 2y, find the gradient of the solution curve through (3,1)(3, 1).
Check yourself
A solution curve passes through (2,5)(2, 5), where its gradient is 0.40.4. Follow the tangent from that point to estimate yy when x=2.5x = 2.5.
Check yourself
dPdt=2P\frac{\mathrm{d}P}{\mathrm{d}t} = 2P, and P=30P = 30 when t=0t = 0. Which is the ?

Revise first: 2.6 Fitting and testing models, 5.14 Setting up and separating differential equations and 5.15 Slope fields

Following the gradient in small steps

In 5.14 you solved differential equations exactly by separating the variables. Many can't be solved that way, such as dydx=0.5x+y\frac{\mathrm{d}y}{\mathrm{d}x} = 0.5x + \sqrt{y}. But the equation still tells you the gradient at every point, just as a does.

So start at the known point. Move a short distance hh along the tangent: yy changes by about gradient × h\times\ h. At the new point, work out the new gradient and take another step. Repeat until you reach the xx you want.

In the formula booklet
yn+1=yn+h×f(xn,yn),xn+1=xn+hy_{n+1} = y_{n} + h \times f(x_{n}, y_{n}), \quad x_{n+1} = x_{n} + h

Here dydx=f(x,y)\frac{\mathrm{d}y}{\mathrm{d}x} = f(x, y), the starting point (x0,y0)(x_{0}, y_{0}) comes from the initial condition, and hh is the constant step length. This is Euler's method. The formula is in the booklet, so you need to know how to use it, not memorise it.

The number of steps is end x−x0h\frac{\text{end } x - x_{0}}{h}. Set out the work as a table with columns nn, xnx_{n}, yny_{n} and f(xn,yn)f(x_{n}, y_{n}). Each row is built only from the row above it.

Worked exampleGiven dydx=x+2y\frac{\mathrm{d}y}{\mathrm{d}x} = x + 2y and y=2y = 2 when x=0x = 0, use Euler's method with step length 0.50.5 to estimate yy when x=1x = 1.

Try it first, then reveal one step at a time.

  1. Here f(x,y)=x+2yf(x, y) = x + 2y, h=0.5h = 0.5, x0=0x_{0} = 0 and y0=2y_{0} = 2. Going from x=0x = 0 to x=1x = 1 takes 1−00.5=2\frac{1 - 0}{0.5} = 2 steps.
Worked exampleA cup of coffee cools in a room at 21 ∘C21\,^{\circ}\text{C}. Its temperature T ∘CT\,^{\circ}\text{C} after tt minutes satisfies dTdt=−0.08(T−21)\frac{\mathrm{d}T}{\mathrm{d}t} = -0.08(T - 21), and T=85T = 85 when t=0t = 0. Use Euler's method with h=1h = 1 to estimate the temperature after 3 minutes. The exact solution is T=21+64e−0.08tT = 21 + 64\mathrm{e}^{-0.08t}. Compare your estimate with it.

Try it first, then reveal one step at a time.

  1. Here tt plays the part of xx and TT the part of yy: Tn+1=Tn−0.08(Tn−21)T_{n+1} = T_{n} - 0.08(T_{n} - 21), tn+1=tn+1t_{n+1} = t_{n} + 1. Three steps take tt from 00 to 33.
Check yourself
Given dydx=x2+y\frac{\mathrm{d}y}{\mathrm{d}x} = x^{2} + y and y=2y = 2 when x=0x = 0, use Euler's method with h=0.2h = 0.2 to estimate yy when x=0.4x = 0.4. Give your answer to 3 s.f.
Check yourself
You estimate yy at x=2x = 2 with h=0.2h = 0.2, then again with h=0.1h = 0.1. What usually happens?

Spreadsheets, the GDC and step length

By hand, two or three steps is the limit. With more, use a spreadsheet, or your GDC in an exam. Both repeat the same row rule many times.

A spreadsheet layout: column A holds xx, column B holds yy. Put x0x_{0} in A2 and y0y_{0} in B2. In A3 type =A2+h, and in B3 type =B2+h*f(A2, B2), with your hh and ff written out. Then fill both formulas down.

Worked exampleA lake is stocked with 100100 fish. A model for the number of fish PP after tt years is dPdt=0.6P(1−P800)\frac{\mathrm{d}P}{\mathrm{d}t} = 0.6P\left(1 - \frac{P}{800}\right). Use a spreadsheet and Euler's method with h=0.5h = 0.5 to estimate the number of fish after 3 years.

Try it first, then reveal one step at a time.

  1. Three years in steps of 0.50.5 is 66 steps. The rule is Pn+1=Pn+0.5×0.6Pn(1−Pn800)P_{n+1} = P_{n} + 0.5 \times 0.6P_{n}\left(1 - \frac{P_{n}}{800}\right), tn+1=tn+0.5t_{n+1} = t_{n} + 0.5.
Worked exampleGiven dydx=0.5x+y\frac{\mathrm{d}y}{\mathrm{d}x} = 0.5x + \sqrt{y} and y=1y = 1 when x=2x = 2, use Euler's method with step length 0.20.2 to estimate yy when x=3x = 3. Give your answer to 3 s.f. Repeating with h=0.1h = 0.1 and h=0.05h = 0.05 gives 3.6405…3.6405\ldots and 3.6817…3.6817\ldots Comment on these results.

Try it first, then reveal one step at a time.

  1. Five steps take xx from 22 to 33. Write down the rule you enter: yn+1=yn+0.2(0.5xn+yn)y_{n+1} = y_{n} + 0.2\left(0.5x_{n} + \sqrt{y_{n}}\right), xn+1=xn+0.2x_{n+1} = x_{n} + 0.2.
Euler's methodDrag the slider
11234exact: y = 2eˣ − x − 1Euler polygon, h = 0.25

dy/dx = x + y, y(0) = 1, so the exact solution is y = 2eˣ − x − 1

0.25

Steps from x = 0 to x = 1: 4

Euler estimate of y(1) = 2.8828 with h = 0.25, exact y(1) = 2e − 2 = 3.4366, error 0.5538

Euler's method follows the tangent for one step of width h: yₙ₊₁ = yₙ + h·f(xₙ, yₙ) and xₙ₊₁ = xₙ + h. Smaller steps stay closer to the exact curve. The step sizes offered all divide 1, so the last point lands on x = 1.

The widget uses dydx=x+y\frac{\mathrm{d}y}{\mathrm{d}x} = x + y with y=1y = 1 at x=0x = 0, where the exact value at x=1x = 1 is 2e−2≈3.442\mathrm{e} - 2 \approx 3.44. With h=0.25h = 0.25 Euler gives about 2.882.88. Slide to h=0.05h = 0.05 and the gap shrinks to about 0.130.13.

Check yourself
Given dydx=xy+1\frac{\mathrm{d}y}{\mathrm{d}x} = \frac{x}{y + 1} and y=1y = 1 when x=0x = 0, use Euler's method on your GDC with h=0.25h = 0.25 to estimate yy when x=2x = 2. Give your answer to 3 s.f.
Check yourself
A spreadsheet runs Euler's method for dydx=x−y\frac{\mathrm{d}y}{\mathrm{d}x} = x - y with h=0.2h = 0.2. Column A holds xx and column B holds yy, starting in row 2. Which cells should the formula in B3, the next yy, use?

Coupled systems and predator–prey models

Some situations have two quantities that change together, such as rabbits and the foxes that eat them. The rate of each depends on both. Time tt is the variable you step through.

In the formula booklet
xn+1=xn+h×f1(xn,yn,tn),yn+1=yn+h×f2(xn,yn,tn),tn+1=tn+hx_{n+1} = x_{n} + h \times f_1(x_{n}, y_{n}, t_{n}), \quad y_{n+1} = y_{n} + h \times f_2(x_{n}, y_{n}, t_{n}), \quad t_{n+1} = t_{n} + h

This is Euler's method once for each equation, and it is in the booklet. The key rule: both new values come from the old row. Work out f1f_1 and f2f_2 with xnx_{n}, yny_{n} and tnt_{n} before you update anything.

Worked exampledxdt=2x−y\frac{\mathrm{d}x}{\mathrm{d}t} = 2x - y and dydt=x+t\frac{\mathrm{d}y}{\mathrm{d}t} = x + t. When t=0t = 0, x=1x = 1 and y=3y = 3. Use Euler's method with h=0.1h = 0.1 to estimate xx and yy when t=0.2t = 0.2.

Try it first, then reveal one step at a time.

  1. The rules are xn+1=xn+0.1(2xn−yn)x_{n+1} = x_{n} + 0.1(2x_{n} - y_{n}), yn+1=yn+0.1(xn+tn)y_{n+1} = y_{n} + 0.1(x_{n} + t_{n}) and tn+1=tn+0.1t_{n+1} = t_{n} + 0.1. Two steps reach t=0.2t = 0.2.
Worked exampleOn an island, RR is the number of rabbits in hundreds and FF the number of foxes in tens, tt years after a survey. A model is dRdt=0.9R−0.05RF\frac{\mathrm{d}R}{\mathrm{d}t} = 0.9R - 0.05RF and dFdt=0.02RF−0.6F\frac{\mathrm{d}F}{\mathrm{d}t} = 0.02RF - 0.6F. At the survey R=40R = 40 and F=10F = 10. Explain what the terms −0.05RF-0.05RF and −0.6F-0.6F mean. Then use Euler's method with h=0.25h = 0.25 to estimate RR and FF one year after the survey.

Try it first, then reveal one step at a time.

  1. Meaning: RFRF grows with the number of rabbit–fox meetings, so −0.05RF-0.05RF is rabbits being eaten. −0.6F-0.6F says that with no rabbits, the foxes would decline.

The new rabbit value is stored in A first. If you stored it straight in R, the fox line would use the new RR and break the key rule. On a spreadsheet, use columns for tt, RR and FF, with every formula in row 3 pointing at row 2.

Graph of the two populations against time t from 0 to 20 years. The rabbit curve, R in hundreds, rises from 40 to a peak near 58 at about t equals 1.5, falls to about 13, then repeats roughly every 9 years. The fox curve, F in tens, starts at 10, peaks near 31 at about t equals 3, about one and a half years after each rabbit peak, then falls to about 9 and repeats. 0 10 20 30 40 50 60 70 0 5 10 15 20 t (years) rabbits, R (hundreds) foxes, F (tens)
The rabbit–fox model run for 20 years by Euler's method with a small step, h=0.01h = 0.01.

Run for longer, the model gives cycles. Rabbits increase, so the foxes have more food and increase. More foxes eat more rabbits, so the rabbits fall. Then the foxes starve and fall, and the rabbits recover. The fox peaks come after the rabbit peaks.

How far can you trust this? Euler only approximates the model's solution. The model itself also ignores disease, weather, hunting and other food sources. So treat the numbers as a guide to the pattern, not exact counts.

Check yourself
dxdt=x−y\frac{\mathrm{d}x}{\mathrm{d}t} = x - y, dydt=2x+y\frac{\mathrm{d}y}{\mathrm{d}t} = 2x + y, with x=3x = 3 and y=1y = 1 when t=0t = 0. Use Euler's method with h=0.2h = 0.2 to estimate yy when t=0.4t = 0.4.
Check yourself
Continue the rabbit–fox table with h=0.25h = 0.25 up to t=2t = 2. What is the largest estimate of RR in the table, in hundreds? Give your answer to 3 s.f.
Check yourself
In the model dFdt=0.02RF−0.6F\frac{\mathrm{d}F}{\mathrm{d}t} = 0.02RF - 0.6F, what does the term −0.6F-0.6F tell you?

Common mistakes

  • Writing only xn+1=xn+hx_{n+1} = x_{n} + h. The method mark needs the yy update with your own ff and hh, such as yn+1=yn+0.1(xn+yn)y_{n+1} = y_{n} + 0.1(x_{n} + y_{n}).
  • Rounding each row before the next step. The error grows with every row; keep the full GDC or spreadsheet values and round only the final answer.
  • Taking the wrong number of steps. Work out end−starth\frac{\text{end} - \text{start}}{h} first, and check that your last row is at the value the question asks for.
  • Giving the step number as the time. If a question asks when something happens, answer with tt, not the row number: with h=0.1h = 0.1 from t=0t = 0, row n=20n = 20 is t=2t = 2 seconds.
  • In a coupled system, updating the second variable with the first one's new value. Both new values come from the old row.
  • Leaving tt out of a rate that depends on it. Use tnt_{n} in each row, and step it on by hh as well.

Exam tips

  • Use Euler's method: write the iteration with your own ff and hh, then show at least one correct row, such as y1y_{1}. These earn the method marks before the GDC finishes the job.
  • Give the final estimate to the accuracy the question asks for, such as 3 decimal places. A wrong earlier value, rounded correctly, can still earn follow-through marks.
  • Interpret or state what the model predicts in context, with units: "about 55905590 rabbits after one year", not just R=55.9R = 55.9.
  • Suggest a reason a prediction may not happen: Euler's method only approximates the solution, and the model leaves out real factors such as disease or hunting.

Key takeaways

In bookletyn+1=yn+h×f(xn,yn),xn+1=xn+hy_{n+1} = y_{n} + h \times f(x_{n}, y_{n}), \quad x_{n+1} = x_{n} + h
In bookletxn+1=xn+hf1(xn,yn,tn),yn+1=yn+hf2(xn,yn,tn),tn+1=tn+hx_{n+1} = x_{n} + h f_1(x_{n}, y_{n}, t_{n}), \quad y_{n+1} = y_{n} + h f_2(x_{n}, y_{n}, t_{n}), \quad t_{n+1} = t_{n} + h
Learn thisEuler's method gives an estimate, not the exact solution. A smaller step length means more steps and usually a closer estimate.
Learn thisNumber of steps =end value−start valueh= \frac{\text{end value} - \text{start value}}{h}. Each row uses only the row above, and in a coupled system both new values come from the old row.
Learn thisSpreadsheet: put x0x_{0} and y0y_{0} in row 2, write row 3 as x+hx + h and y+h×f(x,y)y + h \times f(x, y) using row 2's cells, then fill down.

Practise this

19 past-paper questions on Euler's method for differential equations in the AI HL bank, each with a mark scheme and a worked explanation.

Practise Euler's method for differential equations →