31.5 The Integrating Factor Method

AHL 5.18

In this section you will learn
  • how to recognise a linear first order equation \(\dfrac{\mathrm{d}y}{\mathrm{d}x} + P(x)\,y = Q(x)\)
  • why the integrating factor \(\mathrm{e}^{\int P(x)\,\mathrm{d}x}\) works
  • how to solve these equations in four steps

Equations such as \(\dfrac{\mathrm{d}y}{\mathrm{d}x} + 2y = 4x\) are not separable, so the methods of Section 31.3 do not work. The integrating factor method solves them.

Where the integrating factor comes from

We want to solve a differential equation in the standard form

\[ \frac{\mathrm{d}y}{\mathrm{d}x} + P(x)\,y = Q(x) . \qquad \text{(a)} \]

Key idea: the product rule

For any function \(I(x)\),

\[ \frac{\mathrm{d}}{\mathrm{d}x}\big(I(x)\,y\big) = I(x)\frac{\mathrm{d}y}{\mathrm{d}x} + \boxed{I'(x)}\,y . \qquad \text{(b)} \]

If an expression has the form of the right-hand side of (b), we can integrate it at once: it simply goes back to \(I(x)\,y\).

We want to make the left side of (a) look like (b). Multiply (a) by \(I(x)\):

\[ {\color{#9F353A}I(x)}\frac{\mathrm{d}y}{\mathrm{d}x} + \boxed{{\color{#9F353A}I(x)}\,P(x)}\,y = {\color{#9F353A}I(x)}\,Q(x) . \]

Compare the boxed terms with (b). If \(I(x)P(x) = I'(x)\), the left side is exactly (b):

\[ \begin{aligned} I(x)\frac{\mathrm{d}y}{\mathrm{d}x} + I'(x)\,y &= I(x)\,Q(x) \\ \frac{\mathrm{d}}{\mathrm{d}x}\big(I(x)\,y\big) &= I(x)\,Q(x) && {\color{#9F353A}\text{product rule (b)}} \\ \int \frac{\mathrm{d}}{\mathrm{d}x}\big(I(x)\,y\big)\,\mathrm{d}x &= \int I(x)\,Q(x)\,\mathrm{d}x && {\color{#9F353A}\text{integrate both sides}} \\ I(x)\,y &= \int I(x)\,Q(x)\,\mathrm{d}x + c \\ y &= \frac{1}{I(x)}\left(\int I(x)\,Q(x)\,\mathrm{d}x + c\right) \end{aligned} \]

Finding \(I(x)\). We need a function with \(I'(x) = I(x)\,P(x)\). This is a separable equation:

\[ \begin{aligned} \frac{I'(x)}{I(x)} &= P(x) \\ \int \frac{I'(x)}{I(x)}\,\mathrm{d}x &= \int P(x)\,\mathrm{d}x \\ \ln\lvert I(x)\rvert &= \int P(x)\,\mathrm{d}x + c \\ I(x) &= A\,\mathrm{e}^{\int P(x)\,\mathrm{d}x} && {\color{#9F353A}\text{take } I(x) > 0,\ A = \mathrm{e}^c} \end{aligned} \]

Any non-zero \(A\) works, so we choose \(A = 1\). This function \(I(x) = \mathrm{e}^{\int P(x)\,\mathrm{d}x}\) is called the integrating factor.

The integrating factor method Partly in the HL formula booklet

For \(y' + P(x)y = Q(x)\), that is \(\dfrac{\mathrm{d}y}{\mathrm{d}x} + P(x)\,y = Q(x)\):

  1. Find the integrating factor \(I(x) = \mathrm{e}^{\int P(x)\,\mathrm{d}x}\). (No constant is needed here.) In the HL booklet
  2. Multiply both sides of the equation by \(I(x)\).
  3. The left-hand side is now \(\dfrac{\mathrm{d}}{\mathrm{d}x}\big(I(x)\,y\big)\), so \(\;I(x)\,y = \displaystyle\int I(x)\,Q(x)\,\mathrm{d}x + c\).
  4. Divide by \(I(x)\) to get the general solution. Use the initial condition to find \(c\).
  • \(P(x)\): the function of \(x\) that multiplies \(y\)
  • \(Q(x)\): the function of \(x\) on the right-hand side
  • \(I(x)\): the integrating factor
  • \(c\): a constant of integration

The steps of the method are not in the booklet.

Important. The coefficient of \(\dfrac{\mathrm{d}y}{\mathrm{d}x}\) must be 1 before you find \(P(x)\). If the equation is \(x\dfrac{\mathrm{d}y}{\mathrm{d}x} + \ldots\), divide by \(x\) first.

Useful facts: \(\mathrm{e}^{\ln f(x)} = f(x)\), \(\;\mathrm{e}^{k\ln x} = x^k\), \(\;\mathrm{e}^{-\ln x} = \dfrac{1}{x}\).

Example 1 Solve \(\dfrac{\mathrm{d}y}{\mathrm{d}x} + 2y = 4x + \mathrm{e}^{-x}\), given that \(y(0) = 2\).

\(P(x) = 2\), so \(I(x) = \mathrm{e}^{\int 2\,\mathrm{d}x} = \mathrm{e}^{2x}\).

Multiply: \(\;\dfrac{\mathrm{d}}{\mathrm{d}x}\left(y\,\mathrm{e}^{2x}\right) = 4x\,\mathrm{e}^{2x} + \mathrm{e}^{x}\).

Integrate (by parts for the first term: \(\int 4x\,\mathrm{e}^{2x}\,\mathrm{d}x = 2x\,\mathrm{e}^{2x} - \mathrm{e}^{2x}\)):

\[ y\,\mathrm{e}^{2x} = 2x\,\mathrm{e}^{2x} - \mathrm{e}^{2x} + \mathrm{e}^{x} + c \quad\Rightarrow\quad y = 2x - 1 + \mathrm{e}^{-x} + c\,\mathrm{e}^{-2x} . \]

\(y(0) = 2\): \(\;2 = 0 - 1 + 1 + c\), so \(c = 2\). \(\qquad y = 2x - 1 + \mathrm{e}^{-x} + 2\mathrm{e}^{-2x}\).

Example 2 Find the general solution of \(\;x\dfrac{\mathrm{d}y}{\mathrm{d}x} + (x + 2)\,y = 2\), for \(x > 0\).

Divide by \(x\) to get the standard form: \(\;\dfrac{\mathrm{d}y}{\mathrm{d}x} + \left(1 + \dfrac{2}{x}\right)y = \dfrac{2}{x}\).

\(\displaystyle\int \left(1 + \frac{2}{x}\right)\mathrm{d}x = x + 2\ln x\), so \(I(x) = \mathrm{e}^{x + 2\ln x} = \mathrm{e}^x \times \mathrm{e}^{2\ln x} = x^2\mathrm{e}^x\).

Multiply: \(\;\dfrac{\mathrm{d}}{\mathrm{d}x}\left(x^2\mathrm{e}^x\,y\right) = x^2\mathrm{e}^x \times \dfrac{2}{x} = 2x\,\mathrm{e}^x\).

By parts, \(\displaystyle\int 2x\,\mathrm{e}^x\,\mathrm{d}x = 2x\,\mathrm{e}^x - 2\mathrm{e}^x\). So

\[ x^2\mathrm{e}^x\,y = 2\mathrm{e}^x(x - 1) + c \quad\Rightarrow\quad y = \frac{2(x - 1)}{x^2} + \frac{c\,\mathrm{e}^{-x}}{x^2} . \]

Example 3 In Section 31.2 we used Euler’s method for \(\dfrac{\mathrm{d}y}{\mathrm{d}x} = y - x^2\), \(y(0) = 1\), and found \(y(0.5) \approx 1.578\). Solve this equation exactly and find \(y(0.5)\).

Standard form: \(\dfrac{\mathrm{d}y}{\mathrm{d}x} - y = -x^2\). \(\;P(x) = -1\), \(I(x) = \mathrm{e}^{-x}\).

\(\dfrac{\mathrm{d}}{\mathrm{d}x}\left(y\,\mathrm{e}^{-x}\right) = -x^2\mathrm{e}^{-x}\). By parts twice, \(\displaystyle\int -x^2\mathrm{e}^{-x}\,\mathrm{d}x = (x^2 + 2x + 2)\,\mathrm{e}^{-x}\).

\(y\,\mathrm{e}^{-x} = (x^2 + 2x + 2)\,\mathrm{e}^{-x} + c \Rightarrow y = x^2 + 2x + 2 + c\,\mathrm{e}^{x}\).

\(y(0) = 1\): \(1 = 2 + c\), \(c = -1\). \(\qquad y = x^2 + 2x + 2 - \mathrm{e}^x\).

\(y(0.5) = 0.25 + 1 + 2 - \mathrm{e}^{0.5} = 3.25 - \sqrt{\mathrm{e}} = 1.601\) (4 s.f.). The Euler estimate was about \(1.4\%\) too small.

Common errors

✗ Wrong ✓ Right Why
Finding \(P(x)\) from \(x\frac{\mathrm{d}y}{\mathrm{d}x} + 2y = \ldots\) as \(P = 2\) Divide by \(x\) first: \(P = \frac{2}{x}\) The method needs the standard form.
\(I(x) = \mathrm{e}^{\int P\,\mathrm{d}x + c}\) \(I(x) = \mathrm{e}^{\int P\,\mathrm{d}x}\) Any multiple works; the constant is not needed.
Multiplying only the left side by \(I(x)\) Multiply both sides Otherwise the equation changes.
\(I(x)\,y = \int I(x)Q(x)\,\mathrm{d}x\), then \(y = \ldots + c\) Add \(c\) before dividing by \(I(x)\) The constant is also divided: \(c\,\mathrm{e}^{-2x}\), not \(c\).
Wrong sign of \(P(x)\) \(y' - y = \ldots\) has \(P(x) = -1\) Keep the sign with \(P\).

Exercises

1 Solve \(\dfrac{\mathrm{d}y}{\mathrm{d}x} + 3y = 6\), given that \(y(0) = 0\).

\(I = \mathrm{e}^{3x}\). \(\;(y\,\mathrm{e}^{3x})' = 6\mathrm{e}^{3x} \Rightarrow y\,\mathrm{e}^{3x} = 2\mathrm{e}^{3x} + c \Rightarrow y = 2 + c\,\mathrm{e}^{-3x}\).

\(y(0) = 0\): \(c = -2\). \(\qquad y = 2 - 2\mathrm{e}^{-3x}\).

2 Solve \(\dfrac{\mathrm{d}y}{\mathrm{d}x} + \dfrac{y}{x} = \sqrt{x}\), \(x > 0\), given that \(y(1) = 1\).

\(I = \mathrm{e}^{\ln x} = x\). \(\;(xy)' = x^{\frac{3}{2}} \Rightarrow xy = \dfrac{2}{5}x^{\frac{5}{2}} + c\).

\(y(1) = 1\): \(1 = \dfrac{2}{5} + c\), \(c = \dfrac{3}{5}\). \(\qquad y = \dfrac{2}{5}x^{\frac{3}{2}} + \dfrac{3}{5x}\).

3 Solve \(\dfrac{\mathrm{d}y}{\mathrm{d}x} - 2xy = x\), given that \(y(0) = 1\).

\(I = \mathrm{e}^{-x^2}\). \(\;(y\,\mathrm{e}^{-x^2})' = x\,\mathrm{e}^{-x^2} \Rightarrow y\,\mathrm{e}^{-x^2} = -\dfrac{1}{2}\mathrm{e}^{-x^2} + c \Rightarrow y = -\dfrac{1}{2} + c\,\mathrm{e}^{x^2}\).

\(y(0) = 1\): \(c = \dfrac{3}{2}\). \(\qquad y = \dfrac{3}{2}\mathrm{e}^{x^2} - \dfrac{1}{2}\).

4 Find the general solution of \(\dfrac{\mathrm{d}y}{\mathrm{d}x} + y = x\,\mathrm{e}^{-x}\).

\(I = \mathrm{e}^{x}\). \(\;(y\,\mathrm{e}^{x})' = x \Rightarrow y\,\mathrm{e}^{x} = \dfrac{x^2}{2} + c \Rightarrow y = \left(\dfrac{x^2}{2} + c\right)\mathrm{e}^{-x}\).

5 Solve \(x\dfrac{\mathrm{d}y}{\mathrm{d}x} + 2y = x^2\), \(x > 0\), given that \(y(1) = 0\).

Standard form: \(y' + \dfrac{2}{x}y = x\). \(\;I = \mathrm{e}^{2\ln x} = x^2\). \(\;(x^2 y)' = x^3 \Rightarrow x^2 y = \dfrac{x^4}{4} + c\).

\(y(1) = 0\): \(c = -\dfrac{1}{4}\). \(\qquad y = \dfrac{x^4 - 1}{4x^2}\).

6 Solve \(\dfrac{\mathrm{d}y}{\mathrm{d}x} + y\tan x = \sec x\), \(-\dfrac{\pi}{2} < x < \dfrac{\pi}{2}\), given that \(y(0) = 2\).

\(\displaystyle\int \tan x\,\mathrm{d}x = -\ln(\cos x)\), so \(I = \mathrm{e}^{-\ln\cos x} = \dfrac{1}{\cos x} = \sec x\).

\((y\sec x)' = \sec^2 x \Rightarrow y\sec x = \tan x + c \Rightarrow y = \sin x + c\cos x\).

\(y(0) = 2\): \(c = 2\). \(\qquad y = \sin x + 2\cos x\).

7 Solve \(\sin x\dfrac{\mathrm{d}y}{\mathrm{d}x} + 2y\cos x = \cos x\), \(0 < x < \pi\), given that \(y = 0\) when \(x = \dfrac{\pi}{2}\).

Standard form: \(y' + 2\cot x\,y = \cot x\). \(\;\displaystyle\int 2\cot x\,\mathrm{d}x = 2\ln(\sin x)\), so \(I = \sin^2 x\).

\((y\sin^2 x)' = \sin x\cos x \Rightarrow y\sin^2 x = \dfrac{\sin^2 x}{2} + c\).

\(x = \dfrac{\pi}{2}\): \(0 = \dfrac{1}{2} + c\), \(c = -\dfrac{1}{2}\). \(\qquad y = \dfrac{1}{2} - \dfrac{1}{2\sin^2 x} = -\dfrac{1}{2}\cot^2 x\).

8 Solve \((x + 1)\dfrac{\mathrm{d}y}{\mathrm{d}x} - y = (x + 1)^2\), \(x > -1\), given that \(y(0) = 3\).

Standard form: \(y' - \dfrac{1}{x + 1}y = x + 1\). \(\;I = \mathrm{e}^{-\ln(x + 1)} = \dfrac{1}{x + 1}\).

\(\left(\dfrac{y}{x + 1}\right)' = 1 \Rightarrow \dfrac{y}{x + 1} = x + c\). \(\;y(0) = 3\): \(c = 3\). \(\qquad y = (x + 1)(x + 3)\).

9 A small ball falls from rest. Its velocity \(v\) m s−1 after \(t\) seconds satisfies \(\dfrac{\mathrm{d}v}{\mathrm{d}t} + 0.2v = 9.8\).

(a) Find \(v\) in terms of \(t\).

(b) Find the limiting (terminal) velocity.

(c) Find the time taken to reach \(99\%\) of this velocity.

(a) \(I = \mathrm{e}^{0.2t}\). \(\;(v\,\mathrm{e}^{0.2t})' = 9.8\mathrm{e}^{0.2t} \Rightarrow v\,\mathrm{e}^{0.2t} = 49\mathrm{e}^{0.2t} + c\). \(v(0) = 0\): \(c = -49\). \(\qquad v = 49\left(1 - \mathrm{e}^{-0.2t}\right)\).

(b) As \(t \to \infty\), \(\mathrm{e}^{-0.2t} \to 0\), so \(v \to 49\) m s−1.

(c) \(1 - \mathrm{e}^{-0.2t} = 0.99 \Rightarrow \mathrm{e}^{-0.2t} = 0.01 \Rightarrow t = 5\ln 100 = 23.0\) s.

10 A tank contains 50 litres of pure water. Salt water containing \(0.1\) kg of salt per litre flows in at 3 litres per minute, and the well-mixed liquid flows out at 2 litres per minute. After \(t\) minutes the tank holds \((50 + t)\) litres and \(S\) kg of salt, where

\[ \frac{\mathrm{d}S}{\mathrm{d}t} = 0.3 - \frac{2S}{50 + t} . \]

Find \(S\) in terms of \(t\), and the amount of salt after 50 minutes.

\(\dfrac{\mathrm{d}S}{\mathrm{d}t} + \dfrac{2}{50 + t}S = 0.3\). \(\;I = \mathrm{e}^{2\ln(50 + t)} = (50 + t)^2\).

\(\big((50 + t)^2 S\big)' = 0.3(50 + t)^2 \Rightarrow (50 + t)^2 S = 0.1(50 + t)^3 + c\).

\(S(0) = 0\): \(c = -0.1 \times 50^3 = -12\,500\). \(\qquad S = 0.1(50 + t) - \dfrac{12\,500}{(50 + t)^2}\).

\(t = 50\): \(S = 10 - \dfrac{12\,500}{10\,000} = 8.75\) kg.