Evaluate $\int _0^{2\pi }\frac{\cos (n\theta) }{a+\cos\theta}\,d\theta$ with $a>1$, $n\in \mathbb{N}-\left\{0\right\}$
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. $$