How to integrate $\int\frac{1}{1+\cos{x}}\ dx$? I've looked at wolfram alpha for a possible solution, but it does something that makes no sense to me... It says to let $u=\tan(\frac{x}{2})$ with no clear reason as to why...
So what would be a first step to approaching this? I've thought of converting it to $\frac{\sec{x}}{\sec{x}+1}$, but that seems to be fruitless...
 A: The substitution $u = \tan(x/2)$ is a useful one to know.  It transforms the integral of any rational function of $\sin(x)$ and $\cos(x)$ into the integral of a rational function of $u$.
A: The substitution $t=\tan(x/2)$ is a universally effective method of integrating a rational function of $\cos x$ and/or $\sin x$. It is usually called the Weierstrass Substitution. Please see the link for details. 
The procedure reduces the problem of integrating a rational function of $\cos x$ and/or $\sin x$ to integrating a rational function of $t$. 
However, in many situations, including this one, there are more efficient ways to proceed. 
The quickest, in this case, is the substitution suggested by M. Strochyk. 
Another way would be to multiply top and bottom by $1-\cos x$. We end up with
$$\int \frac{1-\cos x}{\sin^2 x}\,dx.$$
So we need $\int \csc^2 x\,dx$ and $\int \frac{\cos x}{\sin^2 x}\,dx$, both reasonably familiar. 
A: Hint:$$u=\tan\left(\frac{x}{2}\right)$$ then $$\int\frac{1}{1+\cos{x}}\ dx=\int\frac{\frac{2}{1+u^2}}{1+\frac{1-u^2}{1+u^2}}\ du=\int du=u+c=\tan\left(\frac{x}{2}\right)+c$$
A: I will try to explain wolfram alpha's method.
You can use the formula for $$\cos2x=\frac{1-\tan^2(x)}{1+\tan^2(x)}$$
And for this question which converts to $$\cos x=\frac{1-\tan^2(x/2)}{1+\tan^2(x/2)}$$ and now, You can substitute $Y=\tan \frac{x}{2}$ and use the method for partial fraction or otherwise to solve the problem further by already known methods.       
And in the end after integration substitute back $Y=\tan \frac{x}{2}$
A: Hint:
$$1+\cos{x}=\sin^2{\frac{x}{2}}+\cos^2{\frac{x}{2}}+\cos^2{\frac{x}{2}}-\sin^2{\frac{x}{2}}=2\cos^2{\frac{x}{2}}$$
