<s>[INST] Evaluating the integral with trigonometric integrand While solving another problem I have come across this integral which I am unable to evaluate. Can someone please evaluate the following integral? Thank you. 

$$\int_0^{2\pi}\frac{1}{(2+\cos\theta)^2}\,d\theta.$$

 [/INST] Here's the contour integration approach.
$$\int_{0}^{2 \pi} \frac{1}{(2+ \cos \theta)^{2}} \ d \theta = \int_{0}^{2 \pi} \frac{1}{(2+\frac{e^{i \theta} + e^{- i \theta}}{2})^{2}} \ d \theta$$
Let $z=e^{i \theta}$.
Then
$$  \begin{align}\int_{0}^{2 \pi} \frac{1}{(2+ \cos \theta)^{2}} \ d \theta &= \int_{|z|=1} \frac{1}{(2+\frac{z+z^{-1}}{2})^{2}} \frac{dz}{iz} \\ &= \frac{4}{i}\int_{|z|=1}  \frac{z}{(z^{2}+4z+1)^{2}} \ d z  \\ &=\frac{4}{i} \int_{|z|=1}\frac{z}{[(z-\sqrt{3}+2)(z+\sqrt{3}+2)]^{2}} \ dz \end{align}$$
The only pole inside the unit circle is at $z= \sqrt{3}-2$.
Therefore,
$$ \begin{align} \int_{0}^{2 \pi} \frac{1}{(2+ \cos \theta)^{2}} \ d \theta &= 2 \pi i \frac{4}{i} \text{Res} \left[ \frac{z}{[(z-\sqrt{3}+2)(z+\sqrt{3}+2)]^{2}}, \sqrt{3}-2 \right] \\ &= 8 \pi \lim_{z \to \sqrt{3}-2} \frac{d}{dz} \frac{z}{(z+\sqrt{3}+2)^{2}}
\\ &= 8 \pi \lim_{z \to \sqrt{3}-2} \frac{(z+\sqrt{3}+2)^{2}-2z(z+\sqrt{3}+2)}{(z+\sqrt{3}+2)^{4}} \\ &= 8 \pi \lim_{z \to \sqrt{3}-2} \frac{-z+ \sqrt{3} + 2}{(z+\sqrt{3}+2)^{3}} \\ &= 8 \pi \frac{4}{24 \sqrt{3}} = \frac{4 \pi}{3 \sqrt{3}} \end{align}$$
</s>