Evaluate $\int_0^{2\pi} \frac{\cos 2x}{1-2a\cos x+a^2} $ with $a^2<1$ How do I compute the integration for $a^2<1$,
$$\int_0^{2\pi} \dfrac{\cos 2x}{1-2a\cos x+a^2}dx=? $$
I think that:
$$\cos2x =\dfrac{e^{i2x}+e^{-2ix}}{2},
\qquad\cos x =\dfrac{e^{ix}+e^{-ix}}{2}$$
But I cannot. Please help me.
 A: We have $1-2a\cos x+a^2 = (1-a e^{ix})(1-a e^{-ix})$ hence
$$\frac{1}{1-2a\cos x+a^2} = \left(\sum_{m\geq 0}a^m e^{mix}\right)\cdot\left(\sum_{n\geq 0}a^n e^{-nix}\right)\tag{1}$$
and since for every $a,b\in\mathbb{Z}$ we have 
$$\int_{0}^{2\pi}e^{aix}e^{bix}\,dx = 2\pi\cdot\delta(a+b) \tag{2} $$
it follows that
$$ I=\int_{0}^{2\pi}\frac{\cos(2x)}{1-2a\cos x+a^2}=\pi\sum_{m,n\geq 0}\left(\delta(2+m-n)+\delta(-2+m-n)\right)a^{m+n} \tag{3}$$
equals:
$$ I= \pi\sum_{n\geq 0}a^{2n+2} + \pi\sum_{m\geq 2}a^{2m-2} = \color{red}{\frac{2\pi a^2}{1-a^2}}.\tag{4}$$
A: You are on the right track. By letting $z=e^{ix}$ we have that
$$\int_0^{2\pi} \dfrac{\cos 2x}{1-2a\cos x+a^2}\,dx=
\frac{1}{2}\int_{|z|=1}\dfrac{z^2+1/z^2}{1-a(z+1/z)+a^2}\cdot \frac{dz}{iz}\\=\frac{1}{2i}\int_{|z|=1}\dfrac{z^4+1}{z^2(1-za)(z-a)}\,dz
=\pi\left(\mbox{Res}(f,0)+\mbox{Res}(f,a)\right)$$
where we used the Residue Theorem with $f(z)=\dfrac{z^4+1}{z^2(1-za)(z-a)}$ (note that the poles of $f$ inside $|z|<1$ are $0$ and $a$).
Can you take it from here?
P.S. The final result should be $\frac{2\pi a^2}{1-a^2}$.
A: One can factorise the denominator:
$$ 1-2a\cos{x}+a^2 = (e^{ix}-a)(e^{-ix}-a). $$
Then using partial fractions gives
$$ \frac{1}{2}\frac{e^{2ix}+e^{-2ix}}{(e^{ix}-a)(e^{-ix}-a)} = -\frac{a^2+1}{2 a^2} + \frac{a^4+1}{2 a (a^2-1)}\left( -\frac{1}{e^{i x}-a}-\frac{1}{1-a e^{i x}} \right)-\frac{e^{i x}+e^{-i x}}{2 a} $$
Now, since $a^2<1$, the remaining fractions can be expanded in a power series such as $\sum_{k=0}^{\infty} (ae^{ix})^n $. But
$$ \int_0^{2\pi} e^{inx} \, dx = \begin{cases} 2\pi & n=0 \\ 0 & n \neq 0 \end{cases}, $$
so only the constant terms contribute, and hence the integral is
$$ 2\pi \left( -\frac{a^2+1}{2 a^2} + \frac{a^4+1}{2 a (a^2-1)}\left( \frac{1}{a}-1 \right) \right) = \frac{2\pi a^2}{1-a^2}. $$

It may be easier to use the formula
$$ \frac{1-a^2}{1-2a\cos{x}+a^2} = 1+2\sum_{k=0}^{\infty} a^k\cos{kx} $$
for $\lvert a \rvert <1$.
