How to evaluate $\int_0^{2\pi} \frac{\sin^2\theta}{1+\cos^2\theta}\,d\theta$ using residues? I have the following integral and I want to evaluate it using residues
$$I=\int_0^{2\pi} \frac{\sin^2\theta}{1+\cos^2\theta}d\theta$$
By using the transformation $\frac{1}{z}=e^{-i\theta}$, I got to show that 
$$I=i\int_C\frac{z^4-2z^2+1}{z(z^4+6z^2+1)}dz$$
where $C$ is the centered unit circle.
I'm trying to use Cauchy's Residue Theorem, as we have 3 poles inside C: $z=0$, $z=i\sqrt{3-2\sqrt{2}}$ and $z=-i\sqrt{3-2\sqrt{2}}$. However, I'm really struggling to compute the residues of $z=i\sqrt{3-2\sqrt{2}}$ and $z=-i\sqrt{3-2\sqrt{2}}$ by hand. 
Any tips or help to compute them?
 A: Note that $\sqrt{3-2\sqrt2}=\sqrt2-1$. So, since $\pm i\left(\sqrt2-1\right)$ is a simple root of $z(z^4+6z^2+1)$, you have\begin{align}\operatorname{res}_{z=\pm i\left(\sqrt2-1\right)}\frac{z^4-2z^2+1}{z(z^4+6z^2+1)}&=\operatorname{res}_{z=\pm i\left(\sqrt2-1\right)}\frac{z^4-2z^2+1}{z^5+6z^3+z}\\&=\left.\frac{z^4-2z^2+1}{5z^4+18z^2+1}\right|_{z=\pm i\left(\sqrt 2-1\right)}\\&=\frac{3-2\sqrt2}{4-3\sqrt2}.\end{align}Besides,$$\operatorname{res}_{z=0}\frac{z^4-2z^2+1}{z(z^4+6z^2+1)}=\left.\frac{z^4-2z^2+1}{5z^4+18z^2+1}\right|_{z=0}=1.$$
So, you want to compute $\int_0^{2\pi}R(\cos\theta,\sin\theta)\,\mathrm d\theta$, with $R(x,y)=\frac{y^2}{1+x^2}$. But then you define$$f(z)=\frac1zR\left(\frac{z-1/z}2,\frac{z-1/z}{2i}\right)=-\frac{z^4-2z^2+1}{z(z^4+6z^2+1)}$$and then\begin{align}\int_0^{2\pi}\frac{\sin^2\theta}{1+\cos^2\theta}\,\mathrm d\theta&=\int_0^{2\pi}R(\cos\theta,\sin\theta)\,\mathrm d\theta\\&=\frac1i\int_0^{2\pi}e^{-i\theta}R\left(\frac{e^{i\theta}+e^{-i\theta}}2,\frac{e^{i\theta}-e^{-i\theta}}{2i}\right)ie^{i\theta}\,\mathrm d\theta\\&=\frac1i\int_C-\frac{z^4-2z^2+1}{z(z^4+6z^2+1)}\,\mathrm dz\\&=-2\pi\sum_{z_0\in\left\{0,\pm i\left(\sqrt2-1\right)\right\}}\operatorname{res}_{z=z_0}\frac{z^4-2z^2+1}{z(z^4+6z^2+1)}\\&=-2\pi\left(1+2\frac{3-2\sqrt2}{4-3\sqrt2}\right)\\&=2\pi\left(\sqrt2-1\right).\end{align}
A: I guess, it may be a good idea to do few transformations before moving to complex plane.
First, you might note that
$$
I
= \int_0^{2\pi}\frac{\sin^2(\theta) d\theta}{1 + \cos^2(\theta)}
= \frac{1}{2}\int_0^{2\pi}\frac{1 - \cos(2\theta)}{3 + \cos(2\theta)}d(2\theta)
= \int_0^{2\pi}\frac{1 - \cos(x)}{3 + \cos(x)}dx.
$$
The latter transformation is based on the periodicity of $\cos$ -- we should double the range to $[0;4\pi]$, but instead leave it $[0;2\pi]$ and cancel $1/2$ quotient.
In complex plane this looks like
$$
I
= \int_0^{2\pi}\frac{2 - e^{ix} - e^{-ix}}{6 + e^{ix} + e^{-ix}}dx
= \oint_{|z|=1}\frac{i(z - 1)^2}{(z^2 + 6 z + 1)z} dz.
$$
The only poles within the integration contour are $z = 0$ and $z = -3 + 2\sqrt{2}$ that give residues $i$ and $-i\sqrt{2}$. Multiplying by $2\pi i$ and adding them we get the final result
$$
I = 2\pi(\sqrt{2}-1).
$$
