<s>[INST] 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.
 [/INST] 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}}. $$
</s>