## The Integrating Factor Method

The integrating factor method is a method of solving first order differential equations:
It can be used for equations of the form
$f(x)\frac{dy}{dx}+yg(x)=h(x)$

Divide by
$f(x)$
to get
$\frac{dy}{dx}+ \frac{yg(x)}{f(x)}= \frac{h(x)}{f(x)}$

Multiply by a factor
$e^{\int \frac{g(x)}{f(x)}dx}$
so the equation becomes
$\frac{dy}{dx}e^{\int \frac{g(x)}{f(x)}dx}+ye^{\int \frac{g(x)}{f(x)}dx} \frac{g(x)}{f(x)}=h(x)e^{\int \frac{g(x)}{f(x)}dx}$

We can write this as
$\frac{d}{dx}(ye^{\int \frac{g(x)}{f(x)}dx})=h(x)e^{\int \frac{g(x)}{f(x)}dx}$

Then
$ye^{\int \frac{g(x)}{f(x)}dx}= \int h(x)e^{\int \frac{g(x)}{f(x)}dx} \rightarrow y= \frac{\int h(x)e^{\int \frac{g(x)}{f(x)}dx}}{e^{\int \frac{g(x)}{f(x)}dx}}$
.
Example:
$x \frac{dy}{dx}+(x+1)y=x^2$
,
Divide by
$x$
.
$\frac{dy}{dx}+(1+ \frac{1}{x})y=x$
,
The integrating factor is
$e^{\int (1+ \frac{1}{x})dx}=e^{x+lnx}=e^xe^{lnx}=e^xx=xe^x$
.
The equation becomes
$xe^x \frac{dy}{dx}+ (1+ \frac{1}{x}) xe^x y= x^2e^x+$

We can write this as
$\frac{d}{dx}(yxe^x)=x^2e^x$

Integrating both sides
$xe^xy=x^2e^x-2xe^x+2e^x+A$

Then
$y=x-2+ \frac{2}{x} + \frac{A}{x}e^{-x}$