Why does differentiating $-\frac{2}{x+1}$ or $\frac{2x}{x+1}$ result in the same function $\frac{2}{(x+1)^2}$? I have some trouble understanding the integration of $\frac{2}{(x+1)^2}$.
When integrated using $u$-substitution I get:
$$-\frac{2}{x+1}$$
However, I also know that:
$$\frac{2x}{x+1}$$
is a solution as well, due to the fact when you take the derivative of either one of the solutions mentioned above you end up with the same answer:
$$\frac{2}{(x+1)^2}$$
I want to understand how the relation between the both integrated solutions works and why. I can't find any proof or examples that might guide me in the right way. Any help in understand this phenomena would be very much appreciated.

Don't forget that there should be a constant of integration, $C$, at the end of your answer that always differentiates to zero: $\int\frac{2}{(x+1)^2}\,dx=-\frac{2}{x+1}+C$. The integral of a function is not just one single function, but a whole family of infinitely many functions that differ only by a constant. And the second function is nothing more than the first function plus a $2$ (a constant):
$$
-\frac{2}{x+1}+2=
-\frac{2}{x+1}+2\frac{x+1}{x+1}=\\
\frac{-2}{x+1}+\frac{2x+2}{x+1}=
\frac{-2+2x+2}{x+1}=\\
\frac{2x}{x+1}.
$$
Since they're the same function, their derivatives should be equal:
$$
\left(-\frac{2}{x+1}+2\right)'=\frac{2}{(x+1)^2}+0=\frac{2}{(x+1)^2}.\\
\left(\frac{2x}{x+1}\right)'=\frac{2}{(x+1)^2}.
$$
