Calculate the integral with residue theorem Calculate with residue theorem: $\int_0^{\pi/2} \frac{1}{a+\sin^2(z)} dz$
I tried to use a contour as follow (without the blue circle) :
http://i.stack.imgur.com/P48XL.png
but it didn't work well. Any ideas?
 A: First, as the integrand $f(z)=\frac{1}{a+\sin^2 z}$ is even we have
$$I:=\int_0^{\pi/2}\frac{1}{a+\sin^2z}dz=\frac{1}{2} \int_{-\pi/2}^{\pi/2} \frac{1}{a+\sin^2 z}dz.$$
Second, observe that $f(z+\pi)=f(z)$ as well, so 
$$I=\frac{1}{4} \int_{-\pi/2}^{-3 \pi/2} \frac{1}{a+\sin^2 z}dz. $$
Now write $\zeta=e^{iz}$; as $z$ traces the interval $[-\pi/2,3\pi/2]$, $\zeta$ traces the unit circle in the complex plane CCW. Also $$\sin^2 z=\left(\frac{e^{i z}-e^{-iz}}{2i} \right)^2=\left(\frac{\zeta-1/\zeta}{2i} \right)^2,$$
and $d \zeta=i e^{iz} dz=i \zeta dz$. Overall, we find that
$$I=\frac{1}{4}\oint_{|\zeta|=1} \frac{1}{a+\frac{\zeta^2-2+1/\zeta^2}{-4}} \frac{d \zeta}{i \zeta} =\frac{1}{i} \oint_{|\zeta|=1} \frac{\zeta}{4a \zeta^2-\zeta^4+2\zeta^2-1} d\zeta.$$
The denominator here is a biquadratic function, which helps you find the poles.
A: $I=\int_0^{\pi/2} \frac{1}{a+\sin^2(x)} dx=\int_0^{\pi/2} \frac{2}{2a+1-\cos(2x)} dx= \int_0^{\pi} \frac{1}{2a+1-\cos(X)} dX$
Let: $z=e^{iX}$ then $dz=iz \:dX$   and with $\cos(X)=\frac{1}{2}\left( e^{iX}+e^{-iX}\right)=\frac{1}{2}(z+z^{-1})$
$$I=\int \frac{1}{2a+1-\frac{1}{2}(z+z^{-1})}\frac{1}{iz} dz = 2i\int \frac{1}{z^2-(4a+2)z+1} dz $$
The roots of $z^2-(4a+2)z+1=0$ are $2a+1\pm 2\sqrt{a(a+1)}$
if $a>0$ there are two real poles
if $a=0$ there is one pole $z=1$
if $-1< a < 0$ there are two complex poles.
if $a=-1$ there is one pole $z=-1$
if $a<-1$ there are two real poles
So, depending of the case, one have to chose a different contour.
With this hit, I suppose that you can continue.
A: A similar approach to JJaquelin.
Note that by symmetry we have
$$ I = \int_0^{\pi/2}\frac{1}{a+\sin^2(x)}dx  = \int_{-\pi/2}^0 \frac{1}{a+\sin^2(x)}dx = \frac{1}{2}\int_{-\pi/2}^{\pi/2}\frac{1}{a+\sin^2(x)}dx.$$
It follows (using double angle formula) that
$$ I = \int_{-\pi}^\pi\frac{1}{4a+2 - 2cos(\theta)}d\theta$$
We're going to think about this as a contour integral around the boundary of the unit disk, $\partial D$. We let $z= r\exp i\theta$, and hence $dz = i z d\theta $. We can note $2\cos \theta = z + z^{-1}$ on the boundary of the unit disk $\partial D$.
Hence we have
$$ 
I = i\int_{\partial D} \frac{1}{z^2 - (4a + 2)z + 1}dz$$
Since the denominator is a quadratic we have
$$
I = i\int_{\partial D} \frac{1}{(z-z_0)(z-z_1)}dz$$
Where $z_0,z_1$ are the roots of the quadratic found in JJaquelins answer.
We're going to exclude the cases where $a=0$ and $a=-1$. In both of these cases, one of the zeros $z_0,z_1$ is located on $\partial D$ and the integral doesn't even converge in principal value. We must also exclude the case where $a = -1/2$, as this gives solutions at $z_0 = i$ and $z_1 = \bar{z}_0$.
For all other values of $a$, we can use the residue theorem to work the value of $I$. 
I will leave it to you to finish the problem.  Consider splitting the zeros into two cases; two real solutions, and a pair of conjugate solutions. Find out when there are no, one or two poles inside the unit disk, and then evaluate the residues.
