<s>[INST] how evaluate $\int_0^{\pi}\frac{1}{(a+\cos{\theta})^2}, a>1 $, using residues theorem? how evaluate $\int_0^{\pi}\frac{1}{(a+\cos{\theta})^2}, a>1 $,  using residues theorem?
This problem is an exercise book Complex Analysis of Conway.
 [/INST] Firstly $\int_0^{\pi}\dfrac{1}{(a+\cos{\theta})^2}d\theta = \dfrac{1}{2}\int_0^{2\pi}\dfrac{1}{(a+\cos{\theta})^2}d\theta$.
Write $\cos \theta = \dfrac{e^{i\theta} + e^{-i\theta}}{2} = \dfrac{z+ z^{-1}}{2}$ with $z = e^{i\theta}$, then 
$$\int_0^{2\pi}\dfrac{1}{(a+\cos{\theta})^2}d\theta = \int_{|z|= 1} \dfrac{1}{(a+ \dfrac{z + z^{-1}}{2})^2} \dfrac{dz}{iz} = -4i\int_{|z|= 1} \dfrac{z}{(z^2 + 2az + 1)^2}dz$$
Denote the two roots of $z^2 + 2az + 1 = 0$ by $z_1$ and $z_2$ we have $z_1 = \dfrac{-2a + \sqrt{4a^2 - 4}}{2}$ and $z_2 = \dfrac{-2a - \sqrt{4a^2 - 4}}{2}$ and $z_1z_2 = 1$
Since $a>1$, only $z_1 = \sqrt{a^2 -1 } - a$ is inside $|z|=1$, so the residue of $f(z) = \dfrac{z}{(z^2 + 2az + 1)^2}$ at $z_1$ is the value of $\dfrac{d}{dz}\dfrac{z}{(z-z_2)^2}$ taken at $z = z_1$. Then it's easy to get the result by residue theorem
</s>