# How can I solve a first order ODE with $\pm$ signs by the Integrating Factor method?

I have the following first order ODE to be solved via the integrating factor method: $$\frac{\mathrm{d}z}{\mathrm{d}y}\pm z=-\frac12y\tag{1}$$ This is in the general form: $$\frac{\mathrm{d}a}{\mathrm{d}x}+P(x)a=Q(x)$$ Which can be solved with the use of the formula: $$a e^I=\int Q(x)e^I\mathrm{d}x$$ where \begin{align}I=\int P(x)\mathrm{d}x \quad\quad\quad& \text{(Integrating Factor)}\end{align} Applying this method to $(1)$: $$I=\int \pm 1 \mathrm{d}y=\pm y$$ Therefore $$ze^{\pm y}=-\frac12\int ye^{\pm y}\mathrm{d}y\tag{2}$$ The RHS of $(2)$ can be solved by integrating by parts, so proceeding: $$-\frac12\int ye^{\pm y}\mathrm{d}y=-\frac12\left(\pm y e^{\pm y}-\int(\pm 1)e^{\pm y}\mathrm{d}y\right)=-\frac12\left(\pm y e^{\pm y}-\pm e^{\pm y}\right)+C$$ $$=\color{red}{-\frac12\left(\pm e^{\pm y}\left(y-1\right)\right)+C}\tag{A}$$ where $C$ is the constant of integration.

The problem is that the answer given in my textbook is $$-\frac12\int ye^{\pm y}\mathrm{d}y=\color{blue}{-\frac12 e^{\pm y}\left(\pm y-1\right)+C}\tag{B}$$

Are $(\mathrm{A})$ and $(\mathrm{B})$ equivalent or am I making a mistake? If it's a mistake could someone please explain what I'm doing wrong?

## Edit:

Now that I have been given an explanation as to why the expression marked $\color{blue}{\mathrm{blue}}$ is correct; the final step is to make $z$ the subject. I have another question but it would be too confusing and awkward to make it as whole new question while all the background and context is right here. This question immediately follows:

So we have that $$ze^{\pm y}=-\frac12 e^{\pm y} \left(\pm y - 1\right)+C$$ My question is; How can I make $z$ the subject?

I can tell you that the correct textbook answer is $$\color{#F80}{z=-\frac12\left(\pm y -1 \right) + c e^{\mp y}}$$ but I don't understand why the exponential disappeared in the first term and why the $\mp$ (instead of $\pm$) is present in the exponent of the second term.

Any ideas?

Thank you.

• I think the issue arises in that integrating just the exponential term, you have $$- (\pm) \int e^{\pm y} dy = (\mp) (\pm) e^{\pm y} = - e^{\pm y}$$ – Mattos Feb 9 '16 at 14:33
• @Mattos Thanks for your reply, you are right the issue is solely involving integration of the exponential term as I am not sure how to manipulate the plus/minus signs. Could you please tell me why $\pm \cdot \mp =-1$? – BLAZE Feb 9 '16 at 14:37
• Sorry, it's just a slight abuse of notation on my part. If $(\mp) = - (\pm)$, then $(\mp) \cdot (\pm) = - (\pm) \cdot (\pm) = - (\pm)^{2} = -1$ (I'm just pretending that you can algebraically manipulate the $\pm$ signs by the way). – Mattos Feb 9 '16 at 14:41

## 2 Answers

You have shown that $$-\frac12\int ye^{\pm y}\mathrm{d}y=-\frac12\left(\pm y e^{\pm y}-\int(\pm 1)e^{\pm y}\mathrm{d}y\right)$$ From the last expression we get $$=-\frac12\left(\pm y e^{\pm y}-(\pm)^2 e^{\pm y}\right)+C=-\frac12\left(\pm y e^{\pm y}- e^{\pm y}\right)+C=-\frac12 e^{\pm y} \left(\pm y - 1\right)+C$$

• Fantastic answer, I like the fact that you continued from the point where I made the mistake. So we have that $ze^{\pm y}=-\frac12 e^{\pm y} \left(\pm y - 1\right)+C$. The last step is to make $z$ the subject. I can tell you that the answer is $z=-\frac12\left(\pm y -1 \right) + c e^{\mp y}$; but i don't understand why the exponential disappeared in the first term and the $\pm \rightarrow \mp$ in the second term. Any ideas? Thank you. – BLAZE Feb 9 '16 at 20:26
• We have $$ze^{\pm y}=-\frac12 e^{\pm y} \left(\pm y - 1\right)+C$$ We multiply both sides by $e^{\mp y}$ so that the term $e^{\pm y}$ disappear from the left side. So we have the following: $$ze^{\pm y}=-\frac12 e^{\pm y} \left(\pm y - 1\right)+C \\ \Rightarrow ze^{\pm y}e^{\mp y}=-\frac12 e^{\pm y} e^{\mp y}\left(\pm y - 1\right)+C \\ \Rightarrow ze^{\pm y\mp y}=-\frac12 e^{\pm y\mp y} \left(\pm y - 1\right)+Ce^{\mp y}\\ \Rightarrow ze^{0}=-\frac12 e^{0} \left(\pm y - 1\right)+Ce^{\mp y} \\ \Rightarrow z=-\frac12 \left(\pm y - 1\right)+Ce^{\mp y}$$ – Mary Star Feb 9 '16 at 21:12
• Thank you. In the exponent, why does $e^{\pm y \mp y}=e^0$? I'm not sure I follow that part, sorry. If it was $e^{-y+y}$ I would understand completely but in this case we have $\pm \mp$. – BLAZE Feb 9 '16 at 21:20
• $\pm y \mp y$ means either $+y-y$ or $-y+y$, so in each case it is equal to $0$. – Mary Star Feb 9 '16 at 21:24
• Oh I see; so that means that the upper operators are coupled together and the lower operators are coupled? I was never actually told this. – BLAZE Feb 9 '16 at 21:26

Just a tip instead of $\pm z$ use $kz$ then work it through with $k$.

$$z' + kz = -\frac{1}{2}y$$ thus you have $$z\mathrm{e}^{ky} = -\frac{1}{2}\int y\mathrm{e}^{ky} dy + C$$ integrating the right hand side $$\int y\mathrm{e}^{ky}dy = \frac{\mathrm{e}^{ky}}{k^2}\left[ky-1\right]$$ remember $k = \pm 1$ so $k^2 = \pm 1\cdot \pm 1 = 1$. so we have $$\int y\mathrm{e}^{\pm y}dy = \mathrm{e}^{\pm y}\left[\pm y-1\right]$$