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.
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$$