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.
 A: 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$. 
A: By symmetry we have
$$ \int_{0}^{\pi}\frac{d\theta}{4+\sin^2\theta} = 2\int_{0}^{\pi/2}\frac{d\theta}{4+\cos^2\theta} $$
and by setting $\theta=\arctan t$ in the last integral we get
$$ 2\int_{0}^{+\infty}\frac{dt}{4(1+t^2)+1} = \color{red}{\frac{\pi}{2\sqrt{5}}}$$
with the residue theorem applied to $\int_{\mathbb{R}}\frac{dt}{4t^2+5}$.
