<s>[INST] Integrate $\int_0^{2\pi}\frac{dx}{(2+\cos(x))}$ using complex integral theorem Would someone help me to integrate 
$$\int_0^{2\pi}\frac{dx}{(2+\cos(x))}$$  
by means of residue theorem? 
 [/INST] Passing into the complex plane with the substitution
$$\cos x \to \cos z = \frac{\left(z + z^{-1}\right)}{2} ~~~~~~~ \text{d}x = \frac{\text{d}z}{iz}$$
an you get:
$$\int_{|z| = 1} -i \frac{\text{d}z}{z\left(2 + \frac{z + z^{-1}}{2}\right)} = \int_{|z| = 1} -2i \frac{\text{d}z}{z\left(4 + \frac{z^2 + 1}{z}\right)}$$
Arrange the terms:
$$\int_{|z| = 1} -2i \frac{\text{d}z}{4z + z^2 + 1}$$
Now calculate the poles, solving $z^2 + 4z +1  = 0$
The first pole (solution) is $z = -2+\sqrt{3}$ inside the unit circle and it's ok.
The second one is $z = -2-\sqrt{3}$ outside the unit circle so it's not ok.
Result:
$$2\pi i\ \text{Res}_{z = -2+\sqrt{3}}\ (z - 2-\sqrt{3})\frac{-2i}{(z-2-\sqrt{3})(z-2+\sqrt{3})} = \frac{2\pi}{\sqrt{3}}$$
</s>