Primitive of $\sin$ function (Weierstrass) How do I find the primitive of the following function:
$$f(x)=\frac{{\sin x}}{{1+\sin x}}.$$
I solved this with Weierstrass and I found it's:
$$2\int(1+t)^{-2}dt$$ 
where $t=\tan(x/2)$ and if I solve it this would mean the integral is: $$I=\frac{-2}{{1+\tan(x/2)}}+C $$ but the answer is 
$$I=\frac{-2}{{1+\tan(x/2)}}+x+C.$$
The function's domain is $(-\pi/2,\pi/2)$. Why is there an $x$?
 A: Divide numerator and denominator of the function with 
$$1-\sin x$$
giving
$$f(x)=\sin x\frac{1-\sin x}{1-\sin^2x}=\frac{\sin x}{\cos^2x}-\frac{1-\cos^2x}{\cos^2x}$$
Therefore integration of the given function
$$-\sec x-\tan x+x+C.$$
A: With Weierstrass substitutions:
$$\begin{cases}
\tan\cfrac x2=u\\{}\\
\sin x=\cfrac{2u}{1+u^2}\\{}\\
dx=\cfrac{2\,du}{1+u^2}\end{cases}\;\;\implies \int\frac{\sin x}{1+\sin x}=\int\frac{\frac{2u}{1+u^2}}{1+\frac{2u}{1+u^2}}\cdot\frac{2\,du}{1+u^2}=\int\frac{4u}{(1+u)^2(1+u^2)}du=$$$${}$$
$$=-2\int\frac{du}{(1+u)^2}+2\int\frac{du}{1+u^2}=\frac2{1+u}+2\arctan u+C\mapsto\frac2{1+\tan\frac x2}+2\frac x2+C=$$$${}$$
$$=\frac2{1+\tan\frac x2}+x+C$$
I almost agree with what you call "the answer", yet I can't see where that minus sign in the first factor comes from...Check this
A: $$1+\sin x=1+\cos\left(x-\frac\pi2\right)=2\cos^2\left(\frac x2-\frac\pi4\right),$$ so that
$$\int\frac{\sin x}{\sin x+1}dx=\int\left(1-\frac1{\sin x+1}\right)dx=x-\int \frac{dx}{2\cos^2\left(\dfrac x2-\dfrac\pi4\right)}=x-\tan\left(\dfrac x2-\dfrac\pi4\right)+C.$$

This expression is equivalent to that given by @DonAntonio, because
$$\tan\left(\dfrac x2-\dfrac\pi4\right)=\frac{\tan\dfrac x2-1}{\tan\dfrac x2+1}=1-\frac2{1+\tan\dfrac x2}.$$
