<s>[INST] Calculating the following integral: $\int_0^{\frac{z}{1+z}}\frac{-X+z-Xz}{z}dX$ I'm trying to calculate the following integral: $\int_0^{\frac{z}{1+z}}\frac{-X+z-Xz}{z}dX$ however, I seem to be getting the wrong answer and would like some support on where I went wrong. The answer should be: $\frac{z}{2(z+1)}$
What I have tried:
$$\int_0^{\frac{z}{1+z}}\frac{-X+z-Xz}{z}dX \implies \frac{-(1+z)}{z}\int_0^{\frac{z}{1+z}}X\space dX+\int_0^{\frac{z}{1+z}}+1 \space dX$$
Because:
$-X-Xz  = -X(1+z)$ & $\frac{-X(1+z)+z}{z} = \frac{-X(1+z)}{z}+1$
After simplification I get:
$$\left(\frac{-(1+z)}{z}\cdot \frac{(\frac{z}{1+z})^2}{2}\right) \space + \frac{z}{1+z} = \frac{-z^2+z}{2\left(z+1\right)}$$
Where might I have gone wrong?
 [/INST] Everything is correct besides your last equality:
\begin{align}
\left(\frac{-(1+z)}{z}\cdot \frac{(\frac{z}{1+z})^2}{2}\right)+ \frac{z}{1+z} &= \left(\frac{-(1+z)}{z}\cdot \frac{z^2}{2(1+z)^2}\right)+ \frac{z}{1+z} \\
&=  \frac{-z}{2(1+z)}+ \frac{z}{1+z}\\
&= \frac{-z}{2(1+z)} + \frac{2z}{2(1+z)} \\
&= \frac{z}{2(z+1)}
\end{align}
</s>