Evaluate: $\int_{0}^{\pi}\frac{\cos 2017x}{5-4\cos x}dx$ Evaluate:
$\int\limits_{0}^{\pi}\dfrac{\cos 2017x}{5-4\cos x}~dx$
I thought of using some series but could not get it
 A: You may go "the other way round".

Lemma (S). Since $\cos(x)=\frac{e^{ix}+e^{-ix}}{2}$,
  $$ \sum_{n\geq 0}\frac{2\cos(nx)}{2^n}=1+\frac{3}{5-4\cos x}.$$

Since $\int_{0}^{\pi}\cos(nx)\cos(mx)\,dx = \frac{\pi}{2}\,\delta(m,n)$, the Fourier cosine series shown by (S) directly gives the value of the wanted integral, $\color{red}{\frac{\pi}{3}\cdot 2^{-2017}}$.
A: $\newcommand{\bbx}[1]{\,\bbox[8px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
&\int_{0}^{\pi}{\cos\pars{2017x} \over 5 - 4\cos\pars{x}}\,\dd x  =
\left.\Re\int_{0}^{\pi}{z^{2017} \over 5 - 4\pars{z+1/z}/2}
\,{\dd z \over \ic z}\right\vert_{\ z\ =\ \exp\pars{\ic x}}
\\[5mm] = &\
\left.-\,{1 \over 2}\,\Im\int_{0}^{\pi}{z^{2017} \over z^{2} - \pars{5/2}z + 1}
\,\dd z\,\right\vert_{\ z\ =\ \exp\pars{\ic x}} =
\left.-\,{1 \over 2}\,\Im\int_{0}^{\pi}{z^{2017} \over
\pars{z - 1/2}\pars{z - 2}}\,\dd z\,\right\vert_{\ z\ =\ \exp\pars{\ic x}}
\\[5mm] = &\
{1 \over 2}\,\Im\lim_{\epsilon \to 0^{+}}
\int_{\pi}^{0}{\pars{1/2 + \epsilon\expo{\ic\theta}}^{2017} \over
\epsilon\expo{\ic\theta}\pars{1/2 + \epsilon\expo{\ic\theta} - 2}}
\epsilon\expo{\ic\theta}\ic\,\dd\theta =
{1 \over 2}\pars{-\pi}{\pars{1/2}^{2017} \over 1/2 - 2}
\\[5mm] = &\
\bbx{\ds{{2^{-2017} \over 3}\,\pi}} \approx 6.9587 \times 10^{-608}
\end{align}
