I thought it's value would be zero, since the complex integrand:
$$\Im\left(\int_{C}\frac{1}{2+e^{i\theta}}d\theta\right)$$
Where $C$ is the unit disc, is nonsingular. Also $e^{iz}\ne -2$ for any $z$ by Eulers formula right? Where am I going wrong?
I thought it's value would be zero, since the complex integrand:
$$\Im\left(\int_{C}\frac{1}{2+e^{i\theta}}d\theta\right)$$
Where $C$ is the unit disc, is nonsingular. Also $e^{iz}\ne -2$ for any $z$ by Eulers formula right? Where am I going wrong?
On
Remember that when you do $z=e^{i\theta}$ you must also do $dz=i e^{i\theta}\, d\theta$.
The 'corresponding' complex integral I believe you're confused about is
$$\int_C \frac{1}{2+z} \,dz$$
which is indeed $0$ by the reasons you're stated. With $z=e^{i\theta}$ we get
$$\int_0^{2\pi}\frac{ie^{i\theta}}{2+e^{i\theta}}\, d\theta=\int_0^{2\pi}\frac{-2\sin(\theta)}{5+4\cos(\theta)}\,d\theta+ i\cdot \int_0^{2\pi}\frac{1+2\cos(\theta)}{5+4\cos(\theta)}\,d\theta$$
and you can check that each of these real integrals (the real and imaginary parts of the complex integral) is $0$.
On
Another approach, mixing real- and complex-analytique techniques.
$$I=\int_{0}^{2\pi}\frac{d\theta}{2+\sin\theta}=\int_{0}^{\pi}\left(\frac{1}{2+\sin\theta}+\frac{1}{2-\sin\theta}\right)\,d\theta=4\int_{0}^{\pi}\frac{d\theta}{4-\sin^2\theta}$$ gives: $$ I = 8\int_{0}^{\pi/2}\frac{d\theta}{4-\cos^2\theta}=8\int_{0}^{+\infty}\frac{dt}{4(t^2+1)-1}=4\int_{-\infty}^{+\infty}\frac{dt}{4t^2+3}\,dt $$ and by applying the residue theorem: $$ I = 8\pi i\cdot\text{Res}\left(\frac{1}{4t^2+3},t=i\frac{\sqrt{3}}{2}\right)=\frac{8\pi i}{8\cdot i\frac{\sqrt{3}}{2}}=\color{red}{\frac{2\pi}{\sqrt{3}}}.$$
In short, it does not equal to the imaginary part of that complex integral in your question at all: $$ \int_{0}^{2\pi}\frac{1}{2+\sin\theta}\ d\theta\neq \Im\left(\int_0^{2\pi}\frac{1}{2+e^{i\theta}}\ d\theta\right). $$ Also, the notation $$ \Im\left(\int_{C}\frac{1}{2+e^{i\theta}}\ d\theta\right) $$ doesn't makes sense.
The substitution you want to make is $$ \sin t=\frac{z-1/z}{2i} $$ where $z=e^{it}$.
In general, we have $$ \int_0^{2\pi}\frac{dt}{a+b\sin t}=\frac{2\pi}{\sqrt{a^2-b^2}},\quad a>b>0. $$