Use tools from complex analysis to show $\int_0^{2\pi} \frac{d\theta}{A + B \sin \theta} = \frac{2\pi}{\sqrt{A^2 - B^2}}$ Assume $A^2 > B^2$ and that $A > 0$. Show that:
$$\int_0^{2\pi} \frac{d\theta}{A + B \sin \theta} = \frac{2\pi}{\sqrt{A^2 - B^2}}$$
This problem appears in the context of complex analysis. That implies the use of things such as contour integration. I have not seen a problem of this nature before so I'm not sure where to start.
 A: Hint. Let $z=e^{i\theta}$ then $dz=iz d\theta$ and
$$I:=\int_0^{2\pi} \frac{d\theta}{A + B \sin \theta}=
\int_{|z|=1} \frac{\frac{dz}{iz}}{A + B\, \frac{z-1/z}{2i}}=
\int_{|z|=1} \frac{2dz}{Bz^2+2Aiz-B}.$$
Now note that if $A>|B|>0$, then the polynomial $Bz^2+2Aiz-B$ has just one root $z_1$ inside the circle $|z|=1$ (the other one is outside). Hence, by the Residue Theorem, 
$$I:=2\pi i \, \mbox{Res}\left(\frac{2}{Bz^2+2Aiz-B},z_1\right).$$
Can you take it from here?
A: Let $I$ denote the integral. By the substitution $\theta \mapsto \frac{\pi}{2} - 2\phi$ and the periodicity, we have
\begin{align*}
I
 = \frac{1}{2} \int_{0}^{4\pi} \frac{d\theta}{A+B\sin\theta}
&= \int_{0}^{2\pi} \frac{d\phi}{A + B\cos 2\phi} \\
&= \int_{0}^{2\pi} \frac{d\phi}{(A+B)\cos^2\phi + (A - B)\sin^2\phi},
\end{align*}
where the last equality follows by plugging trigonometric identities $A = A(\sin^2\phi + \cos^2\phi)$ and $B\cos 2\phi = B(\cos^2\phi - \sin^2\phi)$.
Now consider the elliptical path $\gamma(\phi) = \sqrt{A+B}\cos\phi + i\sqrt{A-B}\sin\phi$. Along this curve $\gamma$, the imaginary part of the complex differential $dz/z$ simplifies to
$$ \operatorname{Im}\left(\frac{dz}{z}\right)
= \frac{\operatorname{Im}(\bar{z}\, dz)}{|z|^2}
= \frac{\sqrt{A^2-B^2} \, d\phi}{(A+B)\cos^2\phi + (A-B)\sin^2\phi}. $$
Therefore by the Cauchy's integration formula, we have
$$ I
= \frac{1}{\sqrt{A^2 - B^2}} \operatorname{Im} \left( \int_{\gamma} \frac{dz}{z} \right)
= \frac{2\pi}{\sqrt{A^2 - B^2}}. $$
A: The problem is easily solved by trigonometric substitution and does not really require the powerful methods of complex analysis. I will present here an approach which does it using basic calculus.

First we split the integral into into integrals over intervals $[0,\pi]$ and $[\pi, 2\pi]$ and then in the second integral we put $t= \theta - \pi$ and then we get $$I=\int_{0}^{\pi}\left(\frac{1}{A+B\sin t} +\frac{1} {A-B\sin t}\right) \, dt=4A\int_{0}^{\pi/2}\frac{dt}{A^{2}-B^{2}\sin^{2}t}$$ and then we can use $2\sin^{2}t=1-\cos 2t$ to get $$I=8A\int_{0}^{\pi/2}\frac{dt}{2A^{2}-B^{2}+B^{2}\cos 2t}=4A\int_{0}^{\pi}\frac{dz}{2A^{2}-B^{2}+B^{2}\cos z} $$ The integral on right is pretty standard and can be evaluated by formula $$\int_{0}^{\pi}\frac{dx}{a+b\cos x} =\frac{\pi} {\sqrt{a^{2}-b^{2}}}$$ (the above can be proved by using the substitution $(a+b\cos x) (a-b\cos y) =a^{2}-b^{2}$) and thus $$I=\frac{4\pi A} {\sqrt{(2A^{2}-B^{2})^{2}-B^{4}}}=\frac{2\pi}{\sqrt{A^{2}-B^{2}}}$$
