# 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 ?

• You did not consider the residue at $-\frac{2}{3}$. Jun 26 at 18:41
• @Riemann: But isn't it outside of $[0,2\pi]$ because of negativity ? Jun 26 at 18:42
• What has $[0,2\pi]$ to do with this? What matters is that $-\frac23$ belongs to the open unit disk. Jun 26 at 18:46

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
On the right-hand side of the first line, the integral should no longer be over the real interval $$[0,2\pi]$$; rather, it should be over the unit circle in the complex plane. In addition to correcting that calculational step and subsequent ones, that also explains why the residue at $$z=-\frac23$$ is relevant: it's inside the unit circle.