Linear ODEs

Linear ODEs always take the form of

$\displaystyle \frac{dy}{dx} + y\cdot P(x) = Q(x)$

When $Q(x) = 0$ this becomes a separable ODE and can be solved as before such that

$\displaystyle dy \cdot \frac{1}{y}$ $\displaystyle = -P(x) dx$    
$\displaystyle y$ $\displaystyle = Ae^{\int -P(x)dx}\quad\textrm{where } A = e^c$    

When $P(x) = 0$ this becomes a simple separable ODE and can be solved by integration.

Recall the product rule $\frac{d}{dx}(u\cdot v) = u'v + uv'$
This is strikingly close to our Linear ODE, except we are missing a factor, the integration factor, $\mu(x)$. We want $\mu$ to be such that $\mu' = P(x)\mu$, allow us to do some algebraic manipulation.

$\displaystyle \mu'$ $\displaystyle = P(x)\mu$    
$\displaystyle P(x)$ $\displaystyle = \frac{\mu'}{\mu} = \frac{d}{dx}\ln(\mu)$    
$\displaystyle \int P(x) dx$ $\displaystyle = \ln(\mu)$    
$\displaystyle \mu$ $\displaystyle = e^{\int P(x) dx}$    

We can then multiply by our integrating factor, then apply the chain rule, however this is best shown with an example.

$\displaystyle \cos(x)\frac{dy}{dx} + \sin(x)y$ $\displaystyle = 1$    
$\displaystyle \frac{dy}{dx} + \tan(x)y$ $\displaystyle = \sec(x) \quad\textrm{Linear ODE}$    
$\displaystyle \mu$ $\displaystyle = e^{\int \tan(x) dx}$    
$\displaystyle \int \tan(x) dx$ $\displaystyle = \ln(sec(x))$    
$\displaystyle \mu$ $\displaystyle = \sec(x) \quad\textrm{Multiply ODE by $\mu$}$    
$\displaystyle \frac{dy}{dx}\sec(x) + \sec(x)\tan(x)y$ $\displaystyle = \sec^2(x)$    

Since $\frac{d}{dx}\sec(x) = \sec(x)\tan(x)$ we should now be able to see how the LHS of our equation can be withdrawn into its chain rule form.

$\displaystyle \frac{d}{dx}\sec(x)\cdot y$ $\displaystyle = \frac{dy}{dx}\sec(x) + \sec(x)\tan(x)y$    
$\displaystyle \frac{d}{dx}\sec(x)\cdot y$ $\displaystyle = \sec^2(x)$    
$\displaystyle \sec(x) \cdot y$ $\displaystyle = \int \sec^2(x) = \tan(x) + c$    
$\displaystyle y$ $\displaystyle = \sin(x) + c\cdot \cos(x)$