Evaluate using Cauchy's integral theorem $$\int_{0}^{\frac{\pi}{2}} \frac{d\theta}{2+\sin(\theta)}.$$
I understand the idea is to use $\sin(\theta) = \frac{z-z^{-1}}{2i}$ and $z = e^{i\theta}$ to convert into the complex plane and simplified to: $$2\oint_C{\frac{dz}{z^{2}+4zi-1}}$$ which after plugging into the quadratic equation yields the singularities $i(\sqrt{3}-2), -i(\sqrt{3}+2)$
applying Cauchy's Integral Theorem
$$2\oint_C{\frac{dz}{z^{2}+4zi-1}} = 2\pi{i}\sum_{k_i}{\operatorname{Res}(f(z);k_i)}$$ where $k_i =$ all singularities.
My expectation is that $2\pi{i}\sum_{k_i}{\operatorname{Res}(f(z);k_i)} = \frac{2\pi}{\sqrt{3}}$
If I realize that Cauchy's is applied over $\int_{0}^{2\pi}$ but my original integral was only over $\int_{0}^{\frac{\pi}{2}}$ I also put a $\frac{1}{4}$ conversion factor on the integral to change the bounds, which would yield $\frac{\pi}{2\sqrt{3}}$.
This is what I assumed the answer to be from what I understand about this process. However it seems the true result: $$\int_{0}^{\frac{\pi}{2}} \frac{1}{2+\sin(\theta)} = \frac{\pi}{3\sqrt{3}}$$
obviously $\frac{\pi}{2\sqrt{3}}$ and $\frac{\pi}{3\sqrt{3}}$ are different by a factor of $\frac{2}{3}$.
I then solved the problem also using the form $$\oint_C{\frac{f(z)dz}{(z-z_0)^{n+1}}} = \frac{2\pi{i}}{n!}\cdot f^{(n)}(z_0)$$
to check my result, however this also resulted in the same thing I got the other way, i.e. the wrong answer. After testing everything I have not been able to figure out what it could be unless when converting the integrals from $\int_{0}^{\frac{\pi}{2}}$ to a contour over $\oint_C$. You can't actually just adjust the range as I did. And I should be getting a factor of $\frac16$ instead of $\frac14$. But I can't figure out why. Please help. Thank you in advance!
The expected symmetry does not hold for the function $\displaystyle f(\theta)=\frac{1}{2+\sin \theta}.$
The integral can be evaluated by computing the contour integral over the quarter circle.
$$\int_0^{\pi/2} \frac{d\theta}{2+\sin \theta}=2\int_1^{e^{i\pi/2}} \frac{dz}{z^2+4iz-1}$$ $$\phantom{\int_0^{\pi/2} \frac{d\theta}{2+\sin \theta}}=\frac{2}{z_1-z_2} \left(\int_1^{e^{i\pi/2}} \frac{dz}{z-z_1} - \int_1^{e^{i\pi/2}}\frac{dz}{z-z_2} \right),$$ where $z_1=i(\sqrt{3}-2)$ and $z_2 = -i(\sqrt{3}+2)$ are the poles of the integrand. $$\displaystyle \int_0^{ \pi/2} \frac{d\theta}{2+\sin \theta}=\frac{2}{z_1-z_2}\left[ \log(z-z_1) - \log (z-z_2) \right]_1^{e^{i\pi/2}}$$ $$= \frac{1}{i\sqrt{3}}\log \left[\frac{(3-\sqrt{3})}{(3+\sqrt{3})} \frac{(1+i(\sqrt{3}+2))}{(1-i(\sqrt{3}-2))}\right]$$ $$= \frac{1}{i\sqrt{3}} \log \left(\frac{1+i\sqrt{3}}{2} \right)= \frac{1}{i\sqrt{3}} \log e^{i\pi/3}$$ $$= \frac{\pi}{3\sqrt{3}}.$$
$\underline{\text{Reference:}}$ Carrier, Krook, and Pearson, Functions of a Complex Variable, Ch. 3, pp. 86,87.