<s>[INST] Contour integration question help I am trying to evaluate the following integral using complex analysis:
$$\int^{2\pi}_0\frac{\cos(2x)}{5-4\cos(x)}dx$$
I have written it in the following form:
$$\frac{-i}{2}\int_{|z|<1}\frac{z^4+1}{z^2(z-2)(1-2z)}dz$$
However, the residue for $z=1/2$ is $-17/6$ whereas the residue for the double pole at $z=0$ is $-5/4$ and when the sum of these residues is multiplied by $2\pi i\times\frac{-i}{2}=\pi$ the wrong result is obtained (i.e. not $\pi/6$).
What is it that I am doing wrong?
 [/INST] \begin{align}
\operatorname{Res}\limits_{z=1/2} \frac{z^4+1}{z^2(z-2)(1-2z)} &=
\lim_{z\to 1/2} (z-\frac12) \cdot \frac{z^4+1}{z^2(z-2)(1-2z)} \\
&= \lim_{z\to 1/2} \frac{z^4+1}{z^2(z-2)\cdot(-2)} = \frac{(1/2)^4+1}{(1/2)^2\cdot(-3/2)\cdot(-2)} = \frac{17}{12}
\end{align}
</s>