How to solve this integral using the method of residues? Using the method of residues, verify the following.
$$\int_0^{\pi} \frac{d \theta}{(3+2cos \theta)^2} = \frac{3 \pi \sqrt{5}}{25}$$
I tried doing this but can't get the correct answer, here is my attempt:
first I substituted $cos \theta = \frac{z+ \frac{1}{z}}{2}$ and $d \theta = \frac{dz}{iz}$ and got $\int_0^{\pi} \frac{dz}{iz(3+z+\frac{1}{z})^2}$  
then I multiplied top and bottom my $iz$ so that the $i$ moves to the top and on the bottom I'll have $z^2$ so I can distribute it into the rest of it and get $-i \int_0^{\pi} \frac{zdz}{(3z+z^2+1)^2}$
the denominator has two zeroes at $-\frac{3}{2} \pm \sqrt{\frac{5}{4}}$, since the denominator is squared the function has poles here of order two.
The I used Cauchy's Residue theorem but first I needed to find the residue at $-\frac{3}{2} + \sqrt{\frac{5}{4}}$ because only this pole is inside the unit circle.
I found the residue using theorem 1 on pdf page 324/579 from this textbook
http://english-c.tongji.edu.cn/_SiteConf/files/2014/05/05/file_53676237d7159.pdf
After finding the residue using that formula and applying cauchy's residue theorem I do not get an answer close to $\frac{3 \pi \sqrt{5}}{25}$  
I am not sure how to handle the fact that the integral is from $0$ to $\pi$ rather then from $0$ to $2\pi$, and I am not sure if I made any mistakes when finding the poles and residues.
 A: By the substitution $\theta=2\varphi$ and the cosine duplication formula we have
$$ I = \int_{0}^{\pi}\frac{d\theta}{(3+2\cos\theta)^2} = 2\int_{0}^{\pi/2}\frac{d\varphi}{(1+4\cos^2\varphi)^2} \tag{1}$$
and by the substitution $\varphi=\arctan t$ the problem boils down to evaluating
$$ 2\int_{0}^{+\infty}\frac{(1+t^2)}{(5+t^2)^2}\,dt = \int_{-\infty}^{+\infty}\frac{(1+t^2)}{(5+t^2)^2}\,dt.\tag{2}$$
The meromorphic function $f(t)=\frac{(1+t^2)}{(5+t^2)^2}$ has a double pole at $t=\pm i\sqrt{5}$ and behaves like $\frac{1}{t^2}$ for $|t|\to +\infty$. By the residue theorem it follows that:
$$ I = 2\pi i\,\text{Res}(f(t),t=i\sqrt{5}) =2\pi i\lim_{t\to i\sqrt{5}}\frac{d}{dt}\frac{(1+t^2)}{(t+i\sqrt{5})^2}=\color{red}{\frac{3\pi}{5\sqrt{5}}}\tag{3}$$
as wanted, after a straightforward computation.

There also is a simple geometric approach. $\rho(\theta)=\frac{p}{1+\varepsilon\cos\theta}$ is the polar equation of an ellipse with respect to a focus. Since the area in polar coordinates is given by $\frac{1}{2}\int_{0}^{2\pi}\rho(\theta)^2\,d\theta$, $I$ just depends on the area of an ellipse ($\pi ab $) with a given eccentricity and a given semi-latus rectum. This proves the more general
$$ \int_{0}^{\pi}\frac{d\theta}{(u+v\cos\theta)^2} = \frac{\pi u}{\left(u^2-v^2\right)^{3/2}} \tag{4}$$
as soon as $0<v<u$.
A: Note
$$\int_0^{\pi} \frac{d \theta}{(3+2\cos \theta)^2} = \frac12\int_0^{2\pi} \frac{d \theta}{(3+2\cos \theta)^2}.$$
Let $z=e^{i\theta}$ and hence one has
\begin{eqnarray}
&&\int_0^{\pi} \frac{d \theta}{(3+2\cos \theta)^2}\\
&=&\frac12\int_0^{2\pi} \frac{d \theta}{(3+2\cos \theta)^2}\\
&=&\frac12\int_{|z|=1}\frac{1}{(3+z+z^{-1})^2}\frac{dz}{iz}\\
&=&\frac1{2i}\int_{|z|=1}\frac{z}{(z^2+3z+1)^2}dz\\
&=&\pi\text{Res}(f(z),z=\frac{1}{2}(-3+\sqrt5))\\
&=& \frac{3 \pi \sqrt{5}}{25}
\end{eqnarray}
where $f(z)=\frac{z}{(z^2+3z+1)^2}$ has only one pole $z=\frac{1}{2}(-3+\sqrt5)$ inside $|z|=1$.
