$\int \frac{\sin x}{1+2\sin x}dx$ calculate:
$$\int \frac{\sin x}{1+2\sin x}dx$$
I tried using $\sin x=\dfrac{2u}{u^2+1}$, $u=\tan \dfrac{x}2$ and after Simplification:
$$\int \frac{2u}{u^2+4u+1}×\frac{2}{u^2+1}du$$
and I am not able to calulate that.
 A: Before doing that substitution I might say
$\int \frac{\sin x}{1+2\sin x} \ dx\\
\int \frac 12 \frac{2\sin x + 1 - 1}{1+2\sin x} \ dx\\
\int \frac 12 -  \frac{1}{1+2\sin x} \ dx\\
\int \frac 12 \ dx  -  \frac 12 \int \frac{1}{1+2\sin x} \ dx$
Now when we do the substitution it isn't as messy.
$\frac x2  -   \int \frac{1}{u^2 + 4u + 1} \ du$
A: Since $u=\tan\frac{x}{2}$ gives$$\int\frac{dx}{1+2\sin x}=\int\frac{2 du}{(u+2)^2-3}=\frac{-2}{\sqrt{3}}\operatorname{artanh}\frac{u+2}{\sqrt{3}}+C=\frac{-1}{\sqrt{3}}\ln\frac{\sqrt{3}+2+\tan\frac{x}{2}}{\sqrt{3}-2-\tan\frac{x}{2}}+C,$$we have$$\int\frac{\sin xdx}{1+2\sin x}=\frac12x+\frac{1}{2\sqrt{3}}\ln\frac{\sqrt{3}+2+\tan\frac{x}{2}}{\sqrt{3}-2-\tan\frac{x}{2}}+C.$$
A: Hint:
Use the partial fractions method (I think that is the name of it): 
$$\frac{2u}{u^2+4u+1}×\frac{2}{u^2+1} =\frac{au+b}{u^2+4u+1}+\frac{cu+d}{u^2+1} $$
where you have to find $a,b,c,d$. 

How do we do that? First get rid of the fractions: 
$$4u = (au+b)(u^2+1)+(cu+d)(u^2+4u+1)$$
and now get rid of the brackets and then compare the coefficents...
A: Simplify first before substituting,
$$\int \frac{\sin x}{1+2\sin x}dx
=\frac12\int dx -\frac12 \int \frac{1}{1+2\sin x}dx$$
$$=\frac12 x -\frac12 \int  \frac{1+\tan^2\frac x2}{\tan^2\frac x2 +4\tan\frac x2 +1}dx$$
$$=\frac12 x -\int \frac{d(\tan \frac x2)}{\left(\tan^2\frac x2 +2\right)^2 -3}$$
$$=\frac12 x +\frac{1}{\sqrt3}\tanh^{-1}\left( \frac{
\tan\frac x2 +2}{\sqrt3}\right)+C$$
