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 &gt; 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.
We can convert to an integral over the unit circle
$$
\begin{align}
\int_0^{2\pi}\frac{\mathrm{d}\theta}{a+\sin(\theta)}
&amp;=\int_0^{2\pi}\frac{2i\,\mathrm{d}\theta}{2ia+e^{i\theta}-e^{-i\theta}}\\
&amp;=\int_0^{2\pi}\frac{2\,\mathrm{d}e^{i\theta}}{e^{2i\theta}+2iae^{i\theta}-1}\\
&amp;=\oint\frac{2\,\mathrm{d}z}{z^2+2iaz-1}\\
&amp;=\oint\frac{2\,\mathrm{d}z}{(z+ia)^2-(1-a^2)}\\
&amp;=\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 either both inside the unit circle or both outside. In this case the integral is $0$. (If both are outside, then there are no singularities inside the contour. If both are inside, we know the sum of the residues is $0$ since the integral over an arbitrarily large circle vanishes.)

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}}&amp;\text{if }|a|\gt1\\
0&amp;\text{if }|a|\lt1
\end{array}\right.
}
$$
Of course, when $|a|\le1$, the denominator of the integrand vanishes. The Cauchy Principal Value of the integral is $0$.



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