Two different results with residue calculus for the integral $\int_{0}^{2\pi}\frac{\cos(3x)}{5-4\cos(x)}dx$. What went wrong? So I have to evaluate the following integral :$$\int_{0}^{2\pi}\frac{\cos(3x)}{5-4\cos(x)}dx$$ So I solve as usual with the residue theorem and by using $\cos(3x)= Re(e^{3ix})$, $\cos(x)=\frac{e^{ix}+e^{-ix}}{2}$ and $z=e^{ix}$, but then I have some troubles evaluating the residues. I get as poles 2 and $\frac{1}{2}$ where only $\frac{1}{2}$ is in our domain (circle of radius 1). 
When I calculate the residue using $\frac{g(z)}{f'(z)}$, I get $\frac{\frac{1}{2^3}}{5-2}=\frac{1}{24}$ (I put the i outside, that's not the problem here) but when I use $\lim_{z \to \frac{1}{2}} (z-\frac{1}{2})\frac{z^3}{-(z-2)(z-\frac{1}{2})}$, I get $\frac{1}{12}$ so that when I multiply by $2 \pi $ (again the i is not the problem here), I get $\frac{\pi}{6}$. WolframAlpha gets $\frac{\pi}{12}=2\pi *\frac{1}{24}$ so my second way of finding the residue ($\frac{1}{12}$-->$\frac{\pi}{6}$) seems to be wrong. My question is, what did I do wrong ?

Well, you arrived at: $$I=\int_{|z|=1}\frac{z^3}{5-4\left(\frac{z+ z^{-1}}{2}\right)}\frac{dz}{iz}$$
With some algebra the integral reduces to : $$\int_{|z|=1}\frac{z^3}{5z-2(z^2+1)}\frac{dz}{i}=\frac{1}{i}\int_{|z|=1}\frac{z^3}{-2z^2+5z-2}dz=$$
$$=\frac{1}{i}\int_{|z|=1}\frac{z^3}{-(z-2)(2z-1)}dz=\frac{1}{2i}\int_{|z|=1}\frac{z^3}{-(z-2)(z-\tfrac12)}dz$$
Now here you can see that when you factored that denominator you forgot that additional $\frac12$ and everything should be fine now.
