Computation of a certain integral I would like to compute the following integral. This is for a complex analysis course but I managed to around some other integrals using real analysis methodologies. Hopefully one might be able to do for this one too.
$$\int_{0}^{2\pi} \frac{1}{a-\cos(x)}dx, \text{ with } a > 1.$$
Any suggestion will be greatly appreciated.
 A: Let $\tan(x/2) = t$. We then get that $$\sec^2(x/2) dx = 2dt \implies dx = \dfrac{2dt}{1+t^2}$$
Also, $\cos(x) = \dfrac{1-\tan^2(x/2)}{1+\tan^2(x/2)} = \dfrac{1-t^2}{1+t^2}$.
Hence,
\begin{align}
\dfrac{dx}{a- \cos(x)} & = \dfrac{2dt}{1+t^2} \dfrac1{a - \dfrac{1-t^2}{1+t^2}}\\
& = \dfrac{2dt}{a(1+t^2) - (1-t^2)}\\
& = \dfrac{2dt}{(a+1) t^2 + (a-1)}
\end{align}
Hence, $$I = \int \dfrac{2dt}{(a+1) t^2 + (a-1)} = \dfrac2{a+1} \int \dfrac{dt}{t^2 + \dfrac{a-1}{a+1}} = \dfrac2{\sqrt{a^2-1}} \arctan \left(t\sqrt{\dfrac{a+1}{a-1}}\right) + c$$
Writing it in terms of $x$, we get that
$$I = \dfrac2{\sqrt{a^2-1}} \arctan \left(\tan(x/2)\sqrt{\dfrac{a+1}{a-1}}\right) + c$$
A: $$\cos x = \frac{e^{i x}+e^{-ix}}{2}$$
Thus
$$\int_0^{2\pi} \frac{dx}{a-\frac{e^{i x}+e^{-ix}}{2}} = \oint_C \frac{1}{a-\frac{z+z^{-1}}{2}} \frac{dz}{iz} = - i\oint_C \frac{dz}{az-\frac{z^2+1}{2}} = 2i\oint_C \frac{dz}{z^2-2az+1}$$
where $C$ describes the unit circle $|z|=1$, centred at the origin, parametrized by $e^{iz}$ where $0\le z\le 2\pi$.
Letting $f(z)=\frac{1}{z^2-2az+1}$, we find that the poles of $f$ are at $z=a\pm\sqrt{a^2-1}$.  Noting that $a>1$, the only pole in $C$ is the one with the negative sign.  Then
$$\operatorname*{Res}_{z = a-\sqrt{a^2-1}}f(z)= \lim_{z\to a-\sqrt{a^2-1}}\frac{z-a+\sqrt{s^2+1}}{z^2-2az+1}= \lim_{z\to a-\sqrt{a^2-1}}\frac{1}{2z-2a}=- \frac{1}{2\sqrt{a^2-1}}$$
And thus we wrap up:
$$\int_0^{2\pi} \frac{dx}{a-\cos x} = 2i\oint_C \frac{dz}{z^2-2az+1} = 2i\left(-\frac{2\pi i }{2\sqrt{a^2-1}}\right) = \frac{2\pi}{\sqrt{a^2-1}}$$
$\blacksquare$
