# Complex Trigonometric Integration using Residue formula

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?

• This is almost impossible to understand. Use MathJaX, as required when you sign up in this site. Apr 5, 2018 at 15:19
• Add dollar signs to “activate” $\LaTeX$ Apr 5, 2018 at 15:32

Let $f$ be on $\left[0,2\pi\right]$ $$f\left(x\right)=\frac{1}{3-2\cos(x)+\sin(x)}$$ With $z=e^{ix}$ we have $\text{d}z=iz\text{d}x$ and $\displaystyle \frac{z+z^{-1}}{2}=\cos(x)$ and $\displaystyle \frac{z-z^{-1}}{2}=\sin(x)$ Hence $$f\left(x\right)=\frac{2}{6-2z-2z^{-1}-iz+iz^{-1}}=\frac{2}{6-\left(2+i\right)z-\left(2-i\right)z^{-1}}=\frac{2z}{6z-\left(2+i\right)z^2-\left(2-i\right)}$$ So we got slicely what you've done ( careful with the coefficient next time ) because if $P(x)=ax^2+bx+c$ with $x_1$ and $x_2$ two roots then $$P\left(x\right)=a\left(x-x_1\right)\left(x-x_2\right)$$ here you forgot the $a=2+i$.

Now dont forget that you did a change of variable in an integrable, dont forget the $\text{d}z$ hence $$\int_{0}^{2\pi}f\left(x\right)\text{d}x=\int_{\mathscr{C}}^{ }\frac{f\left(z\right)}{iz}\text{d}z=\int_{\mathscr{C}}^{ }\frac{-2i\text{d}z}{6z-\left(2+i\right)z^2-\left(2-i\right)}$$

As you said, only one root interests us, and miraculously

$$\text{Res}\left(f,\frac{2}{5}-\frac{i}{5}\right)=-\frac{i}{2}$$ And finally

$$\int_{0}^{2\pi}\frac{\text{d}x}{3-2\cos(x)+\sin(x)}=2i\pi\text{Res}\left(f,\frac{2}{5}-\frac{i}{5}\right) =\pi$$

Hope it helped you

• Thank you! I knew the residue got to be -i/2 but was thriving to know what i did wrong, and yet it was such an elementary school mistake... 🤦🏻‍♂️ I’m not focused those couple days, my apologies. Apr 5, 2018 at 16:32

A real-analytic approach is both simpler and faster, in my opinion.
$2\sin(x)-\cos(x) = \sqrt{5}\cos(x+\theta_0)$, hence the given integral equals $$\int_{0}^{2\pi}\frac{d\theta}{3-\sqrt{5}\cos\theta}=2\int_{0}^{\pi}\frac{d\theta}{3-\sqrt{5}\cos\theta}=2\int_{0}^{\pi/2}\frac{6\,d\theta}{9-5\cos^2\theta}$$ by periodicity and symmetry. Now letting $\theta=\arctan u$ the last integral becomes $$12\int_{0}^{+\infty}\frac{du}{9(1+u^2)-5}=12\int_{0}^{+\infty}\frac{du}{4+9u^2} = \color{red}{\pi}.$$ See the intro of this question for other viable approaches.