skip to content
Hamza Butt

Integrating Factor

/ 3 min read

Tags: calculus

μ(x)=ef(x)dx\mu(x) = e^{\int f(x) \mathrm{d}x}

You use the integrating factor when the differential equation is not exact.

1. First Order Linear Ordinary Differential Equations

If the differential equation is in the form dydx+f(x)y=g(x)\frac{\mathrm{d} y}{\mathrm{d} x}+f(x)\cdot y=g(x), you could use the integrating factor, μ(x)\mu(x). Keep this form in mind.

Remember the product rule? It’s ddx(fg)=fg+fg\frac{\mathrm{d} }{\mathrm{d} x}(f\cdot g)=f'\cdot g+f\cdot g'.

Let’s replace ff with the yy and gg with a function that we don’t know μ(x)\mu(x), so that it satisfies ddx(μ(x)y)=μ(x)y+dydxμ(x)\frac{\mathrm{d} }{\mathrm{d} x}(\mu(x)\cdot y)=\mu'(x)\cdot y+\frac{\mathrm{d} y}{\mathrm{d} x}\cdot \mu(x), so that you can get a form that’s similar with dydx+f(x)y=g(x)\frac{\mathrm{d} y}{\mathrm{d} x}+f(x)\cdot y=g(x).

If you multiply everything by the integrating factor, you get μ(x)dydx+μ(x)f(x)y=μ(x)g(x)\mu(x)\frac{\mathrm{d} y}{\mathrm{d} x}+\mu(x)\cdot f(x)\cdot y=\mu(x) \cdot g(x).

From above:

ddx(μ(x)y)=μ(x)y+dydxμ(x)\frac{\mathrm{d} }{\mathrm{d} x}(\mu(x)\cdot y)=\mu'(x)\cdot y+\frac{\mathrm{d} y}{\mathrm{d} x}\cdot \mu(x) μ(x)dydx+μ(x)f(x)y=μ(x)g(x)\mu(x)\frac{\mathrm{d} y}{\mathrm{d} x}+\mu(x)\cdot f(x)\cdot y=\mu(x) \cdot g(x)

Comparing where the yy‘s are: μ(x)f(x)=μ(x)\mu(x)\cdot f(x)=\mu'(x)

μ(x)μ(x)=f(x)\frac{\mu'(x)}{\mu(x)}=f(x)

μ(x)μ(x)dx=f(x)dx\int \frac{\mu'(x)}{\mu(x)}\mathrm{d}x =\int f(x)\mathrm{d}x

lnμ(x)=f(x)dx\mathrm{ln}|\mu(x)|=\int f(x)\mathrm{d}x

μ(x)=ef(x)dx\mu(x)=e^{\int f(x)\mathrm{d}x}. Do not worry about plus-minus - you only need one integrating factor.

So, substitute this μ(x)\mu(x) into μ(x)dydx+μ(x)f(x)y=μ(x)g(x)\mu(x)\frac{\mathrm{d} y}{\mathrm{d} x}+\mu(x)\cdot f(x)\cdot y=\mu(x) \cdot g(x) and you notice: the left hand side is ddx(μ(x)y)\frac{\mathrm{d} }{\mathrm{d} x}(\mu(x)\cdot y)

ddx(μ(x)y)=μ(x)g(x)\frac{\mathrm{d} }{\mathrm{d} x}(\mu(x)\cdot y)=\mu(x)\cdot g(x)

You can then solve the equation from there.

For reference: yef(x)=g(x)μ(x)dx+cy \cdot e^{f(x)}=\int g(x)\cdot \mu(x)\mathrm{d}x +c

1.1. Example

dydx+25y=3ex\frac{\mathrm{d} y}{\mathrm{d} x}+\frac{2}{5}y=3e^{-x} , y(0)=5y(0)=5

Recall that your integrating factor μ(x)\mu(x) is ef(x)dxe^{\int f(x) \mathrm{d}x}, so in this case, μ(x)=e25dx\mu(x)=e^{\int \frac{2}{5} \mathrm{d}x}.

e25xdydx+25e25xy=3e35xe^{\frac{2}{5}x}\frac{\mathrm{d} y}{\mathrm{d} x}+\frac{2}{5}e^{\frac{2}{5}x}y=3e^{-\frac{3}{5}x}

ddx(e25xy)=3e35x\frac{\mathrm{d} }{\mathrm{d} x}(e^{\frac{2}{5}x}y)=3e^{-\frac{3}{5}x}

e25xy=5e35x+ce^{\frac{2}{5}x}y=-5e^{-\frac{3}{5}x}+c

y=ex(ce35x5)y=e^{-x}(ce^{\frac{3}{5}x}-5)

Let’s plug in the initial conditions to find the constant cc: 5=e0(ce3505)5=e^{-0}(ce^{\frac{3}{5}\cdot 0}-5)

c=10c=10

y=5ex(2e35x1)y=5e^{-x}(2e^{\frac{3}{5}x}-1)

2. First Order Non-Exact Differential Equations

Use μ(x)=efygxgdx\mu(x)=e^{\int \frac{\frac{\partial f}{\partial y}-\frac{\partial g}{\partial x}}{g} \mathrm{d}x} for when you have the form fdx+gdy=0f \mathrm{d}x+g \mathrm{d}y=0, and the equation is not exact.

Like before, find μ(x)\mu(x) and multiply everything by μ(x)\mu(x).

2.1. Example

(4siny+6x)dx+xcosydy=0(4 \sin y + \frac{6}{x})\mathrm{d}x+x\cos y \mathrm{d}y=0

As you can see, the functions ff and gg are both functions of both xx and yy, so we must use partial differentials. Don’t be scared - this just means you need to take the partial derivative of the function.

Using the formula, f=4siny+6xf=4 \sin y + \frac{6}{x} and g=xcosyg= x\cos y.

Take the partial derivative of ff with respect to yy, and the partial derivative of gg with respect to xx. When you are taking the partial derivative of one variable, all the other variables are considered constants. fy=4cosy\frac{\partial f}{\partial y}=4\cos y and gx=cosy\frac{\partial g}{\partial x}=\cos y.

Therefore, μ(x)=e4cosycosyxcosydx=x3\mu(x)=e^{\int \frac{4\cos y -\cos y}{x \cos y}\mathrm{d}x}=x^3.

Multiply every term by μ(x)\mu (x): (4x3siny+6x2)dx+x4cosydy=0(4x^3 \sin y + 6x^2)\mathrm{d}x+x^4 \cos y \mathrm{d}y=0.

Now this is just an exact equation you can solve. Let FF be the general solution to the equation and that F=Fxdx+Fydy=0F=\frac{\partial F}{\partial x}\mathrm{d}x+\frac{\partial F}{\partial y}\mathrm{d}y=0.

f=Fx=4x3siny+6x2f=\frac{\partial F}{\partial x}=4x^3 \sin y +6x^2, g=Fy=x4cosyg=\frac{\partial F}{\partial y}=x^4 \cos y

Using Fx=4x3siny+6x2\frac{\partial F}{\partial x}=4x^3 \sin y +6x^2, integrate: F=x4siny+2x3+f(y)F=x^4 \sin y+2x^3+f(y).

Then differentiate: Fy=x4cosy+f(y)\frac{\partial F}{\partial y}=x^4 \cos y+f'(y).

Compare: Therefore f(y)=0f'(y)=0, so f(y)=cf(y)=c.

Substitute into FF: F=x4siny+2x3+cF=x^4 \sin y+2x^3+c, and recall that F=0F=0, so x4siny+2x3=c x^4 \sin y+2x^3=c.