Computing $\int_0^{\pi\over2} \frac{dx}{1+\sin^2(x)}$? How would you compute$$\int_0^{\pi\over2} \frac{dx}{1+\sin^2(x)}\, \, ?$$

$$\int_0^{\frac \pi 2} \frac{1}{1 + \sin^2x}dx = \int_0^{\frac \pi 2} \frac{2}{3 - \cos 2x} dx = \int_0^\pi \frac{d\theta}{3 - \cos \theta } = \frac 12\int_0^{2\pi}\frac{d\theta}{3 - \cos \theta}$$
To evaluate $\displaystyle \int_0^{2\pi}\frac{1}{3 - \cos \theta}d\theta$ let $\displaystyle z = e^{i\theta} \implies \cos \theta = \frac{z^2 + 1}{2z}, d\theta = \frac{1}{iz}dz$
$$\int_0^{2\pi}\frac{1}{3 - \cos \theta}d\theta = \frac 2{i}\oint_{|z| = 1} \frac{1}{-z^2 + 6z - 1}dz $$
The poles are $3 - 2 \sqrt 2$ and $3  + 2 \sqrt 2$, and since $3 + 2 \sqrt 2  > 1$,
$$\frac 2{i}\oint_{|z| = 1} \frac{1 }{-z^2 + 6z - 1}dz = 4\pi \text{Res}\left[ \frac{1}{-z^2 + 6z - 1} , 3 - 2 \sqrt 2\right] = \frac{\pi}{\sqrt 2} $$
So $\displaystyle \int_0^{\frac \pi 2} \frac{1}{1 + \sin^2x}dx = \frac{\pi }{2 \sqrt 2}$
