Contour Integration with $\cos(n \theta)$ I need to compute the following real integral using complex numbers. I'm unsure how to handle the numerator so that the ensuing calculations do not become too  unwieldily. 
$\int_{0}^{2\pi} \frac{ \cos n\theta}{\cos(\theta)-a} d\theta$ Thanks!
 A: Let $I(a)$ be given by 
$$I(a)=\int_0^{2\pi} \frac{\cos (n\theta)}{cos \theta -a}\,d\theta$$
Using Euler's Formula, we can write $I(a)$ as
$$I(a)=\text{Re}\left(\int_0^{2\pi} \frac{e^{in\theta}}{cos \theta -a}\,d\theta\right) \tag 1$$
Now, letting $z=e^{i\theta}$ in $(1)$ reveals
$$\begin{align}
I(a)&=\text{Re}\left(-2i\oint_{|z|=1}\frac{z^n}{z^2-2az+1}\,dz\right)\\\\
&=4\pi \text{Res}\left(\frac{z^n}{z^2-2az+1},z=a-\sqrt{a^2-1}\right)\\\\
&=-2\pi \frac{\left(a-\sqrt{a^2-1}\right)^n}{\sqrt{a^2-1}}
\end{align}$$
A: The equivalent contour integral is
$$-i \oint_{|z|=1} \frac{dz}{z^n} \frac{z^{2 n}+1}{z^2-2 a z+1} $$
There are two poles inside this unit circle: $z=0$ and $z=a-\sqrt{a^2-1}$.  Let's first write down the residue at $z=a=\sqrt{a^2-1}$, which the reader should be able to show (the pole is simple) that it is
$$\frac{i}{2\sqrt{a^2-1}} \left [\left (a+\sqrt{a^2-1}\right )^n +\left (a-\sqrt{a^2-1}\right )^n  \right ]$$
The computation of the residue at the pole at $z=0$ is obviously more complicated.  However, rather than attempt to evaluate an $n-1$th derivative of the rational function in the integrand, we will have better luck by expanding the denominator for small $z$ and locating the coefficient of $z^{n-1}$.  Note that
$$\frac1{z^2-2 a z+1} = \sum_{k=0}^{\infty} U_k(a) z^k$$
where $U_k$ is a Chebyshev polynomial of the second kind.  In this case, as $a \gt 1$, we have the residue in this case being
$$-i U_{n-1}(a) = -i \frac{\sinh{(n \operatorname{arccosh}{a})}}{\sinh{( \operatorname{arccosh}{a})}} = -\frac{i}{2\sqrt{a^2-1}}\left [\left (a+\sqrt{a^2-1}\right )^n -\left (a-\sqrt{a^2-1}\right )^n  \right ]$$
The integral is then $i 2 \pi$ times the sum of these residues.  We may then write

$$\int_0^{2 \pi} d\theta \frac{\cos{n \theta}}{a-\cos{\theta}} = \frac{2 \pi}{\sqrt{a^2-1}}\left (a-\sqrt{a^2-1}\right )^n$$

