How to evaluate $\int_{0}^{2\pi}\frac{1}{1+\sin^{2}(\theta)}d\theta$ I'm pretty sure the idea is to interpret this integral as a contour integral over a closed path in the complex plane.
$$I = \int_{0}^{2\pi}\frac{1}{1+\sin^{2}(\theta)}d\theta$$
We take $C = \{z \in \mathbb{C} : |z| = 1\}$, which is positively oriented.
$$z = e^{i\theta}$$
$$\frac{dz}{d\theta} = ie^{i\theta} = iz \rightarrow d\theta = \frac{dz}{iz} $$
$$\sin(\theta) = \frac{e^{i\theta}-e^{-i\theta}}{2i} = \frac{z-z^{-1}}{2i} $$
$$\sin^2(\theta) = \frac{z^2 - 2zz^{-1} + z^{-2}}{(2i)^2} = \frac{z^2 - 2 + z^{-2}}{-4} $$
After some manipulation:
$$I = \frac{4}{i}\oint_{C}\frac{z}{-z^4+6z^2-1}dz$$
After that one should obtain the roots of the polynomial in the denominator and solve the integral either by residues or using Cauchy's formula. However, I'm not sure how to find the roots. This was in the context of an exam, so I assume something must be wrong if the roots are too difficult to find, or if they are not "nice" numbers.
Is there a more clever way of going about this? I tried calculating the residue at infinity, but $\frac{1}{z^{2}}f(\frac{1}{z})$ yields the exact same function and it doesn't get any easier.
Thanks.

How about using Weierstrauss substitution.
$$I=\int_0^{2\pi}\frac{1}{1+\sin^2(x)}dx$$
$t=\tan\frac{x}{2}$ so it becomes:
$$I=4\int_0^\infty\frac{1}{1+\left(\frac{2t}{1+t^2}\right)^2}\frac{dt}{1+t^2}=4\int_0^\infty\frac{1+t^2}{(1+t^2)^2+(2t)^2}dt$$
$$=4\int_0^\infty\frac{t^2+1}{t^4+6t^2+1}dt=4\int_0^\infty\frac{t^2+1}{(t^2+3-2\sqrt{2})(t^2+3+2\sqrt{2})}dt$$
now using partial fractions:
$$\frac{t^2+1}{(t^2+3-2\sqrt{2})(t^2+3+2\sqrt{2})}=\frac{At+B}{t^2+3-2\sqrt{2}}+\frac{Ct+D}{t^2+3+2\sqrt{2}}$$
giving us the simultaneous equations:
$$A+C=0$$$$B+D=1$$$$(3+2\sqrt{2})A+(3-2\sqrt{2})C=0$$$$(3+2\sqrt{2})B+(3-2\sqrt{2})D=1$$
Both $A$ and $C$ come out as $0$ so some form of $\tan$ substitution can be used to solve the two integrals that are formed.
