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.
 A: Through the substitution $\theta=\arctan t$:
$$\begin{eqnarray*}\int_{0}^{\pi}\frac{d\theta}{a+\sin^2\theta} &=& 2\int_{0}^{\pi/2}\frac{d\theta}{a+\sin^2\theta}\\&=&2\int_{0}^{+\infty}\frac{dt}{(1+t^2)\left(a+\frac{t^2}{1+t^2}\right)}\\&=&\frac{2}{a}\int_{0}^{+\infty}\frac{dt}{1+\left(1+\frac{1}{a}\right)t^2}\\&=&\frac{2}{a\sqrt{1+\frac{1}{a}}}\int_{0}^{+\infty}\frac{dt}{1+t^2}\\&=&\color{red}{\frac{\pi}{\sqrt{a^2+a}}}.\end{eqnarray*}$$
A: If you don't mind contour integration, let $z=e^{i\theta}$:
$$
\begin{align}
\int_0^\pi\frac{\mathrm{d}\theta}{a+\sin^2(\theta)}
&=\frac12\int_0^{2\pi}\frac{\mathrm{d}\theta}{a+\sin^2(\theta)}\tag{1}\\
&=\frac12\oint_\gamma\frac1{a-\frac14\left(z-\frac1z\right)^2}\frac{\mathrm{d}z}{iz}\tag{2}\\
&=i\oint_\gamma\frac{2z\,\mathrm{d}z}{z^4-(2+4a)z^2+1}\tag{3}\\
&=i\oint_{\tilde\gamma}\frac{\mathrm{d}z}{z^2-(2+4a)z+1}\tag{4}\\
&=2i\oint_{\gamma}\frac{\mathrm{d}z}{(z-w_-)(z-w_+)}\tag{5}\\
&=-\frac{4\pi}{w_--w_+}\tag{6}\\[3pt]
&=\frac\pi{\sqrt{a+a^2}}\tag{7}
\end{align}
$$
Explanation:
$(1)$: integrand is $\pi$ periodic
$(2)$: $z=e^{i\theta}$ and $\gamma$ is a counter-clockwise unit circle
$(3)$: algebra
$(4)$: substitute $z^2\mapsto z$ but now $\tilde\gamma$ circles the origin twice
$(5)$: $w_+=1+2a+2\sqrt{a+a^2}$ and $w_-=1+2a-2\sqrt{a+a^2}$
$\phantom{(5)\text{:}}$ are the roots of $z^2-(2+4a)z+1$
$(6)$: $w_+$ is outside the unit circle
$\phantom{(6)\text{:}}$ the residue of $\frac1{(z-w_-)(z-w_+)}$ at $z=w_-$ is $\lim\limits_{z\to w_-}\frac{z-w_-}{(z-w_-)(z-w_+)}=\frac1{w_--w_+}$
$(7)$: evaluation

Alternatively, we can use the Weierstrass substitution.
$$
\begin{align}
\int_0^\pi\frac{\mathrm{d}\theta}{a+\sin^2(\theta)}
&=\int_0^\infty\frac{\frac{2\,\mathrm{d}t}{1+t^2}}{a+\left(\frac{2t}{1+t^2}\right)^2}\tag{8}\\
&=\int_0^\infty\frac{2\left(1+t^2\right)\mathrm{d}t}{a\left(1+t^2\right)^2+4t^2}\tag{9}\\
&=\int_0^\infty\frac{2\left(1+t^2\right)\mathrm{d}t}{at^4+(4+2a)t^2+a}\tag{10}\\
&=\frac2a\int_0^\infty\frac{\left(1+t^2\right)\mathrm{d}t}{(t^2+s_+^2)(t^2+s_{\vphantom{+}-}^2)}\tag{11}\\
&=\frac1{\sqrt{a+a^2}}\int_0^\infty\left(\frac{s_+}{t^2+s_+^2}+\frac{s_-}{t^2+s_{\vphantom{+}-}^2}\right)\mathrm{d}t\tag{12}\\
&=\frac1{\sqrt{a+a^2}}\left(\frac\pi2+\frac\pi2\right)\tag{13}\\
&=\frac\pi{\sqrt{a+a^2}}\tag{14}
\end{align}
$$
Explanation:
$\phantom{1}(8)$: Weierstrass substitution
$\phantom{1}(9)$: algebra
$(10)$: more algebra
$(11)$: factor the denominator with $s_+=\sqrt{1+\frac1a}+\sqrt{\frac1a}$ and $s_-=\sqrt{1+\frac1a}-\sqrt{\frac1a}$
$(12)$: partial fractions
$(13)$: arctangent integral
$(14)$: simplify
A: Use $\sin{x} = \frac{e^{ix}-e^{-ix}}{2i}$
Then $\sin^2{x} = \frac{e^{2ix}+e^{-2ix}-2}{-4}$.
Using $e^{-2ix} = \frac{1}{e^{2ix}}$ in the integral, and substituting
$u = e^{2ix}$
will give you
$\int \frac{A}{u^2 + B \cdot u + 1} \cdot du$ with $A$ and $B$ some constants.
This integral can be transformed into an $arctan$ integral by suitable further substitutions.
A: 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}}.
$$
