<s>[INST] Over Cosin Squared Integral Show (using complex analysis) that
$$\int_{0}^\pi \frac{d\theta}{(a+\cos\theta)^2} = \frac{\pi.a}{(a^2-1)^{3/2}}$$
I choose a unite semi-circular path C. So I did:
$$z = e^{i.\theta}$$
$$dz = ie^{i\theta}d\theta \rightarrow d\theta = \frac{dz}{iz} = -i\frac{dz}{z}$$
$$\cos\theta = \frac{e^{i\theta} + e^{-iz}}{2} = \frac{z + z^{-1}}{2}$$
$$\int_{0}^\pi \frac{d\theta}{(a+\cos\theta)^2} = -i\int_{C} \frac{dz}{(a + \frac{z+z^{-1}}{2})z} = 8\pi.Res\left[ \frac{1}{z^3 + 4az^2 + (4a^2+1)z +2a}\right]$$ 
I'm not finding roots for the polynomial and I don't know if this is the best way to solve this problem.
 [/INST] I assume $a > 1$ in the following. For $-1 \leqslant a \leqslant 1$, the integrand would have non-integrable singularities, and for $a < -1$, the given result would have the wrong sign.
To apply the residue theorem we need a closed contour. For the given integral, we could fudge it and take half the sum of the residues in the unit disk for the integral over the semicircle, but I prefer to close it, so using the evenness of the cosine,
$$\int_0^\pi \frac{d\theta}{(a+\cos\theta)^2} = \frac12 \int_{-\pi}^\pi \frac{d\theta}{(a+\cos\theta)^2}$$
to get us an integral over the unit circle. Then we use the substitution you had to obtain
$$\int_0^\pi \frac{d\theta}{(a+\cos\theta)^2} = \frac{1}{2i}\int_{\lvert z\rvert = 1} \frac{1}{\left(a + \frac{z+z^{-1}}{2}\right)^2}\,\frac{dz}{z}.$$
Now you made some mistake I can't figure out when computing the denominator of the integrand.
With
$$\left(a + \frac{z+z^{-1}}{2}\right)(2z) = z^2 + 2az + 1$$
we obtain the two roots
$$\alpha = -a + \sqrt{a^2-1};\quad \beta = -a -\sqrt{a^2-1};$$
of which $\alpha$ lies in the unit disk, and the factorisation $z^2+2az+1 = (z-\alpha)(z-\beta)$.
That gives us
$$\frac{1}{\left(a + \frac{z+z^{-1}}{2}\right)^2z} = \frac{4z}{\left(a + \frac{z+z^{-1}}{2}\right)^2(2z)^2} = \frac{4z}{(z-\alpha)^2(z-\beta)^2}$$
and
$$\begin{align}
\int_0^\pi \frac{d\theta}{(a+\cos\theta)^2} &= \frac{1}{2i}\int_{\lvert z\rvert = 1} \frac{4z}{(z-\alpha)^2(z-\beta)^2}\,dz\\
&= \pi \operatorname{Res}\left(\frac{4z}{(z-\alpha)^2(z-\beta)^2};\, \alpha\right).
\end{align}$$
$\alpha$ is a double pole, so the residue is
$$\left.\frac{d}{dz}\right\rvert_{\alpha} \frac{4z}{(z-\beta)^2} = -\frac{4(\alpha+\beta)}{(\alpha-\beta)^3} = \frac{8a}{(2\sqrt{a^2-1})^3} = \frac{a}{(a^2-1)^{3/2}}.$$
</s>