Example Solve the following initial value problem.

$\displaystyle (\cos{x})y^{\prime} - (\sin{x})y = -e^{x}, y(0) = 1$

Write this in the standard form.

$\displaystyle y^{\prime} - \frac{\sin{x}}{\cos{x}} y = - \frac{e^{x}}{\cos{x}} $

The integrating factor $\mu $ is given by

$\displaystyle \mu = \exp( -\int \frac{\sin{x}}{\cos{x}}dx) = \exp(\log{\cos{x}}) = \cos{x} $

Multiply this to the standard form.

$\displaystyle \cos{x}y^{\prime} - \sin{x} y = - e^{x} $

Note that the left hand side is the derivative of the product of the integrating factor $\mu $ and $y$.

$\displaystyle (\cos{x} y)^{\prime} = - e^{x} $

Integrate both sides with respect to $x$. We have

$\displaystyle \cos{x} y = - \int e^{x} dx = - e^{x} + c $

Thus the general solution is

$\displaystyle y = \frac{c - e^{x}}{\cos{x}}$

Now apply the initial condition $y(0) = 1$. Then we have

$\displaystyle y = \frac{2 - e^{x}}{\cos{x}}$