Compute $\int^{2 \pi} _0 \frac{1}{a + \sin \theta} d\theta$ I want to compute $\displaystyle \int^{2 \pi} _0 \frac{1}{a + \sin \theta} d\theta$, with $a > 0$, where we may use the Cauchy Integral Formula.
The following hint is given: 
Write $sin \theta = (e^{i \theta} - e^{-i \theta})/ 2i$ and interpretate the integral after some manipulation as a complex line integral of a rational function over the unit circle with counterclockwise direction.
What I got so far:
$\displaystyle \int^{2 \pi} _0 \frac{1}{a + \sin \theta} d\theta = \int^{2 \pi} _0 \frac{1}{a + \frac{e^{i \theta} - e^{-i \theta}}{2i}} d\theta = \int^{2 \pi} _0 \frac{1}{\frac{2ia + e^{i \theta} - e^{-i \theta}}{2i}} d\theta = \int^{2 \pi} _0 \frac{2i}{2ia + e^{i \theta} - e^{-i \theta}} d\theta = \int^{2 \pi} _0 \frac{-2}{-2a + i\cdot (e^{i \theta} - e^{-i \theta})} d\theta$
Here I get stuck. It does not look like a complex line integral, where the Cauchy Integral Formula can be used.
 A: We can convert to an integral over the unit circle
$$
\begin{align}
\int_0^{2\pi}\frac{\mathrm{d}\theta}{a+\sin(\theta)}
&=\int_0^{2\pi}\frac{2i\,\mathrm{d}\theta}{2ia+e^{i\theta}-e^{-i\theta}}\\
&=\int_0^{2\pi}\frac{2\,\mathrm{d}e^{i\theta}}{e^{2i\theta}+2iae^{i\theta}-1}\\
&=\oint\frac{2\,\mathrm{d}z}{z^2+2iaz-1}\\
&=\oint\frac{2\,\mathrm{d}z}{(z+ia)^2-(1-a^2)}\\
&=\frac1{\sqrt{1-a^2}}\oint\left(\frac1{z+ia-\sqrt{1-a^2}}-\frac1{z+ia+\sqrt{1-a^2}}\right)\mathrm{d}z\\
\end{align}
$$
If $|a|\lt1$, then $-ia+\sqrt{1-a^2}$ and $-ia-\sqrt{1-a^2}$ are both on the unit circle, thus the integral is not absolutely convergent. Therefore, this needs to be handled as a Cauchy Principal Value Integral. The Cauchy Principal Value ends up counting half of each singularity on the path of integration.  The residues are $\frac{\pm1}{\sqrt{1-a^2}}$ so they cancel each other.
If $|a|\gt1$, then the roots are $-i(a+\sqrt{a^2-1})$ and $-i(a-\sqrt{a^2-1})$. Their product is $-1$, so one must be inside the unit circle and the other is outside.
The residue at the singularities is $\frac{\pm i}{\sqrt{a^2-1}}$. Considering the original integral has the same sign as $a$, we have
$$
\bbox[5px,border:2px solid #C0A000]{
\int_0^{2\pi}\frac{\mathrm{d}\theta}{a+\sin(\theta)}=\left\{\begin{array}{}
\frac{2\pi\,\mathrm{sgn(a)}}{\sqrt{a^2-1}}&\text{if }|a|\gt1\\
0&\text{if }|a|\lt1
\end{array}\right.
}
$$

Note also that since the integrals are of the form
$$
\frac1{\sqrt{1-a^2}}\oint\frac{\mathrm{d}z}{z-(-ia\pm\sqrt{1-a^2})}
$$
They can also be evaluated using $f(z)=1$ in Cauchy's Integral Formula, arriving at the same answer.
A: Note that for $z=e^{it}$, $\frac{z-z^{-1}}{2i}=\sin t$. Hence you're integrating $$\frac{1}{a+\dfrac{z-z^{-1}}{2i}}\frac 1{iz}=\frac{2}{z^2+2iaz-1}$$ over the unit circle. Using residues, this is easy.
In general, if $R(x,y)$ is a rational function finite on the unit circle, you can evaluate $$\int_0^{2\pi}R(\cos t,\sin t)dt=\int_{|z|=1}R\left(\frac{z+z^{-1}}2,\frac{z-z^{-1}}{2i}\right)\frac{dz}{zi}$$ 
