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.
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}$$