Computing $\int_0^\pi (4 + \sin^2 \theta)^{-1} d\theta$ with the residue theorem It's asked to find the value of the real integral
$$
I = \int\limits_0^{\pi}\frac{\rm{d}\theta}{4+\sin^2{\theta}}
$$
I don't understand how to apply the theorem, basically because I cannot parametrise $z = e^{i\theta}$ as I'm not on a circumference.

Note that $\sin^2(\theta)$ is an even function.  Hence, we assert that
$$\int_0^\pi \frac{1}{4+\sin^2(\theta)}\,d\theta=\frac12\int_{-\pi}^\pi \frac{1}{4+\sin^2(\theta)}\,d\theta \tag 1$$
And now one can proceed with the substitution $z=e^{i\theta}$ in $(1)$ such that
$$\int_0^\pi \frac{1}{4+\sin^2(\theta)}\,d\theta=\frac12\oint_{|z|=1}\frac{1}{4+\left(\frac{z-z^{-1}}{2i}\right)^2}\,\frac{1}{iz}\,dz\tag 2$$
We can make things a bit easier by noting that 
$$\begin{align}
\int_{0}^\pi \frac{1}{4+\sin^2(\theta)}\,d\theta&=\int_{0}^{\pi} \frac{2}{9-\cos(2\theta)}\,d\theta\\\\
&=\int_0^{2\pi}\frac{1}{9-\cos(\theta)}\,d\theta\\\\
&=\oint_{|z|=1}\frac{1}{9-\left(\frac{z+z^{-1}}{2}\right)}\,\frac{1}{iz}\,dz\tag 3\\\\
&=\oint_{|z|=1}\frac{2i}{z^2-18z+1}\,dz\\\\
&=\oint_{|z|=1}\frac{2i}{(z-9-4\sqrt{5})(z-9+4\sqrt{5})}\,dz\\\\
&=2\pi i \text{Res}\left(\frac{2i}{(z-9-4\sqrt{5})(z-9+4\sqrt{5})}, z=9-8\sqrt{5}\right)\\\\
&=\frac{\pi}{2\sqrt 5}
\end{align}$$
The integrand of $(3)$ is of simpler form than that of $(2)$ and facilitates evaluating the residue from the pole inside $|z|=1$. 
