How do I prove $\int^{\pi}_{0} \frac{\cos nx}{1+\cos\alpha \cos x} \mathrm{d}x = \frac{\pi}{\sin \alpha} (\tan \alpha - \sec \alpha)^n $? The result I wish to show is that for $n \in \mathbb{Z}$, $$\int^{\pi}_{0} \frac{\cos nx}{1+\cos\alpha \cos x} \mathrm{d}x  = \frac{\pi}{\sin \alpha} (\tan \alpha - \sec \alpha)^n $$
I have made a few attempts through the first techniques that came to my mind but I have not made any meaningful progress.
 A: Hint:
Use the following relation
\begin{equation}
\frac{\sin\alpha}{1+\cos\alpha\cos x}=1+2\sum_{k=1}^\infty \left(\frac{\sin\alpha-1}{\cos\alpha}\right)^k\cos(kx)
\end{equation}
It can be obtained by writing cosine in the denominator of the integrand out in exponential form as the following
\begin{equation}
\frac{A^2-B^2}{A^2-2AB\cos x+B^2}=\frac{A}{A-Be^{ix}}+\frac{Be^{-ix}}{A-Be^{-ix}}
\end{equation}
where we use $A^2+B^2=1$, $-2AB=\cos\alpha$, and the geometric series in form of $\frac{1}{1-y}$. Then use the following relations
\begin{equation}
\int_0^\pi\cos nx\cos mx\ dx=\begin{cases} 
   0&, & \text{if}\ \ n\ne m \\[20pt]
   \dfrac{\pi}{2}&,       & \text{if}\ \ n=m
  \end{cases}
\end{equation}
A: One approach is to use contour integration.
Assuming that $0 <\alpha < \pi $ and $n \in \mathbb{Z}_{\geq 0}$,
$$ \begin{align}\int_{0}^{\pi} \frac{\cos nx}{1+ \cos \alpha \cos x} \, dx &= \frac{1}{2} \, \text{Re} \int_{-\pi}^{\pi} \frac{e^{inx}}{1+\cos \alpha \cos x} \, dx \\ &= \frac{1}{2} \, \text{Re} \int_{|z|=1} \frac{z^{n}}{1+ \cos \alpha \left(\frac{z+z^{-1}}{2} \right)} \frac{dz}{iz} \tag{1}\\ &=   \frac{1}{\cos \alpha} \, \text{Re} \,  \frac{1}{i} \int_{|z|=1} \frac{z^{n}}{z^{2}+2z \sec \alpha + 1 } \\ &= \frac{2 \pi}{\cos \alpha} \, \text{Re} \,  \text{Res} \left[\frac{z^{n}}{z^{2}+2z \sec \alpha +1}, \tan \alpha - \sec \alpha \right] \\ &= \frac{2 \pi}{\cos \alpha} \,  \text{Re} \, \frac{(\tan \alpha -\sec \alpha)^{n}}{2(\tan \alpha - \sec \alpha)+ 2 \sec \alpha} \tag{2}\\ &= \frac{\pi}{\sin \alpha} \left(\tan \alpha - \sec \alpha \right)^{n}.\end{align}$$
For the case $\alpha = \frac{\pi}{2}$, the right side of the equation should be interpreted as a limit.

$(1)$ Let $z=e^{ix}$.
$(2)$ The pole at $z= -\tan \alpha - \sec \alpha$ is outside the unit circle since $0 < \alpha < \pi$.
