Skip to main content
Examonaut

Topic 6 · Lesson 2 of 4

Second order differential equations

Approximating the second derivative

The gradient just after xrx_r is about yr+1−yrh\frac{y_{r+1} - y_r}{h}, and just before it is about yr−yr−1h\frac{y_r - y_{r-1}}{h}. The second derivative is the rate of change of the gradient, so

(d2ydx2)r≈yr+1−yrh−yr−yr−1hh=yr+1−2yr+yr−1h2\left(\frac{d^2y}{dx^2}\right)_r \approx \frac{\frac{y_{r+1} - y_r}{h} - \frac{y_r - y_{r-1}}{h}}{h} = \frac{y_{r+1} - 2y_r + y_{r-1}}{h^2}

Together with (dydx)r≈yr+1−yr−12h\left(\frac{dy}{dx}\right)_r \approx \frac{y_{r+1} - y_{r-1}}{2h}, these turn a second order differential equation into a formula for yr+1y_{r+1} in terms of yry_r and yr−1y_{r-1} (a recurrence relation).

The method

  1. Substitute the approximations into the differential equation at x=xrx = x_r.
  2. Multiply by h2h^2 and rearrange to make yr+1y_{r+1} the subject.
  3. Find y1y_1. If y1y_1 is not given, use the condition on dydx\frac{dy}{dx} at x0x_0: the central approximation (dydx)0≈y1−y−12h\left(\frac{dy}{dx}\right)_0 \approx \frac{y_1 - y_{-1}}{2h} gives y−1y_{-1} in terms of y1y_1, and putting r=0r = 0 in the recurrence then gives an equation for y1y_1.
  4. Use the recurrence for y2y_2, y3y_3, and so on.

Worked example

A second order equation

Given d2ydx2=2y−x\frac{d^2y}{dx^2} = 2y - x, with y=1y = 1 and dydx=1\frac{dy}{dx} = 1 at x=0x = 0, estimate yy at x=0.2x = 0.2 using h=0.1h = 0.1.

Show solution
  1. yr+1−2yr+yr−10.01=2yr−xr\frac{y_{r+1} - 2y_r + y_{r-1}}{0.01} = 2y_r - x_r, so yr+1=2.02yr−yr−1−0.01xry_{r+1} = 2.02y_r - y_{r-1} - 0.01x_r.
  2. From y1−y−10.2=1\frac{y_1 - y_{-1}}{0.2} = 1: y−1=y1−0.2y_{-1} = y_1 - 0.2.
  3. With r=0r = 0: y1=2.02−(y1−0.2)−0y_1 = 2.02 - (y_1 - 0.2) - 0, so 2y1=2.222y_1 = 2.22 and y1=1.11y_1 = 1.11.
  4. With r=1r = 1: y2=2.02×1.11−1−0.01×0.1=1.2412y_2 = 2.02 \times 1.11 - 1 - 0.01 \times 0.1 = 1.2412.

The exact value is about 1.24161.2416, so the method does well over short distances.

Equations with a first derivative term

If the equation contains dydx\frac{dy}{dx}, use the central approximation for it as well. Then yr+1y_{r+1} appears in two places; collect those terms before dividing. For example d2ydx2+xdydx=1\frac{d^2y}{dx^2} + x\frac{dy}{dx} = 1 with h=0.1h = 0.1 gives

yr+1−2yr+yr−1+0.05xr(yr+1−yr−1)=0.01y_{r+1} - 2y_r + y_{r-1} + 0.05x_r(y_{r+1} - y_{r-1}) = 0.01

so (1+0.05xr)yr+1=2yr−(1−0.05xr)yr−1+0.01(1 + 0.05x_r)y_{r+1} = 2y_r - (1 - 0.05x_r)y_{r-1} + 0.01.

Practise this topic

Both are part of Premium.