5.18 · AHL · HL onlyPaper 1Paper 2Paper 3

First-order differential equations

In a minute

A links a function with its derivative, such as dydx=2y\frac{\mathrm{d}y}{\mathrm{d}x} = 2y. Solving it means finding the function. Three exact methods cover the course: separating the variables, y=vxy = vx and the . When none works, estimates the answer.

You'll be able to

  • Check that a function solves a differential equation, and use a given point to turn the into a .
  • Solve equations by separating the variables, including the with partial fractions.
  • Solve a dydx=f(yx)\frac{\mathrm{d}y}{\mathrm{d}x} = f\left(\frac{y}{x}\right) with the substitution y=vxy = vx.
  • Solve dydx+P(x)y=Q(x)\frac{\mathrm{d}y}{\mathrm{d}x} + P(x)y = Q(x) with an integrating factor.
  • Estimate a solution with Euler's method, and say whether the estimate is too big or too small.
Before you start3 quick questions on what this builds on
Check yourself
Find ∫2xx2+5 dx\int \frac{2x}{x^{2} + 5}\,\mathrm{d}x.
Check yourself
Find ∫2x(x+2) dx\int \frac{2}{x(x + 2)}\,\mathrm{d}x.
Check yourself
Find ∫xe−x dx\int x\mathrm{e}^{-x}\,\mathrm{d}x.

Revise first: 5.10 Indefinite integration and substitution, 5.15 Extended differentiation and integration and 5.16 Integration by substitution and parts

Differential equations and their solutions

Until now you differentiated a given function. A differential equation turns this round: it tells you about dydx\frac{\mathrm{d}y}{\mathrm{d}x}, and you find yy.

For example, dydx=2y\frac{\mathrm{d}y}{\mathrm{d}x} = 2y says the gradient is always twice the height. y=Ae2xy = A\mathrm{e}^{2x} works for any constant AA, since its derivative is 2Ae2x=2y2A\mathrm{e}^{2x} = 2y.

To check a solution, differentiate it and substitute into both sides. They must agree for every xx.

Worked exampleFind the particular solution of dydx=6x2−4\frac{\mathrm{d}y}{\mathrm{d}x} = 6x^{2} - 4 whose curve passes through (1,3)(1, 3).

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

  1. The right side depends only on xx, so integrate both sides with respect to xx: y=∫(6x2−4) dxy = \int (6x^{2} - 4)\,\mathrm{d}x.
Check yourself
Which function is a solution of dydx=−3y\frac{\mathrm{d}y}{\mathrm{d}x} = -3y?
Worked exampleFind the value of the constant kk for which y=kx3y = kx^{3} is a solution of xdydx−y=4x3x\frac{\mathrm{d}y}{\mathrm{d}x} - y = 4x^{3}.

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

  1. Differentiate the trial solution: dydx=3kx2\frac{\mathrm{d}y}{\mathrm{d}x} = 3kx^{2}.
Check yourself
Given dydx=3x\frac{\mathrm{d}y}{\mathrm{d}x} = \frac{3}{x} for x>0x > 0, and y=2y = 2 when x=1x = 1, find yy when x=e2x = \mathrm{e}^{2}.

Separating the variables

Many equations have the form dydx=f(x) g(y)\frac{\mathrm{d}y}{\mathrm{d}x} = f(x)\,g(y): a function of xx times a function of yy. Move every yy to one side with dy\mathrm{d}y, and every xx to the other with dx\mathrm{d}x. Then integrate each side.

Learn this
dydx=f(x) g(y)  ⇒  ∫1g(y) dy=∫f(x) dx\frac{\mathrm{d}y}{\mathrm{d}x} = f(x)\,g(y) \;\Rightarrow\; \int \frac{1}{g(y)}\,\mathrm{d}y = \int f(x)\,\mathrm{d}x

1. Divide and multiply so that yy and dy\mathrm{d}y are on the left, and xx and dx\mathrm{d}x are on the right.

2. Integrate both sides, and add + C+\,C straight away. One constant is enough: constants on both sides would combine into one.

3. Use the given point to find the constant, then rearrange into the form the question asks for.

Worked exampleSolve dydx=3x2y\frac{\mathrm{d}y}{\mathrm{d}x} = 3x^{2}y, given that y=5y = 5 when x=0x = 0. Give yy in terms of xx.

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

  1. Separate the variables: ∫1y dy=∫3x2 dx\int \frac{1}{y}\,\mathrm{d}y = \int 3x^{2}\,\mathrm{d}x.
Check yourself
Solve dydx=(2x+1)y\frac{\mathrm{d}y}{\mathrm{d}x} = (2x + 1)y, given that y=4y = 4 when x=0x = 0.
Worked exampleSolve exdydx=xy\mathrm{e}^{x}\frac{\mathrm{d}y}{\mathrm{d}x} = \frac{x}{y}, given that y=2y = 2 when x=0x = 0. Write your answer as y2=f(x)y^{2} = f(x).

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

  1. Multiply both sides by yy and by e−x\mathrm{e}^{-x}: ydydx=xe−xy\frac{\mathrm{d}y}{\mathrm{d}x} = x\mathrm{e}^{-x}, so ∫y dy=∫xe−x dx\int y\,\mathrm{d}y = \int x\mathrm{e}^{-x}\,\mathrm{d}x.
Check yourself
Given ydydx=4xy\frac{\mathrm{d}y}{\mathrm{d}x} = 4x, with y>0y > 0 and y=3y = 3 when x=1x = 1, find yy when x=2x = 2. Give your answer to 3 s.f.

The logistic equation

Some quantities grow fast at first and then level off, like a population with limited food. Growth slows to zero as the quantity nears a limit aa.

Take k>0k > 0. While nn is small, nn grows almost exponentially. Near aa, the factor a−na - n is close to zero, so growth almost stops.

dndt=0\frac{\mathrm{d}n}{\mathrm{d}t} = 0 when n=0n = 0 or n=an = a. These are equilibrium values. Start between them and nn rises towards aa without ever passing it.

The variables separate, but 1n(a−n)\frac{1}{n(a - n)} is not a standard integral. Split it into first, as in 5.15:

Learn this
1n(a−n)=1a(1n+1a−n)\frac{1}{n(a - n)} = \frac{1}{a}\left(\frac{1}{n} + \frac{1}{a - n}\right)
Worked exampleA rumour spreads through a school of 500500 students. The number NN who have heard it after tt days satisfies dNdt=0.002N(500−N)\frac{\mathrm{d}N}{\mathrm{d}t} = 0.002N(500 - N), and N=50N = 50 when t=0t = 0. Find NN in terms of tt.

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

  1. Separate: ∫1N(500−N) dN=∫0.002 dt\int \frac{1}{N(500 - N)}\,\mathrm{d}N = \int 0.002\,\mathrm{d}t.
S-shaped graph of N against t for t from 0 to 8 days. It starts at 50, rises slowly, climbs most steeply at t equals ln 9, about 2.2, where N is 250, then levels off just below a dashed horizontal line at N equals 500. t N 500 250 50 0 ln 9 4 8 steepest at N = 250
N=5001+9e−tN = \frac{500}{1 + 9\mathrm{e}^{-t}} climbs fastest at N=250N = 250, then levels off towards 500500.

As t→∞t \to \infty, e−t→0\mathrm{e}^{-t} \to 0, so N→500N \to 500. In general the same steps give n=a1+Be−aktn = \frac{a}{1 + B\mathrm{e}^{-akt}}, which tends to aa. Show the working rather than quoting this.

Check yourself
Which is the partial-fraction form of 1n(10−n)\frac{1}{n(10 - n)}?
Worked exampleFor the rumour model N=5001+9e−tN = \frac{500}{1 + 9\mathrm{e}^{-t}}, find the exact time when 400400 students have heard the rumour.

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

  1. Set N=400N = 400: 5001+9e−t=400\frac{500}{1 + 9\mathrm{e}^{-t}} = 400.
Check yourself
The equation dndt=0.1n(10−n)\frac{\mathrm{d}n}{\mathrm{d}t} = 0.1n(10 - n), with n=2n = 2 when t=0t = 0, has a solution of the form n=101+Be−tn = \frac{10}{1 + B\mathrm{e}^{-t}}. Find nn when t=1t = 1. Give your answer to 3 s.f.

Homogeneous equations

Some equations don't separate, such as dydx=x+2yx\frac{\mathrm{d}y}{\mathrm{d}x} = \frac{x + 2y}{x}. Divide the top and bottom by xx, though, and it becomes 1+2⋅yx1 + 2 \cdot \frac{y}{x}. It depends only on the ratio yx\frac{y}{x}.

A quick test: every term on the top and bottom has the same total power of xx and yy, as in x2+y2xy\frac{x^{2} + y^{2}}{xy}.

Call the ratio vv, so y=vxy = vx, where vv is a function of xx. The product rule gives dydx\frac{\mathrm{d}y}{\mathrm{d}x}:

Learn this
y=vx  ⇒  dydx=v+xdvdxy = vx \;\Rightarrow\; \frac{\mathrm{d}y}{\mathrm{d}x} = v + x\frac{\mathrm{d}v}{\mathrm{d}x}

Substituting gives a separable equation in vv and xx. Solve it, then replace vv by yx\frac{y}{x}.

Worked exampleUse the substitution y=vxy = vx to solve dydx=x+2yx\frac{\mathrm{d}y}{\mathrm{d}x} = \frac{x + 2y}{x} for x>0x > 0, given that y=3y = 3 when x=1x = 1.

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

  1. Write the right side in terms of vv: x+2yx=1+2v\frac{x + 2y}{x} = 1 + 2v.
Check yourself
Use y=vxy = vx to find the general solution of dydx=1+yx\frac{\mathrm{d}y}{\mathrm{d}x} = 1 + \frac{y}{x}, for x>0x > 0.
Worked exampleUse the substitution y=vxy = vx to solve dydx=x+3y3x+y\frac{\mathrm{d}y}{\mathrm{d}x} = \frac{x + 3y}{3x + y}, given that y=1y = 1 when x=3x = 3. Give your answer as an equation without logarithms.

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

  1. Divide the top and bottom by xx: the right side is 1+3v3+v\frac{1 + 3v}{3 + v}.
Check yourself
Use y=vxy = vx to solve dydx=x2+y2xy\frac{\mathrm{d}y}{\mathrm{d}x} = \frac{x^{2} + y^{2}}{xy} for x>0x > 0 and y>0y > 0, given that y=2y = 2 when x=1x = 1. Find yy when x=2x = 2, to 3 s.f.

The integrating factor

A linear first-order equation has the form dydx+P(x)y=Q(x)\frac{\mathrm{d}y}{\mathrm{d}x} + P(x)y = Q(x), where PP and QQ are functions of xx only. It usually doesn't separate. Instead, you multiply by a function that turns the left side into one derivative.

Read the product rule backwards: ddx(ex2y)=ex2dydx+2xex2y=ex2(dydx+2xy)\frac{\mathrm{d}}{\mathrm{d}x}\left(\mathrm{e}^{x^{2}}y\right) = \mathrm{e}^{x^{2}}\frac{\mathrm{d}y}{\mathrm{d}x} + 2x\mathrm{e}^{x^{2}}y = \mathrm{e}^{x^{2}}\left(\frac{\mathrm{d}y}{\mathrm{d}x} + 2xy\right). So ex2\mathrm{e}^{x^{2}} turns dydx+2xy\frac{\mathrm{d}y}{\mathrm{d}x} + 2xy into one derivative, and x2=∫2x dxx^{2} = \int 2x\,\mathrm{d}x.

In the formula booklet
e∫P(x) dx\mathrm{e}^{\int P(x)\,\mathrm{d}x}

The factor is in the formula booklet. The method is not:

1. Rearrange to dydx+P(x)y=Q(x)\frac{\mathrm{d}y}{\mathrm{d}x} + P(x)y = Q(x). If dydx\frac{\mathrm{d}y}{\mathrm{d}x} has a coefficient, divide the whole equation by it first.

2. Find I(x)=e∫P(x) dxI(x) = \mathrm{e}^{\int P(x)\,\mathrm{d}x}. You can leave out the constant of integration here.

3. Write ddx(I(x) y)=I(x) Q(x)\frac{\mathrm{d}}{\mathrm{d}x}\left(I(x)\,y\right) = I(x)\,Q(x). Integrate both sides, with + C+\,C.

4. Divide by I(x)I(x). The constant is divided too.

Learn this
I(x) y=∫I(x) Q(x) dxI(x)\,y = \int I(x)\,Q(x)\,\mathrm{d}x
Worked exampleSolve dydx=x+y\frac{\mathrm{d}y}{\mathrm{d}x} = x + y, given that y=1y = 1 when x=0x = 0.

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

  1. Rearrange: dydx−y=x\frac{\mathrm{d}y}{\mathrm{d}x} - y = x, so P(x)=−1P(x) = -1 and Q(x)=xQ(x) = x.
Check yourself
Find the integrating factor for dydx+3x2y=sin⁡x\frac{\mathrm{d}y}{\mathrm{d}x} + 3x^{2}y = \sin x.
Worked exampleSolve cos⁡x dydx+ysin⁡x=1\cos x\,\frac{\mathrm{d}y}{\mathrm{d}x} + y\sin x = 1 for −π2<x<π2-\frac{\pi}{2} < x < \frac{\pi}{2}, given that y=3y = 3 when x=0x = 0. Write yy as a function of xx.

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

  1. Divide by cos⁡x\cos x first, so that dydx\frac{\mathrm{d}y}{\mathrm{d}x} stands alone: dydx+ytan⁡x=sec⁡x\frac{\mathrm{d}y}{\mathrm{d}x} + y\tan x = \sec x. So P(x)=tan⁡xP(x) = \tan x.
Check yourself
Solve dydx+y=e−x\frac{\mathrm{d}y}{\mathrm{d}x} + y = \mathrm{e}^{-x}, given that y=2y = 2 when x=0x = 0. Find yy when x=1x = 1, to 3 s.f.

Euler's method

Many differential equations can't be solved exactly, such as dydx=x+y\frac{\mathrm{d}y}{\mathrm{d}x} = \sqrt{x + y}. But the equation gives the gradient at every point. So from a known point, take a small step hh along the tangent: yy changes by gradient ×\times step. Then repeat from the new point.

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), (x0,y0)(x_{0}, y_{0}) is the given point and hh is the constant step length. This is , and the formula is in the booklet.

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, y(0)=1y(0) = 1, solved exactly above: y(1)=2e−2≈3.44y(1) = 2\mathrm{e} - 2 \approx 3.44. Euler gives about 2.882.88 with h=0.25h = 0.25, and 3.313.31 with h=0.05h = 0.05.

Worked exampleGiven dydx=2x−y\frac{\mathrm{d}y}{\mathrm{d}x} = 2x - y and y=1y = 1 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)=2x−yf(x, y) = 2x - y, h=0.5h = 0.5, x0=0x_{0} = 0 and y0=1y_{0} = 1. Two steps take xx from 00 to 11. A table of xnx_{n}, yny_{n} and f(xn,yn)f(x_{n}, y_{n}) keeps it clear.
Check yourself
Given dydx=xy\frac{\mathrm{d}y}{\mathrm{d}x} = xy and y=2y = 2 when x=1x = 1, use Euler's method with h=0.1h = 0.1 to estimate yy when x=1.2x = 1.2. Give your answer to 3 s.f.

Too big or too small? Each step follows a tangent. From a point on a curve the tangent lies below the curve, so that step underestimates; on a curve it overestimates (see 5.8). With small steps the estimate stays on the same side, and that is the reason exam questions expect. With a large step it can fail: for dydx=−10y\frac{\mathrm{d}y}{\mathrm{d}x} = -10y, y(0)=1y(0) = 1 and h=0.2h = 0.2, Euler gives −1-1 and then 11, either side of the true curve.

To find the concavity, differentiate dydx=f(x,y)\frac{\mathrm{d}y}{\mathrm{d}x} = f(x, y) again, treating yy as a function of xx as in .

Worked exampleGiven dydx=x+y\frac{\mathrm{d}y}{\mathrm{d}x} = \sqrt{x + y} and y=3y = 3 when x=1x = 1, use Euler's method with step length 0.20.2 to estimate yy when x=2x = 2. Give your answer to 3 s.f. State, with a reason, whether it is an underestimate or an overestimate.

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

  1. Five steps take xx from 11 to 22. Write down the rule you will put into the calculator: yn+1=yn+0.2xn+yny_{n+1} = y_{n} + 0.2\sqrt{x_{n} + y_{n}} and xn+1=xn+0.2x_{n+1} = x_{n} + 0.2.
Check yourself
Euler's method is used on dydx=y2\frac{\mathrm{d}y}{\mathrm{d}x} = y^{2}, starting from y=1y = 1 at x=0x = 0 and stepping to x=0.5x = 0.5. On this interval y>0y > 0. What can you say about the estimate?

Common mistakes

  • Forgetting + C+\,C, or adding it only after rearranging. Add it the moment you integrate, then use the given point to find it.
  • Writing ex2+c\mathrm{e}^{x^{2} + c} as ex2+ec\mathrm{e}^{x^{2}} + \mathrm{e}^{c}. The constant multiplies, giving Aex2A\mathrm{e}^{x^{2}}.
  • Missing a factor from the inside when you integrate. ∫y4+y2 dy\int \frac{y}{4 + y^{2}}\,\mathrm{d}y is 12ln⁡(4+y2)+C\frac{1}{2}\ln(4 + y^{2}) + C, and ∫11−v dv\int \frac{1}{1 - v}\,\mathrm{d}v is −ln⁡∣1−v∣+C-\ln\lvert 1 - v\rvert + C. Differentiate back to check.
  • Finding the integrating factor before dividing through. For cos⁡x dydx+ysin⁡x=1\cos x\,\frac{\mathrm{d}y}{\mathrm{d}x} + y\sin x = 1, divide by cos⁡x\cos x first, so P(x)=tan⁡xP(x) = \tan x, not sin⁡x\sin x.
  • In Euler's method, using the new xx with the old yy, or reusing the first gradient. Recalculate f(xn,yn)f(x_{n}, y_{n}) at the current point every step, and count the steps you need.

Exam tips

  • “Solve” with a given point means find the particular solution, in the form the question asks for.
  • “Show that” the solution is a given equation: work forwards from the differential equation, and make your last line match the given result.
  • On Paper 2, write the Euler rule and the first step before the calculator value, and give the final estimate to 3 s.f.
  • For over- or underestimate, link concavity to the tangents: concave up means the tangents lie below the curve.

Key takeaways

Learn thisdydx=f(x) g(y)  ⇒  ∫1g(y) dy=∫f(x) dx\frac{\mathrm{d}y}{\mathrm{d}x} = f(x)\,g(y) \;\Rightarrow\; \int \frac{1}{g(y)}\,\mathrm{d}y = \int f(x)\,\mathrm{d}x
Learn thisy=vx  ⇒  dydx=v+xdvdxy = vx \;\Rightarrow\; \frac{\mathrm{d}y}{\mathrm{d}x} = v + x\frac{\mathrm{d}v}{\mathrm{d}x}
In booklete∫P(x) dx\mathrm{e}^{\int P(x)\,\mathrm{d}x}
Learn thisI(x) y=∫I(x) Q(x) dxI(x)\,y = \int I(x)\,Q(x)\,\mathrm{d}x
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
Learn thisThe general solution has one arbitrary constant. A given point fixes it and gives the particular solution.
Learn thisSeparable: ∫1g(y) dy=∫f(x) dx\int \frac{1}{g(y)}\,\mathrm{d}y = \int f(x)\,\mathrm{d}x. Add + C+\,C as soon as you integrate, and remember ef(x)+c=Aef(x)\mathrm{e}^{f(x) + c} = A\mathrm{e}^{f(x)}.
Learn thisLogistic dndt=kn(a−n)\frac{\mathrm{d}n}{\mathrm{d}t} = kn(a - n): separate, use partial fractions, and get n=a1+Be−aktn = \frac{a}{1 + B\mathrm{e}^{-akt}}, which tends to aa.
Learn thisHomogeneous dydx=f(yx)\frac{\mathrm{d}y}{\mathrm{d}x} = f\left(\frac{y}{x}\right): put y=vxy = vx, so dydx=v+xdvdx\frac{\mathrm{d}y}{\mathrm{d}x} = v + x\frac{\mathrm{d}v}{\mathrm{d}x}, then separate.
In bookletLinear dydx+P(x)y=Q(x)\frac{\mathrm{d}y}{\mathrm{d}x} + P(x)y = Q(x): multiply by I(x)=e∫P(x) dxI(x) = \mathrm{e}^{\int P(x)\,\mathrm{d}x}, then I(x) y=∫I(x) Q(x) dxI(x)\,y = \int I(x)\,Q(x)\,\mathrm{d}x.
In bookletEuler: yn+1=yn+h×f(xn,yn)y_{n+1} = y_{n} + h \times f(x_{n}, y_{n}). With small steps, a concave-up curve gives an underestimate and a concave-down curve an overestimate.

Practise this

27 past-paper questions on 5.18 in the AA HL bank, each with a mark scheme and a worked explanation.

Practise 5.18 →