Example of contour integration Could someone help me evaluate the following integral with contour integration ?
$$\int_{0}^{2\pi}\frac{d\theta}{(a+b\cos\theta)^2}.$$
Constraints are: $a>b>0$.
 A: We have:
$$ I = \int_{0}^{\pi/2}\frac{d\theta}{a+b\cos\theta}=\int_{0}^{\pi/2}\frac{d\theta}{a+b\,\frac{1-\tan^2(\theta/2)}{1+\tan^2(\theta/2)}}=2\int_{0}^{\pi/4}\frac{d\theta}{a+b\,\frac{1-\tan^2(\theta)}{1+\tan^2(\theta)}}$$
or just:
$$ I = 2\int_{0}^{1}\frac{dt}{(a+b)+(a-b)\,t^2}=\frac{2}{\sqrt{a^2-b^2}}\,\arctan\sqrt{\frac{a-b}{a+b}} $$
that can be proven with many techniques, not only contour integration. 
That gives:
$$\int_{0}^{2\pi}\frac{d\theta}{a+b\cos\theta}=2\left(I+\int_{0}^{\pi/2}\frac{d\theta}{a-b\cos\theta}\right) = \color{red}{\frac{2\pi}{\sqrt{a^2-b^2}}}\tag{1}$$
since for any $r>0$, $\arctan r+\arctan\frac{1}{r}=\frac{\pi}{2}$.
Now, what about the modified question? We have:
$$ -\frac{d}{da}\frac{1}{a+b\cos\theta} = \frac{1}{(a+b\cos\theta)^2}, \tag{2}$$
hence, by $(1)$ and $(2)$:
$$ \int_{0}^{2\pi}\frac{d\theta}{(a+b\cos\theta)^2} = -\frac{d}{da}\frac{2\pi}{\sqrt{a^2-b^2}} = \color{red}{\frac{2\pi a}{(a^2-b^2)\sqrt{a^2-b^2}}}.\tag{3}$$
A: Using the parametrization $z = e^{i\theta}$, $0 \le \theta \le 2\pi$ for the unit circle, we can write the integral as the contour integral
$$\oint_{|z| = 1} \dfrac{1}{\left(a + b\frac{z + z^{-1}}{2}\right)^2} \frac{dz}{iz},$$
which can be rewritten
$$\oint_{|z| = 1} \dfrac{4z}{i(bz^2 + 2az + b)^2}\, dz,$$
or
$$\frac{4}{ib^2}\oint \frac{z}{(z^2 + \frac{2a}{b}z + 1)^2}\, dz.$$
The roots of $z^2 + 2(a/b)z + 1$ are 
$$z_0 = \frac{-a-\sqrt{a^2 - b^2}}{b}\quad \text{and} \quad z_1 = \frac{-a + \sqrt{a^2 - b^2}}{b}.$$
The point $z_0$ lies outside the circle since 
$$|z_0| = \frac{a + \sqrt{a^2 - b^2}}{b} > \frac{a}{b} > 1.$$ 
So $z_1$ lies inside the circle (shown by computation or by use of the fact $z_0z_1 = 1$ and $|z_0| > 1$). Hence, the function $z/(z - z_0)^2$ is analytic inside and on $|z| = 1$. Since $z^2 + 2(b/a)z + 1 = (z - z_0)(z - z_1)$, it follows from Cauchy's differentiation formula that
\begin{align}\frac{4}{ib^2}\oint_{|z| = 1} \frac{z}{(z + \frac{2b}{a}z + 1)^2}\, dz&= \frac{4}{ib^2} \cdot 2\pi i \frac{d}{dz}\bigg|_{z = z_1} \frac{z}{(z - z_0)^2}\\
&= \frac{8\pi}{b^2} \cdot \frac{-(z_1 + z_0)}{(z_1 - z_0)^3}\\
&= \frac{8\pi}{b^2} \cdot \dfrac{\frac{2a}{b}}{\frac{8(a^2 - b^2)\sqrt{a^2 - b^2}}{b^3}}\\
&= \frac{2\pi a}{(a^2 - b^2)\sqrt{a^2 - b^2}}.
\end{align}
