Solving a complex integral I need help solving an integral from John Conway book. 
Lets $\alpha$ complex number different from 1 find integral $$\int\frac{dx}{1-2\alpha\cos{x}+{\alpha}^2}$$ from 0 to $2\pi$ in unit circle $$(z-\alpha)^{-1}(z-\frac{1}{\alpha})^{-1}$$
 A: Substitute: $z = e^{i x}$ then:
$$\cos x = \frac{1}{2} \left( z + \frac{1}{z} \right), \; dx = \frac{1}{i} \cdot \frac{dz}{z}$$
and we can rewrite the integral as:
$$ i \int_{|z|=1} \frac{dz}{a (z-a)(z - \frac{1}{a})}$$
There are two cases:


*

*$|a| < 1$ then only $z=a$ is a pole inside a circle and the residue is:
$${\rm res}_{z=a} \frac{1}{a (z-a)(z - \frac{1}{a})} = \lim_{z \to a} \frac{z-a}{a (z-a)(z - \frac{1}{a})} = \frac{1}{a^2 - 1}$$
hence the result is:
$$2 \pi i \cdot \frac{i}{a^2 - 1} = \frac{2 \pi}{1 - a^2}$$

*$|a| > 1$ similarly only $1/a$ lies inside the circle and the residue is:
$${\rm res}_{z=1/a} \frac{1}{a (z-a)(z - \frac{1}{a})} = \lim_{z \to 1/a} \frac{z-\frac{1}{a}}{a (z-a)(z - \frac{1}{a})} = \frac{1}{1 - a^2}$$
hence the result is:
$$2 \pi i \cdot \frac{i}{1 - a^2} = \frac{2 \pi}{a^2 - 1}$$
A: Let $t=\tan(x/2) $ so that $\cos x = \frac{1-t^2}{1+t^2}$ and $dx=\frac{2 dt}{1+t^2}.$ The integral becomes $$ \int \frac{1}{1-2\alpha \frac{1-t^2}{1+t^2} + \alpha^2} \frac{2 dt}{1+t^2}=2 \int \frac{dx}{(\alpha-1)^2+ (\alpha+1)^2 t^2}= \frac{1}{\alpha^2-1} \tan^{-1} \left( \frac{(\alpha+1)t}{\alpha-1} \right)+ C= \frac{1}{\alpha^2-1} \tan^{-1} \left( \frac{(\alpha+1)\tan(x/2)}{\alpha-1} \right)+ C$$
