All revision notes topics

Numerical solution of differential equationsEdexcel A-Level Further Maths: Revision notes

Section 1

Step length and the idea of a numerical solution

Many differential equations cannot be solved exactly. A numerical method starts from a known point (x0,y0)(x_0,y_0) and moves forward in equal steps of length hh, so xn=x0+nhx_n=x_0+nh. At each step the derivative at xnx_n is replaced by a difference approximation that uses nearby values yn−1y_{n-1}, yny_n, yn+1y_{n+1}. The notation yny_n means the approximation to y(xn)y(x_n). Smaller steps usually give more accurate results but need more calculation. The three approximations on the specification are (dydx)n=yn+1−ynh,(dydx)n=yn+1−yn−12h,(d2ydx2)n=yn+1−2yn+yn−1h2.\left(\frac{dy}{dx}\right)_n=\frac{y_{n+1}-y_n}{h},\quad\left(\frac{dy}{dx}\right)_n=\frac{y_{n+1}-y_{n-1}}{2h},\quad\left(\frac{d^2y}{dx^2}\right)_n=\frac{y_{n+1}-2y_n+y_{n-1}}{h^2}.

Key termsstep lengthdifference approximation
Common mistake

Mixing up the indices: yny_n is the approximation at xn=x0+nhx_n=x_0+nh, not at x=nx=n.

Section 2

The forward difference method (Euler)

Substitute (dydx)n=yn+1−ynh\left(\frac{dy}{dx}\right)_n=\frac{y_{n+1}-y_n}{h} into dydx=f(x,y)\frac{dy}{dx}=f(x,y) and rearrange: yn+1=yn+h f(xn,yn).y_{n+1}=y_n+h\,f(x_n,y_n). Example: dydx=x+y\frac{dy}{dx}=x+y, y(0)=1y(0)=1, h=0.2h=0.2. Then y1=1+0.2(0+1)=1.2y_1=1+0.2(0+1)=1.2, y2=1.2+0.2(0.2+1.2)=1.48y_2=1.2+0.2(0.2+1.2)=1.48 and y3=1.48+0.2(0.4+1.48)=1.856y_3=1.48+0.2(0.4+1.48)=1.856. The exact solution is y=2ex−x−1y=2e^x-x-1, so y(0.6)=2.044y(0.6)=2.044 and the percentage error in y3y_3 is 2.044−1.8562.044×100=9.2%\frac{2.044-1.856}{2.044}\times100=9.2\%. Each step uses the gradient at the start of the interval, so errors build up.

Key termsEuler's methodforward difference
Common mistake

Using xn+1x_{n+1} in the gradient, or the old y0y_0 at every step. Update both xnx_n and yny_n each time.

Exam tip

Set out a table of nn, xnx_n, yny_n and f(xn,yn)f(x_n,y_n) so no step is skipped.

Section 3

The central difference method (first order)

The approximation (dydx)n=yn+1−yn−12h\left(\frac{dy}{dx}\right)_n=\frac{y_{n+1}-y_{n-1}}{2h} is more accurate, because it is centred on xnx_n. Substituting into dydx=f(x,y)\frac{dy}{dx}=f(x,y) gives yn+1=yn−1+2h f(xn,yn).y_{n+1}=y_{n-1}+2h\,f(x_n,y_n). It needs two starting values, y0y_0 and y1y_1, because every step looks back two values. Find y1y_1 by the forward difference method. Example: dydx=x−y\frac{dy}{dx}=x-y, y(0)=1y(0)=1, h=0.1h=0.1. First y1=1+0.1(0−1)=0.9y_1=1+0.1(0-1)=0.9. Then y2=y0+0.2(x1−y1)=1+0.2(0.1−0.9)=0.84y_2=y_0+0.2(x_1-y_1)=1+0.2(0.1-0.9)=0.84 and y3=y1+0.2(x2−y2)=0.9+0.2(0.2−0.84)=0.772y_3=y_1+0.2(x_2-y_2)=0.9+0.2(0.2-0.84)=0.772.

Key termscentral difference
Common mistake

Stepping from yny_n instead of yn−1y_{n-1}. The central difference formula adds 2hf(xn,yn)2hf(x_n,y_n) to yn−1y_{n-1}.

Section 4

Second-order differential equations

Replace d2ydx2\frac{d^2y}{dx^2} by yn+1−2yn+yn−1h2\frac{y_{n+1}-2y_n+y_{n-1}}{h^2}. For d2ydx2=f(x,y)\frac{d^2y}{dx^2}=f(x,y) this gives yn+1=2yn−yn−1+h2f(xn,yn).y_{n+1}=2y_n-y_{n-1}+h^2f(x_n,y_n). If the equation also contains dydx\frac{dy}{dx}, replace it by the central difference yn+1−yn−12h\frac{y_{n+1}-y_{n-1}}{2h} as well, then collect the yn+1y_{n+1}, yny_n and yn−1y_{n-1} terms. Example: d2ydx2=−y\frac{d^2y}{dx^2}=-y with h=0.1h=0.1 gives yn+1−2yn+yn−1=−0.01yny_{n+1}-2y_n+y_{n-1}=-0.01y_n, so yn+1=1.99yn−yn−1y_{n+1}=1.99y_n-y_{n-1}.

Key termssecond-order equation
Exam tip

Substitute both approximations, multiply through by h2h^2 to clear fractions, and only then collect terms.

Section 5

Starting a second-order method

The second-order formula also needs two values, y0y_0 and y1y_1, but the initial conditions give y0y_0 and dydx\frac{dy}{dx} at x0x_0. Use the central difference at n=0n=0: y1−y−12h=(dydx)0,\frac{y_1-y_{-1}}{2h}=\left(\frac{dy}{dx}\right)_0, which brings in the extra value y−1y_{-1}. Write the recurrence formula with n=0n=0, and solve the two equations for y1y_1 and y−1y_{-1}. Example: y0=0y_0=0, dydx=1\frac{dy}{dx}=1, h=0.1h=0.1, and yn+1=1.99yn−yn−1y_{n+1}=1.99y_n-y_{n-1}. Then y1−y−1=0.2y_1-y_{-1}=0.2 and y1=−y−1y_1=-y_{-1}, so y1=0.1y_1=0.1, and y2=1.99(0.1)−0=0.199y_2=1.99(0.1)-0=0.199. (The exact value is sin⁡0.2=0.1987\sin0.2=0.1987.) A simpler start is y1=y0+h(dydx)0y_1=y_0+h\left(\frac{dy}{dx}\right)_0.

Key termsinitial conditions
Common mistake

Using y−1=y0y_{-1}=y_0 as if the function were constant. Find y−1y_{-1} from the derivative condition instead.

Section 6

Accuracy

Compare a numerical estimate with an exact value using the percentage error: exact−estimateexact×100.\frac{\text{exact}-\text{estimate}}{\text{exact}}\times100. Errors grow as more steps are taken. To improve an estimate, use a smaller step length hh, so that each difference approximation is closer to the true derivative, or use the central difference rather than the forward difference. For d2ydx2+2dydx+y=0\frac{d^2y}{dx^2}+2\frac{dy}{dx}+y=0, y(0)=1y(0)=1, y′(0)=0y'(0)=0 and h=0.5h=0.5, the estimate of y(1)y(1) is 0.68750.6875 against an exact 0.73580.7358: an error of 6.6%6.6\%.

Key termspercentage error
Exam tip

Always say why: a smaller hh gives a better approximation to the derivative, at the cost of more steps.

That's the notes covered.

Carry on to the next subtopic.

Exam questions on Numerical solution of differential equations

  1. The differential equation dydx=x+y\frac{dy}{dx}=x+y, with y=1y=1 when x=0x=0, is solved numerically using the approximation (dydx)n=yn+1−ynh\left(\frac{dy}{dx}\right)_n=\frac{y_{n+1}-y_n}{h} with h=0.2h=0.2. Here xn=0.2nx_n=0.2n and yny_n is the approximation to yy at xnx_n.
    Given that y3=1.856y_3=1.856, and that the exact solution is y=2ex−x−1y=2e^x-x-1, calculate the percentage error in y3y_3 as an approximation to y(0.6)y(0.6).2 marks
  2. The differential equation dydx=x−y\frac{dy}{dx}=x-y, with y=1y=1 when x=0x=0, is solved numerically using the approximation (dydx)n=yn+1−yn−12h\left(\frac{dy}{dx}\right)_n=\frac{y_{n+1}-y_{n-1}}{2h} with h=0.1h=0.1. Here xn=0.1nx_n=0.1n, y0=1y_0=1, and the value y1=0.9y_1=0.9 is found from the approximation (dydx)n=yn+1−ynh\left(\frac{dy}{dx}\right)_n=\frac{y_{n+1}-y_n}{h}.
    Find y3y_3.2 marks
  3. The function yy satisfies d2ydx2=−y\frac{d^2y}{dx^2}=-y, with y=0y=0 and dydx=1\frac{dy}{dx}=1 when x=0x=0. It is solved numerically with step length h=0.1h=0.1, where xn=0.1nx_n=0.1n and yny_n approximates yy at xnx_n, using (d2ydx2)n=yn+1−2yn+yn−1h2\left(\frac{d^2y}{dx^2}\right)_n=\frac{y_{n+1}-2y_n+y_{n-1}}{h^2} and (dydx)n=yn+1−yn−12h\left(\frac{dy}{dx}\right)_n=\frac{y_{n+1}-y_{n-1}}{2h}.
    Show that yn+1=1.99yn−yn−1y_{n+1}=1.99y_n-y_{n-1}.3 marks
See the full worksheet

Written by the Exaim team, led by Shaun Daswani (Head of Upper Secondary, Improve ME Institute; MSc Financial Mathematics, Imperial College London; BSc, UCL) and Jason Daswani (operational lead, Improve ME Institute; LSE).