The Mystery of the Integrating Factor The other day I was taught that to solve equations of the form
$$
f'+pf=q,
$$
where $f=f(t)$, $p=p(t)$ and $q=q(t)$, I need to use a function, or integrating factor, $\mu=\mu(t)$ such that
$$
\mu'=\mu p.
$$
However, how do I know that such function $\mu$ exists at all? In other words, can I always find $\mu$?
 A: Subject to some assumptions, you can figure out what $\mu$ must look like. Consider that you have
$$\frac{d\mu}{d x} = \mu \cdot p(x)$$
Separating variables and integrating:
$$\int \frac{d\mu}{\mu} = \int p(x) dx$$
which implies that
$$\log \mu = \int p(x) dx$$
or
$$\mu(t) = \exp \left( \int_{t_0}^t p(x) dx \right)$$
So as long as $p(x)$ has a first integral, the function $\mu(x)$ exists.
A: However you've got your answer, I'd like to note you some other points. The OE $$y'=f(t,y)$$ can be always written as $$M(t,y)dt+N(t,y)dy=0$$ For example your OE is as $\frac{dy}{dt}+py=q$ or $dy+[py-q]dt=0$. Here, we find $M=py-q$ and $N=1$. Now the following tool can help you. Please pay attention to the assumptions inside it:

Theorem: If $\mu$ be a function of $z$ and $z$ is itself a function of $x$ and $y$,i.e.; $$\mu=\mu(z(x,y))$$ and if $\mu$ be an integrating factor of $$M(x,y)dx+N(x,y)dy=0$$ then; $$\mu=\exp\left(\int\frac{M_y-N_x}{z_xN-z_yM}dz\right)$$ provided the integrand is a function of $z$.

This theorem can lead us to find the proper function which makes a non-exact OE exact.
