TITLE: Evaluate $\int _0^{2\pi }\frac{\cos (n\theta) }{a+\cos\theta}\,d\theta$ with $a>1$, $n\in \mathbb{N}-\left\{0\right\}$
QUESTION [8 upvotes]: Evaluate $$\int _0^{2\pi }\frac{\cos (n\theta) }{a+\cos\theta}\,d\theta,\quad\,a>1$$

I wrote $$f\left(z\right)=\frac{\frac{1}{2}\left(z^n+z^{-n}\right)}{\frac{iz^2}{2}+aiz+\frac{i}{2}}$$
The discriminant is $\Delta =a^2-1>0$
Poles are $z=-a\pm \sqrt{a^2-1}$ and $z=0$
$z=-a+\sqrt{a^2-1}$ and $z=0$ are within the unit circle.
Applying the residue theorem, we compute: $2i\pi \lim _{z\to -a+\sqrt{a^2-1}}\left(\frac{-\frac{i}{2}\left(z^n+z^{-n}\right)}{\frac{1}{2}\left(z+a+\sqrt{a^2-1}\right)}\right)$
The first residue is $\pi \frac{\left(-a+\sqrt{a^2-1}\right)^n+\left(-a+\sqrt{a^2-1}\right)^{-n}}{\sqrt{a^2-1}}$
Now $2i\pi \lim _{z\to 0}\left(\frac{-\frac{i}{2}\left(z^{n+1}+z^{-n+1}\right)}{\frac{1}{2}\left(z+a-\sqrt{a^2-1}\right)\left(z+a+\sqrt{a^2-1}\right)}\right)$ $=\lim _{z\to 0}\left(2\pi \left(z^{n+1}+z^{-n+1}\right)\right)\:$

REPLY [5 votes]: To evaluate the integral $$I(a,n)=\int _0^{2\pi }\frac{\cos (n\theta) }{a+\cos\theta}\,d\theta=\operatorname{Re}\int _0^{2\pi }\frac{e^{in\theta} }{a+\cos\theta}\,d\theta,\quad\,a>1,\quad\,n\in\mathbb N $$
it is suggestive to use the substitution $z=e^{i\theta}$ so that
$$
I(a,n)=\operatorname{Re}\left[\frac1i\oint\limits_{|z|=1}f(z)dz\right]
=2\pi\operatorname{Re}\left[\sum_{z}^{|z|<1}
\operatorname{Res}(f,z)\right]\tag1,
$$
with
$$
f(z)=\frac{2z^n}{z^2+2az+1}\tag2.
$$
The only pole of $f(z)$ lying inside the circle $|z|=1$ is the simple pole at $z=-a+\sqrt{a^2-1}\equiv z_a$.
The residue at the pole can be easily evaluated as
$$
\operatorname{Res}(f,z_a)=\lim_{z\to z_a} (z-z_a)f(z)=\frac{z_a^n}{\sqrt{a^2-1}},
$$
so that finally
$$
I(a,n)=\frac {(\sqrt{a^2-1}-a)^n}{\sqrt {a^2-1}}2\pi\equiv
(-1)^n\frac { e^{-n\operatorname{arccosh} a}}{\sqrt {a^2-1}}2\pi.
$$