Trigonometric Integral Using Residue Theorem Evaluate:
$$\int_{0}^{2\pi} \frac{1}{1+a^2-2a \cos(x)} dx$$
where $a>1$.
I am trying to transform the integral into a contour integral in which the Residue Theorem would apply, but am having trouble.
 A: Hint: One way is to let $z=e^{ix}$ so that $\mathrm{d}x=\frac{\mathrm{d}z}{iz}$ and $\cos(x)=\frac12\left(z+z^{-1}\right)$. Then
$$
\begin{align}
\int_{|z|=1}\frac1{1+a^2-a\left(z+z^{-1}\right)}\frac{\mathrm{d}z}{iz}
&=\frac ia\int_{|z|=1}\frac1{z^2-z\left(\frac1a+a\right)+1}\mathrm{d}z\\
&=\frac ia\int_{|z|=1}\frac1{(z-a)\left(z-\frac1a\right)}\mathrm{d}z
\end{align}
$$
A: Another variant is applying Poisson's formula to the constant function $f(z)=1$ and the point $\frac1a$:
$$
1 = f(\tfrac1a) = 
\frac1{2\pi} \int_0^{2\pi} \frac{1-\frac1{a^2}}{1-\frac2a\cos x+\frac1{a^2}} f(e^{ix}) \,\mathrm{d}x =
\frac{a^2-1}{2\pi} \int_0^{2\pi} \frac{\mathrm{d}x}{1-2a\cos x+a^2} 
$$
so
$$
\int_0^{2\pi} \frac{\mathrm{d}x}{1-2a\cos x+a^2} 
= \frac{2\pi}{a^2-1}.
$$
A: Put
$$z=e^{ix}\implies dz=ie^{ix}=iz\,dx\implies dx=-\frac{i\,dz}z\;,\;\;\cos x=\frac{z+z^{-1}}2=\frac{z^2+1}{2z}\implies$$
$$\int_0^{2\pi}\frac{dx}{1+a^2-2a\cos x}=\oint_{|z|=1}-\frac{i\,dz}z\frac1{1+a^2-2a\frac{z^2+1}{2z}}=$$
$$=i\oint_{|z|=1}\frac{dz}{az^2-(a^2+1)z+a}=\frac ia\oint_{|z|=1}\frac{dz}{(z-a)\left(z-\frac1a\right)}$$
Can you finish now?
