Evaluating trigonometric integral and Cauchy's Theorem I am trying to evaluate the following integral: $\int_0 ^\pi {d\theta\over{1+\sin^2\theta}}$
I tried using the substitution of $\sin\theta={1\over 2i}(z-1/z)$, where $z=e^{i\theta}$, and $d\theta={1\over iz} dz$, and got to $1+\sin^2\theta= 1/4 (4iz-iz^3+2iz-i/z)$. 
I would put this back in the original integral, but I do not know how I should manipulate this. I plan to use Cauchy's Formula in the end.   Please help me out. 
 A: As you began correctly we let $z=e^{i\theta}$ and our aim is to be able to integrate over some closed contour and then be able to use the Cauchy Residue Theorem. If $\theta$ ranges over $[0,2\pi]$ then we see that $z$ traces the unit circle, which we denote $\gamma$. 
As you said, $\sin\theta= {(z + z^{-1})\over2i}$, which gives us $ \sin^2\theta = {1\over4}(-z^2 + 6 - {1\over{z^2}})$ and $d\theta = {1\over{iz}}dz$.  Putting this in the integral we get:
$$\int_0 ^\pi {d\theta\over{1+\sin^2\theta}} = \int_{\gamma^+}{4z^2\over-z^2+6-z^{-2}}{dz\over iz}$$ $$=\int_{\gamma^+}{4iz\over z^4-6z^2+1}dz$$
We note that this integral is only over the upper semicircle which we have denoted  $\gamma^+$, but with another substitution we can fix that. We now let $t=z^2$ and note that this means that we are now integrating over the whole unit disc, hence our integral changes to: $$\int_\gamma {2i\over t^2 -6t +1}dt$$
This is an integral over a simple closed curve and so we can use Cauchy's Residue Theorem. The poles of the function are at $t=3\pm2\sqrt{2}$, however we notice that only the smaller pole is inside $\gamma$ and so we need only work out the residue for that pole. It is a simple pole and easy to work out that the residue is $-1\over 4\sqrt{2}$. We now apply CRT to get that: $$\int_\gamma {2i\over t^2 -6t +1}dt = 2i\cdot2\pi i\cdot {-1\over 4\sqrt{2}} = {\pi\over \sqrt{2}} $$ 
