Integral $\int_0^{\pi} \frac{\cos(2018x)}{5-4\cos{x}}dx$ I wish to evaluate  $$I(2018)=\int_{0}^{\pi}\frac{\cos(2018x)}{5-4\cos x} dx$$ Considering $$X=I(k)+iJ(k)=\int_{-\pi}^{\pi}\frac{\cos{kx}}{5-4\cos x} dx +i\int_{-\pi}^{\pi}\frac{\sin{kx}}{5-4\cos x} dx=\int_{-\pi}^{\pi}\frac{e^{ikx}}{5-4\cos x} dx$$ let us substitute $$e^{ix}=z\rightarrow dx=\frac{dz}{iz} \, ,|z|=1$$ Due to Euler's formula we can rewrite $$\cos x=\frac{z^2+1}{2z}$$ $$X=\oint_{|z|=1} \frac{z^k}{5-4\frac{z^2+1}{2z}}\frac{dz}{iz}=\frac{1}{i}\oint_{|z|=1} \frac{z^k}{-2z^2+5z-2}dz$$ $$-2z^2+5z-2=-\frac{1}{2}((2z)^2-5(2z)+4)=-\frac{1}{2}(2z-4)(2z-1)=-2(z-2)(z-\frac{1}{2})$$ Now let us notice that in our contour $|z|=1\,$ only the pole $z_2=\frac{1}{2}$ is found. Thus the integral we seek to evaluate is $$\frac{1}{i} \cdot 2\pi i \, \text{Res} (f(z),z_2)$$ where $f(z)=\frac{z^k}{-2(z-2)(z-\frac{1}{2})}$ $$X=2\pi \lim_{z\to z_2} (z-z_2)\frac{z^k}{-2(z-2)(z-z_2)}=\frac{2}{3}\pi \frac{1}{2^k}$$ therefore $$I(k)=\Re (X) =\frac{2\pi}{3}\frac{1}{2^k}$$ And $$\int_{0}^{\pi}\frac{\cos(2018 x)}{5-4\cos x} dx=\frac{\pi}{3}\cdot\frac{1}{2^{2018}}.$$ Now someone told me that the answer is $0$ and I am wrong (also wolfram gives $0$ as an answer). Could you please clarify? Or maybe give another solution to this integral if it's $0$ or another answer? 

You are correct! This is an elementary approach without complex analysis. 
Since $$\cos((n+1)x)+\cos((n-1)x)=2\cos(nx)\cos(x)$$ then for $n\geq 1$, we have the linear recurrence
$$\begin{align}
I(n-1)+I(n+1)&=\int_{0}^{\pi}\frac{2\cos(nx)\cos(x)}{5-4\cos(x)} dx\\
&=
-\frac{1}{2}\int_{0}^{\pi}\frac{\cos(nx)(-5+5-4\cos(x))}{5-4\cos(x)} dx\\
&=
\frac{5}{2}I(n)-\frac{1}{2}\int_{0}^{\pi}\cos(nx) dx=\frac{5}{2}I(n).
\end{align}$$
Then
$$I(n)=A2^n+\frac{B}{2^n}$$
for some constants $A$ and $B$. Since $I(n)$ is bounded it follows that $A=0$ and
$$I(n)=\frac{I(0)}{2^n}=\frac{1}{2^n}\int_{0}^{\pi}\frac{dx}{5-4\cos(x)} =\frac{1}{2^n}\left[\frac{2\arctan(3\tan(x/2))}{3}\right]_{0}^{\pi}=\frac{\pi/3}{2^n}.$$
P.S. In order to show that $I(n)$ is not zero for any $n$ it suffices to say that $I(0)>0$ since it is the integral of a positive continuous function.
