Skip to content
Family Table Math
Auto

The Integrating Factor

An equation like dydx+2y=ex\dfrac{dy}{dx} + 2y = e^x can’t be separated: the yy and the exe^x are added, not multiplied. But it is linear in yy, and every linear first-order equation can be solved the same way: multiply through by a carefully chosen function, the integrating factor, and the left side becomes the derivative of a product. This is the last of the exact methods in IB Mathematics AA HL, alongside separation of variables and homogeneous equations.

Linear first-order equations in standard form

Section titled “Linear first-order equations in standard form”

A first-order differential equation is linear if it can be written in the standard form

dydx+P(x) y=Q(x)\frac{dy}{dx} + P(x)\,y = Q(x)

where PP and QQ are functions of xx only. The coefficient of dydx\dfrac{dy}{dx} must be 11. If it isn’t, divide through first. For example, xdydx+2y=x2x\dfrac{dy}{dx} + 2y = x^2 becomes dydx+2x y=x\dfrac{dy}{dx} + \dfrac{2}{x}\,y = x, so P(x)=2xP(x) = \dfrac{2}{x} and Q(x)=xQ(x) = x.

Watch the sign: dydx−3y=x\dfrac{dy}{dx} - 3y = x has P(x)=−3P(x) = -3.

The integrating factor is

I(x)=e∫P(x) dxI(x) = e^{\int P(x)\,dx}

You don’t need a +C+ C in this integral: any one antiderivative works.

The integrating factor is chosen so that I′(x)=P(x) I(x)I'(x) = P(x)\,I(x) (by the chain rule). Multiply the standard form by I(x)I(x):

Idydx+P I y=I Q⇒Idydx+I′ y=I QI\frac{dy}{dx} + P\,I\,y = I\,Q \quad\Rightarrow\quad I\frac{dy}{dx} + I'\,y = I\,Q

The left side is exactly the product rule for ddx(I y)\dfrac{d}{dx}(I\,y). So

ddx(I(x) y)=I(x) Q(x)⇒I(x) y=∫I(x) Q(x) dx+C\frac{d}{dx}\big(I(x)\,y\big) = I(x)\,Q(x) \quad\Rightarrow\quad I(x)\,y = \int I(x)\,Q(x)\,dx + C

Divide by I(x)I(x) to get yy. Notice that the +C+ C gets divided by I(x)I(x) too.

  1. Rearrange into standard form and read off P(x)P(x) and Q(x)Q(x).
  2. Find I(x)=e∫P dxI(x) = e^{\int P\,dx} and simplify it. Useful facts: eln⁡x=xe^{\ln x} = x, e2ln⁡x=x2e^{2\ln x} = x^2, e−ln⁡x=1xe^{-\ln x} = \dfrac{1}{x}, e−ln⁡cos⁡x=sec⁡xe^{-\ln \cos x} = \sec x.
  3. Multiply through, and write the left side as ddx(I y)\dfrac{d}{dx}\big(I\,y\big).
  4. Integrate both sides, with +C+ C on the right. You may need integration by parts or a substitution.
  5. Solve for yy, then use any initial condition to find CC.

Check by substituting back: it only takes a minute and catches sign errors.

Some equations are both separable and linear (like dydx=3−y\dfrac{dy}{dx} = 3 - y). Either method works and gives the same answer.

Solve dydx+2y=ex\dfrac{dy}{dx} + 2y = e^x, given that y=1y = 1 when x=0x = 0.

Solution. It is already in standard form, with P(x)=2P(x) = 2 and Q(x)=exQ(x) = e^x. The integrating factor is I(x)=e∫2 dx=e2xI(x) = e^{\int 2\,dx} = e^{2x}. Multiply through:

e2xdydx+2e2xy=e3xddx(e2xy)=e3xe2xy=13e3x+Cy=13ex+Ce−2x\begin{aligned} e^{2x}\frac{dy}{dx} + 2e^{2x}y &= e^{3x} \\ \frac{d}{dx}\left(e^{2x}y\right) &= e^{3x} \\ e^{2x}y &= \frac{1}{3}e^{3x} + C \\ y &= \frac{1}{3}e^{x} + Ce^{-2x} \end{aligned}

At x=0x = 0: 1=13+C1 = \dfrac{1}{3} + C, so C=23C = \dfrac{2}{3} and

y=13ex+23e−2xy = \frac{1}{3}e^x + \frac{2}{3}e^{-2x}

Check: dydx+2y=(13ex−43e−2x)+(23ex+43e−2x)=ex\dfrac{dy}{dx} + 2y = \left(\dfrac{1}{3}e^x - \dfrac{4}{3}e^{-2x}\right) + \left(\dfrac{2}{3}e^x + \dfrac{4}{3}e^{-2x}\right) = e^x. ✓

Solution curves y = e^x/3 + Ce^(-2x) of dy/dx + 2y = e^x. Whatever the value of C, the curves merge with the dashed curve y = e^x/3 as x increases. The particular solution with C = 2/3 passes through (0, 1). −1 1 2 −1 1 2 3 (0, 1) y = eˣ/3 C = 2/3
Solutions of dydx+2y=ex\frac{dy}{dx} + 2y = e^x. The term Ce−2xCe^{-2x} dies away, so every solution ends up following y=13exy = \frac{1}{3}e^x.

Example 2: Rearranging into standard form first

Section titled “Example 2: Rearranging into standard form first”

Solve xdydx+2y=x2x\dfrac{dy}{dx} + 2y = x^2 for x>0x \gt 0, given that y=1y = 1 when x=1x = 1.

Solution. Divide by xx: dydx+2x y=x\dfrac{dy}{dx} + \dfrac{2}{x}\,y = x. Then

I(x)=e∫2x dx=e2ln⁡x=eln⁡x2=x2I(x) = e^{\int \frac{2}{x}\,dx} = e^{2\ln x} = e^{\ln x^2} = x^2

(For x>0x \gt 0 we can drop the absolute value in ln⁡∣x∣\ln|x|.) Multiply through by x2x^2:

x2dydx+2xy=x3ddx(x2y)=x3x2y=x44+Cy=x24+Cx2\begin{aligned} x^2\frac{dy}{dx} + 2xy &= x^3 \\ \frac{d}{dx}\left(x^2y\right) &= x^3 \\ x^2y &= \frac{x^4}{4} + C \\ y &= \frac{x^2}{4} + \frac{C}{x^2} \end{aligned}

At (1,1)(1, 1): 1=14+C1 = \dfrac{1}{4} + C, so C=34C = \dfrac{3}{4} and y=x24+34x2y = \dfrac{x^2}{4} + \dfrac{3}{4x^2}.

Example 3: A trigonometric integrating factor

Section titled “Example 3: A trigonometric integrating factor”

Solve dydx+ytan⁡x=cos⁡x\dfrac{dy}{dx} + y\tan x = \cos x for −π2<x<π2-\dfrac{\pi}{2} \lt x \lt \dfrac{\pi}{2}, given that y(0)=2y(0) = 2. (Radians.)

Solution. P(x)=tan⁡xP(x) = \tan x. Since ∫tan⁡x dx=−ln⁡∣cos⁡x∣\displaystyle\int \tan x\,dx = -\ln|\cos x| and cos⁡x>0\cos x \gt 0 on this interval,

I(x)=e−ln⁡cos⁡x=1cos⁡x=sec⁡xI(x) = e^{-\ln \cos x} = \frac{1}{\cos x} = \sec x

Multiply through by sec⁡x\sec x. On the right, cos⁡xsec⁡x=1\cos x \sec x = 1:

ddx(ysec⁡x)=1⇒ysec⁡x=x+C⇒y=(x+C)cos⁡x\frac{d}{dx}\left(y\sec x\right) = 1 \quad\Rightarrow\quad y\sec x = x + C \quad\Rightarrow\quad y = (x + C)\cos x

At x=0x = 0: 2=(0+C)(1)2 = (0 + C)(1), so C=2C = 2 and y=(x+2)cos⁡xy = (x + 2)\cos x.

A tank holds 5050 L of pure water. Brine containing 22 g of salt per litre flows in at 33 L/min, and the well-mixed solution flows out at 22 L/min. Let SS be the mass of salt (in grams) in the tank after tt minutes.

(a) Explain why dSdt=6−2S50+t\dfrac{dS}{dt} = 6 - \dfrac{2S}{50 + t}.

(b) Solve the differential equation, and find the concentration of salt after 5050 minutes.

Solution.

(a) Salt flows in at (2 g/L)(3 L/min)=6(2 \text{ g/L})(3 \text{ L/min}) = 6 g/min. The volume grows by 11 L each minute, so it is 50+t50 + t litres, and the concentration is S50+t\dfrac{S}{50 + t} g/L. Salt flows out at S50+t×2\dfrac{S}{50 + t} \times 2 g/min. Rate of change = rate in − rate out.

(b) Standard form: dSdt+250+t S=6\dfrac{dS}{dt} + \dfrac{2}{50 + t}\,S = 6. The integrating factor is

I(t)=e∫250+t dt=e2ln⁡(50+t)=(50+t)2I(t) = e^{\int \frac{2}{50 + t}\,dt} = e^{2\ln(50 + t)} = (50 + t)^2

So

ddt((50+t)2S)=6(50+t)2(50+t)2S=2(50+t)3+C\begin{aligned} \frac{d}{dt}\Big((50 + t)^2 S\Big) &= 6(50 + t)^2 \\ (50 + t)^2 S &= 2(50 + t)^3 + C \end{aligned}

At t=0t = 0 the water is pure, so S=0S = 0: 0=2(50)3+C0 = 2(50)^3 + C, giving C=−250 000C = -250\,000. Then

S=2(50+t)−250 000(50+t)2S = 2(50 + t) - \frac{250\,000}{(50 + t)^2}

At t=50t = 50: S=2(100)−250 00010 000=200−25=175S = 2(100) - \dfrac{250\,000}{10\,000} = 200 - 25 = 175 g, in 100100 L of solution. The concentration is 1.751.75 g/L. (In the long run it approaches the inflow concentration of 22 g/L, which makes sense.)

Not dividing by the coefficient of dy/dx first. The integrating factor formula only works when the equation starts dydx+…\dfrac{dy}{dx} + \ldots. For xdydx+2y=x2x\dfrac{dy}{dx} + 2y = x^2, the P(x)P(x) is 2x\dfrac{2}{x}, not 22.

Getting the sign of P wrong. For dydx−2xy=…\dfrac{dy}{dx} - \dfrac{2}{x}y = \ldots, P(x)=−2xP(x) = -\dfrac{2}{x} and I(x)=e−2ln⁡x=x−2I(x) = e^{-2\ln x} = x^{-2}. Move every yy term to the left before reading off PP.

Forgetting to multiply the right side by I(x). Both sides get multiplied. The left side becomes ddx(Iy)\dfrac{d}{dx}(Iy) automatically; the right side becomes I(x)Q(x)I(x)Q(x), which is what you integrate.

Dividing only part of the answer by I(x). From e2xy=13e3x+Ce^{2x}y = \dfrac{1}{3}e^{3x} + C, the solution is y=13ex+Ce−2xy = \dfrac{1}{3}e^x + Ce^{-2x}, not 13ex+C\dfrac{1}{3}e^x + C. The constant gets divided too, and that’s what makes the solution curves different shapes.

Not simplifying the integrating factor. Leaving I(x)=e2ln⁡xI(x) = e^{2\ln x} makes the next step messy. Use log laws: e2ln⁡x=x2e^{2\ln x} = x^2.

Adding the constant too late. The +C+ C belongs on the right as soon as you integrate. Adding it after dividing by I(x)I(x) gives the wrong family of solutions.

1. (Warm-up) For each equation, state P(x)P(x) and Q(x)Q(x) and find the integrating factor, simplified.

  • (a) dydx+3y=x\dfrac{dy}{dx} + 3y = x
  • (b) dydx−1x y=x2\dfrac{dy}{dx} - \dfrac{1}{x}\,y = x^2, x>0x \gt 0
  • (c) dydx+2xy=x\dfrac{dy}{dx} + 2xy = x
Solution

(a) P(x)=3P(x) = 3, Q(x)=xQ(x) = x, I(x)=e3xI(x) = e^{3x}.

(b) P(x)=−1xP(x) = -\dfrac{1}{x}, Q(x)=x2Q(x) = x^2, I(x)=e−ln⁡x=1xI(x) = e^{-\ln x} = \dfrac{1}{x}.

(c) P(x)=2xP(x) = 2x, Q(x)=xQ(x) = x, I(x)=ex2I(x) = e^{x^2}.

2. (Warm-up) Find the general solution of dydx−y=e2x\dfrac{dy}{dx} - y = e^{2x}.

Solution

P(x)=−1P(x) = -1, so I(x)=e−xI(x) = e^{-x}.

ddx(e−xy)=e−xe2x=ex⇒e−xy=ex+C⇒y=e2x+Cex\frac{d}{dx}\left(e^{-x}y\right) = e^{-x}e^{2x} = e^x \quad\Rightarrow\quad e^{-x}y = e^x + C \quad\Rightarrow\quad y = e^{2x} + Ce^x

3. (Warm-up) Find the general solution of dydx+2xy=2x\dfrac{dy}{dx} + 2xy = 2x.

Solution

I(x)=ex2I(x) = e^{x^2}.

ddx(ex2y)=2xex2⇒ex2y=ex2+C⇒y=1+Ce−x2\frac{d}{dx}\left(e^{x^2}y\right) = 2xe^{x^2} \quad\Rightarrow\quad e^{x^2}y = e^{x^2} + C \quad\Rightarrow\quad y = 1 + Ce^{-x^2}

(The integral ∫2xex2 dx=ex2+C\displaystyle\int 2xe^{x^2}\,dx = e^{x^2} + C uses the substitution u=x2u = x^2. This equation is also separable; try it that way too.)

4. (Core) Solve xdydx−2y=x3exx\dfrac{dy}{dx} - 2y = x^3e^x, x>0x \gt 0, given that y=0y = 0 when x=1x = 1.

Solution

Divide by xx: dydx−2x y=x2ex\dfrac{dy}{dx} - \dfrac{2}{x}\,y = x^2e^x. Then I(x)=e−2ln⁡x=x−2I(x) = e^{-2\ln x} = x^{-2}.

ddx(yx2)=x−2⋅x2ex=ex⇒yx2=ex+C\frac{d}{dx}\left(\frac{y}{x^2}\right) = x^{-2}\cdot x^2e^x = e^x \quad\Rightarrow\quad \frac{y}{x^2} = e^x + C

At (1,0)(1, 0): 0=e+C0 = e + C, so C=−eC = -e and

y=x2(ex−e)y = x^2\left(e^x - e\right)

5. (Core) Solve dydx=x−y\dfrac{dy}{dx} = x - y with y(0)=2y(0) = 2, and find y(1)y(1) to 3 s.f.

Solution

Rearrange: dydx+y=x\dfrac{dy}{dx} + y = x, so I(x)=exI(x) = e^x.

ddx(exy)=xex\frac{d}{dx}\left(e^xy\right) = xe^x

By parts, ∫xex dx=xex−ex+C\displaystyle\int xe^x\,dx = xe^x - e^x + C. So exy=(x−1)ex+Ce^xy = (x - 1)e^x + C and y=x−1+Ce−xy = x - 1 + Ce^{-x}.

At x=0x = 0: 2=−1+C2 = -1 + C, so C=3C = 3 and y=x−1+3e−xy = x - 1 + 3e^{-x}. Then y(1)=3e−1≈1.10y(1) = 3e^{-1} \approx 1.10 (3 s.f.).

(Compare with the rough estimate of 0.750.75 from two steps of Euler’s method for the same equation.)

6. (Core) Solve cos⁡x dydx+ysin⁡x=1\cos x\,\dfrac{dy}{dx} + y\sin x = 1 for 0≤x<π20 \le x \lt \dfrac{\pi}{2}, given that y(0)=3y(0) = 3.

Solution

Divide by cos⁡x\cos x: dydx+ytan⁡x=sec⁡x\dfrac{dy}{dx} + y\tan x = \sec x. As in Example 3, I(x)=sec⁡xI(x) = \sec x.

ddx(ysec⁡x)=sec⁡2x⇒ysec⁡x=tan⁡x+C⇒y=sin⁡x+Ccos⁡x\frac{d}{dx}\left(y\sec x\right) = \sec^2 x \quad\Rightarrow\quad y\sec x = \tan x + C \quad\Rightarrow\quad y = \sin x + C\cos x

At x=0x = 0: 3=0+C3 = 0 + C. So y=sin⁡x+3cos⁡xy = \sin x + 3\cos x.

7. (Core) A pollutant enters a lake, and the mass PP kg of pollutant in the lake after tt days satisfies

dPdt+0.1P=5e−0.05t,P(0)=0\frac{dP}{dt} + 0.1P = 5e^{-0.05t}, \qquad P(0) = 0
  • (a) Find PP in terms of tt.
  • (b) Find the maximum mass of pollutant in the lake, and when it occurs (to 3 s.f.).
Solution

(a) I(t)=e0.1tI(t) = e^{0.1t}.

ddt(e0.1tP)=5e0.05t⇒e0.1tP=100e0.05t+C\frac{d}{dt}\left(e^{0.1t}P\right) = 5e^{0.05t} \quad\Rightarrow\quad e^{0.1t}P = 100e^{0.05t} + C

At t=0t = 0: 0=100+C0 = 100 + C, so C=−100C = -100 and

P=100(e−0.05t−e−0.1t)P = 100\left(e^{-0.05t} - e^{-0.1t}\right)

(b) dPdt=100(−0.05e−0.05t+0.1e−0.1t)=0\dfrac{dP}{dt} = 100\left(-0.05e^{-0.05t} + 0.1e^{-0.1t}\right) = 0 gives e−0.05t=2e−0.1te^{-0.05t} = 2e^{-0.1t}, so e0.05t=2e^{0.05t} = 2 and t=20ln⁡2≈13.9t = 20\ln 2 \approx 13.9 days. Then e−0.05t=12e^{-0.05t} = \dfrac{1}{2} and e−0.1t=14e^{-0.1t} = \dfrac{1}{4}, so P=100(12−14)=25P = 100\left(\dfrac{1}{2} - \dfrac{1}{4}\right) = 25 kg. (It is a maximum: PP starts at 00, rises, and tends to 00 again.)

8. (Challenge) Solve dydx+yx=sin⁡x\dfrac{dy}{dx} + \dfrac{y}{x} = \sin x, x>0x \gt 0, given that y=1y = 1 when x=πx = \pi.

Solution

I(x)=eln⁡x=xI(x) = e^{\ln x} = x.

ddx(xy)=xsin⁡x\frac{d}{dx}(xy) = x\sin x

By parts, with u=xu = x and dv=sin⁡x dxdv = \sin x\,dx: ∫xsin⁡x dx=−xcos⁡x+∫cos⁡x dx=sin⁡x−xcos⁡x+C\displaystyle\int x\sin x\,dx = -x\cos x + \int \cos x\,dx = \sin x - x\cos x + C. So

xy=sin⁡x−xcos⁡x+Cxy = \sin x - x\cos x + C

At (π,1)(\pi, 1): π=0−π(−1)+C=π+C\pi = 0 - \pi(-1) + C = \pi + C, so C=0C = 0 and

y=sin⁡xx−cos⁡xy = \frac{\sin x}{x} - \cos x

9. (Challenge) Solve (x2+1)dydx+4xy=x(x^2 + 1)\dfrac{dy}{dx} + 4xy = x, given that y(0)=0y(0) = 0, and describe what happens to yy as x→∞x \to \infty.

Solution

Divide by x2+1x^2 + 1: dydx+4xx2+1 y=xx2+1\dfrac{dy}{dx} + \dfrac{4x}{x^2 + 1}\,y = \dfrac{x}{x^2 + 1}. Then

I(x)=e∫4xx2+1 dx=e2ln⁡(x2+1)=(x2+1)2I(x) = e^{\int \frac{4x}{x^2 + 1}\,dx} = e^{2\ln(x^2 + 1)} = (x^2 + 1)^2

Multiply through:

ddx((x2+1)2y)=x(x2+1)\frac{d}{dx}\Big((x^2 + 1)^2 y\Big) = x(x^2 + 1)

With u=x2+1u = x^2 + 1, ∫x(x2+1) dx=(x2+1)24+C\displaystyle\int x(x^2 + 1)\,dx = \frac{(x^2 + 1)^2}{4} + C. So (x2+1)2y=(x2+1)24+C(x^2 + 1)^2 y = \dfrac{(x^2 + 1)^2}{4} + C, and

y=14+C(x2+1)2y = \frac{1}{4} + \frac{C}{(x^2 + 1)^2}

At x=0x = 0: 0=14+C0 = \dfrac{1}{4} + C, so C=−14C = -\dfrac{1}{4} and y=14−14(x2+1)2y = \dfrac{1}{4} - \dfrac{1}{4(x^2 + 1)^2}.

As x→∞x \to \infty, the second term tends to 00, so y→14y \to \dfrac{1}{4} (from below).