# Integrating factor formula derivation plus-minus problem

I'm trying to derive the formula for the solution of a first order ODE, $y = e^{-\mu(x)}\int e^{\mu(x)}q(x)dx$ with $\mu(x) = \int p(x)dx$ for the form $y'+p(x)y = q(x)$. Here's what I did:

Rewriting the general form $y'+py = q$, we get $$\left[q(x)-p(x)y\right]dx = dy.\label{eqn:int-fact2}$$ Now state $M = q(x) - p(x) y$, $N=1$ and assume left and right hand side to be a constant: $$\frac{dM}{dy} = \frac{dN}{dx} = C\label{eqn:int-fact-MN}$$ Use integrating factor $\mu(x)$ to ensure exactness: $$\frac{d[\mu(x) \cdot M]}{dy} = \frac{d[\mu (x) \cdot N]}{dx} \Rightarrow \mu(x) \frac{dM}{dy} = \mu(x) \frac{dN}{dx} + \frac{d\mu(x)}{dx} N.$$ $$\mu(x)\left[-p(x)\right] = \frac{d\mu(x)}{dx} \Rightarrow -p(x)dx = \frac{d\mu(x)}{\mu(x)}.$$ $$\ln \mu(x) = -\int p(x)dx \Rightarrow \boxed{\mu(x) = e^{-\int p(x)dx}}$$ $$\int \left[q(x)-p(x)y\right]dx =\int dy,$$ $$\int e^{-\int p(x)dx}dy = e^{-\int p(x)dx}y + C(x)$$ $$p(x)ye^{-\int p(x)dx} + C'(x)= q(x)e^{-\int p(x)dx} + p(x) y e^{-\int p(x)dx}$$ $$C'(x)= q(x)e^{-\int p(x)dx} \Rightarrow C(x) = \int q(x)e^{-\int p(x)dx}dx + C.$$ Choose $C=0$ to get: $$e^{-\int p(x)dx}y + \int q(x)e^{-\int p(x)dx}dx = 0$$ $$e^{-\int p(x)dx}y = - \int q(x)e^{-\int p(x)dx}dx \Rightarrow \boxed{y = - e^{\int p(x)dx}\int q(x)e^{-\int p(x)dx}dx}$$

So why am I ending up with ye olde $+\mapsto-$ and $-\mapsto+$? Where is the error?

• Have you looked at the relevant Wikipedia page? Commented Oct 19, 2016 at 14:48
• @robert Yes, I already know how to do it that way. I want to do it this way as well Commented Oct 19, 2016 at 16:32

## 2 Answers

$y’+py=q\enspace$ with $\enspace y:=\mu z\enspace$ $(z\neq 0)\enspace$ => $\enspace\mu’z+\mu z’+p\mu z=q$

Be $\enspace\mu’+p\mu =0\enspace$ and $\enspace\mu z’=q$ .

=> $\enspace\displaystyle \mu =e^{-\int p} \enspace$ and $\enspace\displaystyle z=\int (q\mu^{-1})= \int (q e^{\int p})$.

=> $\enspace\displaystyle y=\mu z= e^{-\int p} \int (q e^{\int p})$

I have to write $$\left[p(x)y - q(x)\right]dx + dy = Mdx + Ndy = 0,$$ which yields to correct integrating factor. However, filling it in, we get $$ye^{\int p(x)dx} + C(x) + \int\left[p(x)y-q(x)\right]e^{\int p(x)dx}dx = 0,$$ which still doesn't yield the right solution when taken the derivative wrt $x$.