<s>[INST] Calculating complex integral with Residue - where is my fault? \begin{align}\int_0^{2\pi} \frac{\cos(x)}{13+12\cos(x)} dx & = \displaystyle\int_0^{2\pi} \frac{(z+1/z)\frac{1}{2}}{13+12(z+1/z)\frac{1}{2}}\frac{1}{iz} dz \\
& = \cdots \\
&= -i\displaystyle\int_0^{2\pi} \frac{z^2+1}{\left(z+\frac{2}{3}\right)\left(z+\frac{3}{2}\right)z}dz \\
&= 2\pi i (-i) \operatorname{Res}\left(\frac{z^2+1}{\left(z+\frac{2}{3}\right)\left(z+\frac{3}{2}\right)z};0\right) \\
&=2\pi \lim_{z\to0}\frac{z^2+1}{\left(z+\frac{2}{3}\right)\left(z+\frac{3}{2}\right)}\\
&=2\pi \frac{0^2+1}{\left(0+\frac{2}{3}\right)\left(0+\frac{3}{2}\right)}\\
&=2\pi
\end{align}
But Wolfram Alpha says it's $\frac{4\pi}{15}$.
What am I doing wrong ?
 [/INST] You forget the residue at $-2/3$, because the change of variable is $z=e^{it}$, so the integral in $z$ is not from $0$ to $2\pi$, is in the unit circle, that includes inside $-2/3$.
$\begin{align}\displaystyle\int_0^{2\pi} \frac{cos(x)}{13+12cos(x)} dx & = \displaystyle\int_\gamma \frac{(z+1/z)\frac{1}{2}}{13+12(z+1/z)\frac{1}{2}}\frac{1}{iz} dz \\
& = \dots \\
&= -i\displaystyle\int_\gamma \frac{z^2+1}{(3z+2)(2z+3)2z}dz \\
&= 2\pi i (-i) (Res(f;0)+Res(f;2/3)) \\
&=2\pi (\lim_{z\to0}\frac{z^2+1}{(3z+2)2(2z+3)}+\lim_{z\to\frac{-2}{3}}\frac{z^2+1}{2z(2z+3)3})\\
&=-\frac{4\pi}{15}
\end{align} $
Another mistake was in the factorization of the denominator:
$$12z^3+26z^2+12z\not=z(z+2/3)(z+3/2)$$
though the roots are the same
</s>