Integral $\int_0^{2\pi}\frac{dx}{2+\cos{x}}$ How do I integrate this?
$$\int_0^{2\pi}\frac{dx}{2+\cos{x}}, x\in\mathbb{R}$$
I know the substitution method from real analysis, $t=\tan{\frac{x}{2}}$, but since this problem is in a set of problems about complex integration, I thought there must be another (easier?) way.
I tried computing the poles in the complex plane and got 
$$\text{Re}(z_0)=\pi+2\pi k, k\in\mathbb{Z}; \text{Im}(z_0)=-\log (2\pm\sqrt{3})$$
but what contour of integration should I choose?
 A: Here is an elementary treatment: 
First note that $\displaystyle2+\cos x=\frac{3+\tan ^2 \frac{x}{2}}{1+\tan^2 \frac{x}{2}}$. Also note that for $\displaystyle f(x)=\frac{3+\tan ^2 \frac{x}{2}}{1+\tan^2 \frac{x}{2}}$, it holds that $\displaystyle f(x+\pi)=f(x)$ for $0<x<\pi$. Therefore
$$\begin{align}\int_0^{2\pi}\frac{1}{2+\cos x}dx&=\int_0^{2\pi}\frac{1+\tan^2 \frac{x}{2}}{3+\tan ^2 \frac{x}{2}}dx\\
&=2\int_0^{\pi}\frac{1+\tan^2 \frac{x}{2}}{3+\tan ^2 \frac{x}{2}}dx \\
&=2\pi-4\int_0^{\pi}\frac{1}{3+\tan ^2 \frac{x}{2}}dx \\
&=2\pi-8\int_0^{\infty}\frac{1}{(3+u^2)(1+u^2)}du\\
&=2\pi-4\int_0^{\infty}\frac{1}{1+u^2}du+4\int_0^{\infty}\frac{1}{3+u^2}du\\
&=\frac{2\pi}{\sqrt{3}}
\end{align}$$
A: For completeness, we know that $\cos(x) = \frac{e^{ix}+e^{-ix}}{2}$ and from @danielfischer's comment, $z=e^{ix}$, we are able to obtain $\cos(z) = \frac{z + 1/z}{2}$. Then $dx =\frac{dz}{iz}$. Therefore, we have the following integral were $\gamma$ is to be taking counter clockwise such that $|z|=1$
$$
\int_{\gamma}\frac{1}{2 + \frac{z + 1/z}{2}}\frac{dz}{iz} = \int_{\gamma}\frac{2z}{4z + z^2 + 1}\frac{dz}{iz}
$$
Then the poles occur at $z^2 + 4z + 1$. However, we only need to consider the pole in the contour.
