<s>[INST] Evaluate $\int_{0}^{\pi} \frac{d\theta}{(2+\cos\theta)^2}$ How can one evaluate $\displaystyle\int_{0}^{\pi} \frac{d\theta}{(2+\cos\theta)^2}$?
My attempt:
$$\int_{0}^{\pi} \frac{d\theta}{(2+\cos\theta)^2} =  \frac{1}{2}\int_{0}^{2\pi} \frac{d\theta}{(2+\cos\theta)^2}$$
To find the singularity, I solve:
$ (2+\cos\theta)^2 = 0 $ and therefore, $\cos\theta =  -2$.
Substituting: $\cos z = \frac{e^{iz} + e^{-iz}}{2} = \frac{z + \frac{1}{z}}{2}$,
I find that $z = -2 + \sqrt{3} $ is the singular point that lies in the unit circle $|z| = 1$.
From this point, I have little idea how to go about solving this problem. I know I have to find the residue and then just sum them but to get the expression that would cancel out the pole is where I am currently stuck.
 [/INST] Trigonometric substitution:
$$x=\tan\frac{\theta}{2}\Longrightarrow d\theta=\frac{2}{x^2+1}dx\;\;,\;\;\cos\theta=\frac{1-x^2}{1+x^2}\Longrightarrow$$
$$\int\limits_0^\pi\frac{d\theta}{(2+\cos\theta)^2}=\int\limits_0^\infty\frac{2\,dx}{1+x^2}\frac{1}{\left(2+\frac{1-x^2}{1+x^2}\right)^2}=2\int\limits_0^\infty\frac{x^2+1}{(x^2+3)^2}dx=$$
$$2\int\limits_0^\infty\left(\frac{1}{3+x^2}-\frac{2}{(3+x^2)^2}\right)=\left.\frac{2}{\sqrt 3}\arctan\frac{x}{\sqrt 3}\right|_0^\infty-\left.4\left(\frac{x}{6(3+x^2)}+\frac{1}{6\sqrt 3}\arctan\frac{x}{\sqrt 3}\right)\right|_0^\infty=$$
$$=\frac{4}{3\sqrt 3}\frac{\pi}{2}=\frac{2\pi}{3\sqrt 3}$$
</s>