<s>[INST] evaluate the integral Evaluate the integral: 
$$\int_0^{\pi} \frac{\cos 2\theta}{1 -2a\cos \theta +a^2}d\theta$$
The way I approach this problem is: 
since, $\cos \theta = \frac{e^{it} + e^{-it}}{2}$; and $cos 2\theta = Re(z^2)$. Then, the integral will be written as follow: 
$$\frac{1}{2}\int_0^{2 \pi} \frac{Re(z^2)}{1 - 2a \left( \frac{z + z^{-1}}{2}\right) +a^2}dz$$
$$ = \frac{1}{2}\int_0^{2\pi} \frac{-Re(z^2)}{(z-z_1)(z-z_2)}dz$$
where: 
$$z_1 = \frac{(2a^2 - 2) + \sqrt{4(a^4+1)}}{4a}; \; z_2 = \frac{(2a^2 - 2) - \sqrt{4(a^4+1)}}{4a}$$
until here, I don't know how to use the Residue theorem to evaluate the integral. Can someone show me ?
 [/INST] Another way is to use the following Fourier expansion: for $|a| < 1$,
$$ \frac{1-a^2}{1 - 2a\cos\theta + a^2} = \sum_{n=-\infty}^{\infty} a^{|n|} e^{in\theta} = 1 + 2 \sum_{n=1}^{\infty} a^n \cos(n\theta). $$
This series immediately gives us
$$ \int_{0}^{\pi} \frac{\cos n\theta}{1 - 2a\cos\theta + a^2} \, dx = \frac{\pi a^n}{1-a^2}, \quad n = 1, 2, \cdots. $$
</s>