Evaluate $\int_0^{2\pi} \frac{d\theta}{\left(1+\beta \cos (\theta )\right)^2}$ I am trying to evaluate the integral
$$\int_0^{2\pi} \frac{d\theta}{\left(1+\beta \cos \left(\theta\right)\right)^2}$$
via change of variables and applying Cauchy's Residue Theorem. Here is how I'm approaching this.
First, I make the the change of variables:
$$\begin{align*}
z&=e^{i\theta}\\
dz&=\dfrac{1}{iz}d\theta\\
\cos\left(\theta\right)&=\dfrac{1}{2}(z+z^{-1})
\end{align*}
$$
Substituting these back in, the integral then becomes the complex line-integral,
$$\oint_{|z|=1}\frac{dz}{iz\left(1+\beta(z+z^{-1})\right)^2}$$
The integrand has three singularities: a removable singularity $z=0$ (that approaches 0), and poles of order 2 at $z=\dfrac{-1}{\beta}\left(1\pm\sqrt{1-\beta^2}\right)$. This means that if we just compute the sum of the residues of the integrand and multiply that by $2\pi i$, then by Cauchy's Theorem we'll have evaluated the primary integral.
To compute the residue of the integrand at $z=\dfrac{-1}{\beta}\left(1\pm\sqrt{1-\beta^2}\right)$, because there are poles of order 2 at each of the points we must first take the derivative of the part that is analytic in a nearby domain of the singularity, and then evaluate it at that point. 
At this point it becomes extremely messy. I will edit this and write in my computations, but only if nobody seems to find any error or shortcut in my previous steps.

EDIT: As suggested in the comments, the substitution $z=\beta e^{i \theta}$ is also valid. Doing that, the integral becomes
$$\begin{align*}
\oint_{|z|=\beta} \frac{dz}{iz\left(1+\frac{1}{2}\left(z+z^{-1}\right)\right)^2} &= -i\oint_{|z|=\beta}\frac{2z}{\left(z^2+2z+1\right)^2}dz\\
&=-i\oint_{|z|=\beta} \frac{2z}{\left(z+1\right)^4}dz
\end{align*}$$
But look at that! The integrand is analytic in the region bounded by $|z|=\beta$, and so by Cauchy's Theorem the integral is always $0$, which can't be right. Any more suggestions?

One pole is inside the contour the other is outside the contour. And if you put $z = \beta\exp(i\theta)$ then $z^{-1}$ will have a factor of $\beta^{-1}$ instead of the desired $\beta$  so you must multiply that by $\beta^{2}$. 
Note that the sum of all the residues in the complex plane, including the residue at infinity, always equals zero. This means that the value of a contour integral is given by either the sum of the residues of the poles inside the contour, or by minus the sum of the residues of the poles outside the contour.
