<s>[INST] Definite integral of $\int_0^\pi \frac{d\theta}{a+\sin^2 \theta} \quad (a>0)$ Definite integral of $$\int_0^\pi \frac{d\theta}{a+\sin^2 \theta} \quad (a>0)$$
I was attempting to do a trig substitution but that did not work out for me I believe because of the $a$. Looking at this to begin with I thought it was going to go smoothly but I keep getting stuck.
 [/INST] Let's find
$$
\int_0^{2\pi} \frac{1}{a+\sin^2\theta}d\theta
$$
instead. Let $z=e^{i\theta}$, then $dz=ie^{i\theta}d\theta=izd\theta$, so
\begin{align}
\int_0^{2\pi} \frac{1}{a+\sin^2\theta}d\theta &=\int_0^{2\pi} \frac{1}{a+\left(\frac{e^{i\theta}-e^{-i\theta}}{2i}\right)^2}d\theta\\
&=\int_C \frac{1}{a+\left(\frac{z-\frac{1}{z}}{2i}\right)^2}\frac{dz}{iz}\\
&=\int_C \frac{-4z}{i(z^4-(4a+2)z^2+1)}dz,
\end{align}
where $C$ is a unit circle.
$f(z)=\dfrac{-4z}{i(z^4-(4a+2)z^2+1)}$ has four simple poles, at
$$
z=\pm\sqrt{2a+1+\sqrt{4a^2+4a}},\pm\sqrt{2a+1-\sqrt{4a^2+4a}}
$$
Since $a>0$, $z=\pm\sqrt{2a+1+\sqrt{4a^2+4a}}$ is outside $C$, and others are inside $C$. Find $\operatorname{Res}f(\pm\sqrt{2a+1-\sqrt{4a^2+4a}})$: With routine calculations, we get
\begin{align}
\operatorname{Res}(f;\sqrt{2a+1-\sqrt{4a^2+4a}})&=\lim_{z\to\sqrt{2a+1-\sqrt{4a^2+4a}}}(z-\sqrt{2a+1-\sqrt{4a^2+4a}})f(z)\\
&=\frac{1}{i\sqrt{4a^2+4a}}
\end{align}
and
$$
\operatorname{Res}(f;-\sqrt{2a+1-\sqrt{4a^2+4a}})=\frac{1}{i\sqrt{4a^2+4a}}.
$$
Therefore,
\begin{align}
\int_C f(z)dz&=2\pi i( \operatorname{Res}(f;\sqrt{2a+1+\sqrt{4a^2+4a}})+\operatorname{Res}(f;-\sqrt{2a+1+\sqrt{4a^2+4a}}))\\
&=2\pi i\cdot \frac{2}{i\sqrt{4a^2+4a}}\\
&=\frac{2\pi}{\sqrt{a^2+a}}.
\end{align}
Since $\sin^2\theta=\sin^2(\pi+\theta)$,
$$
\int_0^{\pi} \frac{1}{a+\sin^2\theta}d\theta=\frac{1}{2}\int_0^{2\pi} \frac{1}{a+\sin^2\theta}d\theta=\frac{\pi}{\sqrt{a^2+a}}.
$$
</s>