Evaluate the integral $\int_0^{\frac{\pi}{2}} \frac{1}{a + \sin^2 \theta}$ using the residue theorem Can someone show me how to compute this integral using the residue theorem: 
$$\int_0^{\frac{\pi}{2}} \frac{1}{a + \sin^2 \theta}d\theta$$
 A: Hint:
First, as Winther said, let $u=4\theta$, then let $z=e^{iu},$  $dz=i e^{iu}d\theta=i zd\theta$.
We know that: $$\sin( u)=\frac 1 {2i} (z-\frac 1 z)$$
Now to get rid of that pesky $\sin(4u)$:
$$\sin(4 u)=\frac 1 {2i} (z^4-\frac 1 {z^4})$$
simplifying we get:
$$\sin(4u)=\frac{-i(z^8-1)}{2z^4}$$
So your integral finally becomes:
$$\frac 1 4\int\dfrac{1}{a+\left( \frac{-i(z^8-1)}{2z^4} \right)^2}\frac{dz}{iz}$$
From here on out, applying the residue theorem should be straightforward.
A: We can simplify the problem by (i) exploiting the even symmetry of the integrand, (ii) using the identity 
$$\sin^2 \theta =\frac{1-\cos 2\theta}{2}$$
and (iii) enforcing the substitution $2\theta \to \theta$.  We can write then write the integral of interest $I(a)$ as
$$I(a)=\frac12 \int_0^{2\pi}\frac{1}{(2a+1)-\cos \theta}d\theta \tag 1$$
Then, we move to the complex plane and letting $z=e^{i\theta}$ find that 
$$I(a) = i\oint_{|z|=1} \frac{1}{z^2-2(2a+1)z+1}dz$$
For $a>0$ ($a<-1$), the only pole enclosed in the unit circle is at
$$z=(2a+1)-2\sqrt{a(a+1)}\,\,\,\,\left(z=(2a+1)+2\sqrt{a(a+1)}\right)$$
Therefore the residue of $\frac{1}{z^2-2(2a+1)z+1}$ is for $a>1$
$$\begin{align}
\lim_{z\to (2a+1)-2\sqrt{a(a+1)}}\left(\frac{z-(2a+1)+2\sqrt{a(a+1)}}{z^2-2(2a+1)z+1}\right)=\frac{1}{-4\sqrt{a(a+1)}}
\end{align}$$
and for $a<-1$
$$\begin{align}
\lim_{z\to (2a+1)+2\sqrt{a(a+1)}}\left(\frac{z-(2a+1)-2\sqrt{a(a+1)}}{z^2-2(2a+1)z+1}\right)=\frac{1}{4\sqrt{a(a+1)}}
\end{align}$$
Putting it all together yields for $a>0$ or $a<-1$
$$\bbox[5px,border:2px solid #C0A000]{I(a)=(2\pi i) i\,\text{sgn(a)}\,\frac{1}{-4\sqrt{a(a+1)}}=\text{sgn}(a)\,\frac{\pi}{2\sqrt{a(a+1)}}}$$
NOTE:
For $-1\le a\le 0$, the integral of interest is divergent.
A: Notice, 
$$\int_0^{\frac{\pi}{2}} \frac{1}{a + \sin^2 \theta}d\theta$$
$$=\int_0^{\frac{\pi}{2}} \frac{\sec^2\theta}{a\sec^2\theta + \sec^2\theta\sin^2 \theta}d\theta$$
$$=\int_0^{\frac{\pi}{2}} \frac{\sec^2\theta}{a+a\tan^2\theta + \tan^2 \theta}d\theta$$
$$=\int_0^{\frac{\pi}{2}} \frac{\sec^2\theta}{a+(a+1)\tan^2\theta}d\theta$$
Let, $\tan \theta=t\implies \sec^2\theta d \theta=dt$
$$=\frac{1}{a+1}\int_{0}^{\infty}\frac{dt}{\frac{a}{a+1}+t^2}$$
$$=\frac{1}{a+1}\sqrt{\frac{a+1}{a}}\left[\tan^{-1}\left(t\sqrt{\frac{a+1}{a}}\right)\right]_{0}^{\infty}$$ $$=\frac{1}{\sqrt{a(a+1)}}\left(\frac{\pi}{2}-0\right)$$
$$=\frac{\pi}{2\sqrt{a(a+1)}}$$ Hence, we have
$$\bbox[5px, border:2px solid #C0A000]{\color{red}{\int_0^{\frac{\pi}{2}} \frac{d\theta}{a + \sin^2 \theta}=\frac{\pi}{2\sqrt{a(a+1)}}}}$$
