Weierstrass Substitution $\int\frac{1}{2+4\sin(x)}$ I want to calculate $\int\frac{1}{2+4\sin(x)}$, and I know that I need to define:
$t=\tan(\frac{x}{2})$ which means that $\sin(\frac{x}{2})=\sqrt\frac{t^2}{1+t^2}$, but I do not understand why.
I have tried searching about it, and I read about Weierstrass Substitution, but didn't understand its proof.
Can someone please explain me this equality?
I have also tried: $x=\arctan(t)$ and $dx=\frac{2}{1+t^2}dt$, but I didn't know how to continue...
Thanks a lot!
 A: If you do $t=\tan\left(\frac x2\right)$ then, since $\frac{\sin(x/2)}{\cos(x/2)}=t$ and $\cos^2\left(\frac x2\right)+\sin^2\left(\frac x2\right)=1$, a simple computation shows that$$\sin\left(\frac x2\right)=\frac t{\sqrt{1+t^2}}\quad\text{and}\quad\cos\left(\frac x2\right)=\frac1{\sqrt{1+t^2}}.$$But then$$\sin\left(x\right)=2\sin\left(\frac x2\right)\cos\left(\frac x2\right)=\frac{2t}{1+t^2}$$and$$\cos\left(x\right)=\cos^2\left(\frac x2\right)-\sin^2\left(\frac x2\right)=\frac{1-t^2}{1+t^2}$$and therefore, and since $\mathrm dx=\frac2{1+t^2}\,\mathrm dt$, your integral becomes$$\int\frac1{2+4\frac{2t}{1+t^2}}\frac2{1+t^2}\,\mathrm dt.$$
A: While @JoséCarlosSantos's answer has explained how to show $\sin\tfrac{x}{2}=\pm\sqrt{\tfrac{t^2}{1+t^2}}$, for this problem writing $\sin x$ in terms of $t$ is more helpful. Note$$\sin x=2\sin\tfrac{x}{2}\cos\tfrac{x}{2}=\frac{2\tan\tfrac{x}{2}}{\sec^2\tfrac{x}{2}}=\frac{2t}{1+t^2}.$$This approach has the advantage we don't have to worry about $\pm$ signs from square-rooting in $\sin\tfrac{x}{2}=\pm\sqrt{1-\cos^2\tfrac{x}{2}}$. Instead we can proceed to$$\int\frac{dx}{2+4\sin x}=\int\frac{dt/(1+t^2)}{1+2\sin x}=\int\frac{dt}{1+4t+t^2}.$$
