<s>[INST] How to integrate $f( \theta ) = \frac{1}{a + \sin( \theta ) }$? Let $a > 1$. I am wondering how evaluate the integral: $$ \int_{0}^{2 \pi } \frac{1}{a + \sin( \theta) } d \theta $$ by means of methods of complex analysis. In the homework assignment, the following hint is given: write $\sin( \theta ) = (e^{i \theta } - e^{- i \theta} ) / 2i $ and interpret the integral (after some algebraic manipulations) as a complex line integral of a rational function over the positively oriented unit circle. 
I write $\theta := t$, so I'll have to type less. 
This is how I approached the question: We know, from the definition of the complex line integral, that $$ \int_{ \alpha } f(t) dt = \int_{a}^{b} f( \alpha (t) ) \alpha ' (t) .$$
In our case, we have $\alpha(t) = e^{i t}$. So, if we want to rewrite our "ordinary" integral as a complex line integral, we have the equation $$ f( \alpha (t) ) \cdot e^{i t} = \frac{1}{a + \frac{ e^{i t} - 1/e^{i t} }{2i} } $$. If we divide both sides by $e^{i t}$, and rewrite the denominator of the resulting fraction a bit, we obtain: $$f( \alpha (t)) = \frac{2i}{e^{2 i t} + 2 i a e^{i t} -1 } . $$ Since we already noted, that $ \alpha(t) = e^{i t} $, I thought that, based on this, we can deduce that $$f(t) = \frac{2i}{t^2 + 2 i a t - 1} $$. 
From here, I'm not entirely sure how to proceed. One possibility is to find the roots of the polynomial in the denominator of the fraction in the integral, by means of the (abc)-rule. We obtain the roots $t_1 =i a - \sqrt{1 -a} $ and $t_2 = i a + \sqrt{ 1 - a }$. We know, that $a >1 $, so we can rewrite these roots: $t_1 = i a - i \sqrt{a-1} = i(a - \sqrt{a-1} $ , and $t_2 = i a + i \sqrt{a-1} = i (a + \sqrt{a-1} ) $, so we can rewrite our integral as follows: $$ \int_{ \alpha } \frac{1}{ (t - t_1) (t-t_2) } $$ . But how do we proceed from here? We don't know the value of $a$, so we don't know how "big" the roots are. Could we use the Cauchy Integral Formula? Or something else? How do we use that we integrate over a positively orientated unit circle? 
 [/INST] As you did, let $z=e^{i\theta}$. Then $dz=izd\theta$ and
$$ \sin\theta=\frac{1}{2i}\left(z-\frac{1}{z}\right) $$
and hence
\begin{eqnarray*}
\int_0^{2\pi}\frac{1}{a+\sin\theta}d\theta&=&\int_{|z|=1}\frac{1}{a+\frac{1}{2i}\left(z-\frac{1}{z}\right)}\frac{dz}{iz}\\
&=&2\int_{|z|=1}\frac{1}{z^2+2aiz-1}dz\\
&=&2\int_{|z|=1}\frac{1}{(z+ai)^2+a^2-1}dz\\
&=&2\int_{|z|=1}\frac{1}{(z+ai+\sqrt{a^2-1}i)(z+ai-\sqrt{a^2-1}i)}dz\\
&=&2\cdot 2\pi i\text{Res}\left(\frac{1}{(z+ai+\sqrt{a^2-1}i)},z=-ai+\sqrt{a^2-1}i)\right)\\
&=&4\pi i\frac{1}{2\sqrt{a^2-1}i}\\
&=&\frac{2\pi}{\sqrt{a^2-1}}.
\end{eqnarray*}
Another simple way is to use trigonometric transforms instead of complex analysis. Let $t=\tan\frac{\theta}{2}$ and then $\sin\theta=\frac{2t}{t^2+1}$ and $d\theta=\frac{2}{t^2+1}dt$. Thus
\begin{eqnarray*}
\int_0^{2\pi}\frac{1}{a+\sin\theta}d\theta&=&\int_{-\infty}^\infty\frac{1}{a+\frac{2t}{t^2+1}}\frac{2}{t^2+1}dt\\
&=&2\int_{-\infty}^\infty\frac{1}{a(t^2+1)+2t}dt\\
&=&\frac{2}{a}\int_{-\infty}^\infty\frac{1}{(t+\frac{1}{a})^2+1-\frac{1}{a^2}}dt\\
&=&\frac{2}{a}\frac{1}{\sqrt{1-\frac{1}{a^2}}}\left.\arctan\frac{t+\frac{1}{a}}{\sqrt{1-\frac{1}{a^2}}}\right|_{-\infty}^\infty\\
&=&\frac{2\pi}{\sqrt{a^2-1}}.
\end{eqnarray*}
</s>