I’m trying to calculate the following integral: $$I=\int_{0}^{2\pi}\left(\frac{1} {3-2\cos x +\sin x}\right)\,dx$$
Using De Moivre formula, and setting $z= e^{ix}$, the -factorised- integral becomes : $$I=\int{ \frac{2dz} { (z-(2-i)) \cdot (z-\frac{(2-i)}{5}) } }$$ where $|z|=1$ is the contour.
Thefore, using the Residue formula over the closed contour $|z|=1$ gives us: $$I = 2i\pi \cdot \operatorname{Res}\left(f(z),\frac{(2-i)}{5}\right)$$ excluding the other point $2-i$ since it’s out of $|z|=1$.
Calculating the residue, we get $\operatorname{Res}= -1 - \frac{i}{2}$
Thereby, $I = 2i\pi(-1-\frac{i}{2}) = \pi - 2i\pi$.
The thing is that the result of the integral can’t have an imaginary part since the main integral is all real...
Doing a further search I got to find that the integral equals: $I = \pi$ , which is the real part of my answer.
So what did I do wrong? Where’s my mistake?