<s>[INST] $\int_{0}^{2\pi} \frac{\cos{3\theta}}{5-4\cos{\theta}}\,d{\theta}$ by using complex/real integration How to evaluate $\int_{0}^{2\pi} \frac{\cos{3\theta}}{5-4\cos{\theta}}\,d{\theta}$ 
by using complex integration?
I assume $z=e^{i{\theta}}$, $\frac{1}{iz}dz=d{\theta}$,
$$\cos{\theta}=\frac{z+z^{-1}}{2}
\quad\mbox{and}\quad \cos3{\theta}=\frac{(z+z^{-1})(z^2+z^{-2}-1)}{2}.$$
Hence 
$$\frac{1}{2i}\oint_{|z|=1} \frac{{(z+z^{-1})(z^2+z^{-2}-1)}}{(5-4\frac{z+z^{-1}}{2})z}\,dz$$
and I'm stuck in this. Could you give me a hints or solution?
 [/INST] Complex Method
We better use $\cos 3x=Re(e^{3xi})=Re(z^3)$ to make the life easier.
Let $z=e^{xi}$, then the integral is transformed to a contour integration with a unit circle in anti-clockwise direction.
\begin{aligned}
I&=\operatorname{Re} \oint_{|z |=1}\frac{z^3}{5-\frac{4}{2}\left(z+\frac{1}{z}\right)} \cdot \frac{d z}{i z}\\
& = \operatorname{Re}\left(\frac{-1}{i} \oint_{|z |=1} \frac{z^3}{(2 z-1)(z-2)} d z\right) \\
& =\operatorname{Re}\left(-2 \pi\left(\frac{1}{2} \cdot \frac{\frac{1}{8}}{-\frac{3}{2}}\right)\right) \\
& =\frac{\pi}{12} 
\end{aligned}

Real Method
$\begin{aligned} \displaystyle \int_{0}^{2 \pi} {\frac{\cos(3 x)}{5 - 4 \cos(x)}} dx & = \int_{0}^{2 \pi} {\frac{4 \cos^{3}(x) - 3 \cos(x)}{5 - 4 \cos(x)}} dx \\ &= \int _ { 0 } ^ { 2 \pi } \left[ - \cos ^ { 2 } x - \frac { 5 } { 4 } \cos x - \frac { 13 } { 16 } + \frac { 65 } { 16 ( 5 - 4 \cos x ) } \right] d x\\ & = \left[ - \frac { x } { 2 } - \frac { \sin 2 x } { 4 } - \frac { 5 } { 4 } \sin x - \frac { 13 } { 16 } x \right] _ { 0 } ^ { 2 \pi } +\frac { 65 } { 16 } \int _ { 0 } ^ { 2 \pi } \frac { d x } { 5 - 4 \cos x }\\&= - \frac { 21 \pi } { 8 } + \frac { 65 } { 16 } \int _ { 0 } ^ { 2 \pi } \frac { d x } { 5 - 4 \cos x } \end{aligned} \tag*{} $
$\displaystyle \textrm{Let }t=\tan \frac{x}{2}, \textrm{ then }d t = \frac { 1 } { 2 } ( 1 + t ^ { 2 } ) d x$
$\displaystyle \begin{aligned} \int _ { 0 } ^ { 2 \pi } \frac { d x } { 5 - 4 \cos x }  & =2 \int _ { 0 } ^ { \pi } \frac { d x } { 5 - 4 \cos x  } \\ &=2 \int_0^{\infty} \frac{1}{5-4 \cdot \frac{1-t^2}{1+t^2}} \cdot \frac{2 d t}{1+t^2}\\&  = 4 \int _ { 0 } ^ { \infty } \frac { d t } { ( 3 t ) ^ { 2 } + 1 } \\&= \frac { 4 } { 3 }\left [ \tan ^ { - 1 } ( 3 t )\right ] _ { 0 } ^ { \infty }  \\ &= \frac { 4 } { 3 } \cdot \frac { \pi } { 2 }  \\ &= \frac { \pi } { 6 } \end{aligned} \tag*{} $
$\displaystyle \therefore I = - \frac { 21 \pi } { 8 } + \frac { 65 } { 16 } \cdot \frac { 2 \pi } { 3 }=\boxed{\frac{\pi }{12}} \tag*{} $
</s>