How do I evaluate this integral using cauchy's residue theorem. $$\int_0^{2\pi} \dfrac{\cos 2 \theta}{1+\sin^2 \theta}d\theta$$
$$=\dfrac{-2}{i}\oint_{|z|=1} \dfrac{z^4+1}{z(z^4-4z^2-2z+1)}dz $$
I am stuck on how to use Cauchy's residue theorem since the bottom does not factor nicely. I know $z=-1$, $z=0.3111$ and $z=0$ lie within the contour but not sure where to go from here.

By symmetry, our integral is just:
$$ \color{red}{I}=4\int_{0}^{\pi/2}\frac{\cos(2\theta)}{1+\sin^2\theta}\,d\theta = 4\int_{0}^{\pi/2}\frac{1-2\cos^2\varphi}{1+\cos^2\varphi}\,d\varphi \tag{1}$$
($\varphi=\frac{\pi}{2}-\theta$) and through the substitution $\varphi=\arctan t$ we get:
$$ I = 4\int_{0}^{+\infty}\frac{t^2-1}{(1+t^2)(2+t^2)}\,dt =\color{red}{\pi(3\sqrt{2}-4)}\tag{2}$$
where the last step follows from partial fraction decomposition:
$$ \frac{t^2-1}{(t^2+1)(t^2+2)} = \frac{3}{2+t^2}-\frac{2}{1+t^2}.\tag{3}$$
