Solve $\int_{-\pi}^{\pi}\frac{1}{1+\sin^{^{2}}t}dt$ I need to solve $\int_{-\pi}^{\pi}\frac{1}{1+\sin^{^{2}}t}dt$. This is what I did, but I think the answer should be $\sqrt{2}\pi$.
${\sin^{^{2}}t}=\frac{1-\cos(2t)}{2}$
$z=e^{2ti}=\cos(2t)+i\sin(2t)$
$-2\pi \leq 2t\leq 2\pi$
$\cos(2t)=\Re(z)=\frac{z+\bar{z}}{2}$
$z^{-1}=\frac{1}{z}=\frac{\bar{z}}{|z|^{2}}$ with $|z|=1$
$\frac{1}{1+\sin^{2}t}=\frac{4}{6-z-\frac{1}{z}}$
$dt=\frac{dz}{2iz}$
$\int_{-\pi}^{\pi}\frac{1}{1+\sin^{^{2}}t}dt=\oint_{|z|=1}\frac{4}{6-z-\frac{1}{z}}\frac{dz}{2iz}=\frac{2}{i}\oint_{|z|=1}\frac{1}{6z-z^{2}-1}dz$
$6z-z^{2}-1=0$
$z_{1}=3-2\sqrt{2}\in\Omega$
$z_{2}=3+2\sqrt{2}\notin\Omega$
$f(z)=\frac{1}{6z-z^{2}-1}=\frac{1}{[z-(3-2\sqrt{2})][z-(3+2\sqrt{2})]}$
$\operatorname{Res}(f,z_{1})=\lim_{z\to z_{1}}(z-z_{1})f(z)=-\frac{1}{4\sqrt{2}}$
Using the Residue theorem $\frac{2}{i} 2\pi i(-\frac{1}{4\sqrt{2}})=\pi (-\frac{1}{\sqrt{2}})$
I've solved problems like this before just fine, but the parametrizations were always $z=e^{ti}$ $-\pi \leq t\leq \pi$, so I think that's where my problem is, but I don't know how to do it right.
 A: Here is an alternative approach without using complex analysis.
The change of variables $\sin(t)=\dfrac{2u}{1+u^2}$ with $u=\tan\left(\dfrac{t}{2}\right)$ gives $\mbox{d}u=\dfrac{1}{2}\left(1+\tan\left(\dfrac{t}{2}\right)^2\right)\mbox{d}t$.
And therefore 
\begin{align*}I&=\int_{-\pi}^{\pi}\dfrac{1}{1+\sin(t)^2}\mbox{d}t\\
&=2\int_{0}^{\pi}\dfrac{1}{1+\sin(t)^2}\mbox{d}t\\
&=4\int_{0}^{+\infty}\dfrac{1}{1+\left(\dfrac{2u}{1+u^2}\right)^2 }\dfrac{\mbox{d}u}{1+u^2}\\
&=4\int_{0}^{+\infty}\dfrac{1+u^2}{1+u^4+6u^2}\mbox{d}u.
\end{align*}
Now notice that, noting $\alpha=3-2\sqrt{2}$ and $\beta=3+2\sqrt{2}$, you have $1+u^4+6u^2=(u^2+\alpha)(u^2+\beta)$ and
\begin{align*}
\dfrac{1+u^2}{1+u^4+6u^2}&=\dfrac{1+u^2+\alpha-\alpha}{1+u^4+6u^2}\\
&=\dfrac{1-\alpha}{1+u^4+6u^2}+\dfrac{1}{u^2+\beta}\\
&=\dfrac{1}{u^2+\beta}+(1-\alpha)\dfrac{1}{4\sqrt{2}}\left(\dfrac{1}{u^2+\alpha}+\dfrac{-1}{u^2+\beta}\right).
\end{align*}
Thus, \begin{align*}
\int_{0}^{\infty}\dfrac{1+u^2}{1+u^4+6u^2}du=\dfrac{1}{\sqrt{\beta}}\dfrac{\pi}{2}+(1-\alpha)\dfrac{1}{4\sqrt{2}}\dfrac{\pi}{2}\left(-\dfrac{1}{\sqrt{\beta}}+\dfrac{1}{\sqrt{\alpha}}\right).
\end{align*}
Since $\sqrt{\alpha}=\sqrt{2}-1$ and $\sqrt{\beta}=1+\sqrt{2}$ we obtain
\begin{align*}
I&=4\int_{0}^{+\infty}\dfrac{1+u^2}{1+u^4+6u^2}\mbox{d}u\\
&=\dfrac{4}{\sqrt{\beta}}\dfrac{\pi}{2}+(1-\alpha)\dfrac{1}{\sqrt{2}}\dfrac{\pi}{2}\left(\dfrac{-1}{\sqrt{\beta}}+\dfrac{1}{\sqrt{\alpha}}\right)\\
&=\pi\left(\dfrac{2}{1+\sqrt{2}}+\dfrac{\sqrt{2}-1}{\sqrt{2}}\dfrac{-\sqrt{\alpha}+\sqrt{\beta}}{\sqrt{\alpha\beta}}\right)\\
&=\pi(2\sqrt{2}-2+\sqrt{2}(\sqrt{2}-1))\\
&=\pi(2\sqrt{2}-2+2-\sqrt{2})\\
&=\sqrt{2}\pi.
\end{align*}
A: Why not use your suggested $z=e^{it}$ parametrization from the start?
$$\int_{-\pi}^\pi\frac1{1+\sin^2(t)}~\mathrm dt=\oint_{|z|=1}\frac{4z/i}{3z^2+2z-1}~\mathrm dz$$
which follows from $\displaystyle\sin(t)=\frac{e^{it}-e^{-it}}{2i}$.
A: Sketch of another method (not using complex analysis): You could also note that your integral equals $$\int_{-\pi}^{\pi}\frac{1}{1+\sin^2 t}\, dt = 4\int_0^{\pi/2}\frac{1}{1+\sin^2 t}\, dt$$ (make sure you can explain why, based on symmetry of the $\sin^2 t$ function!). Then for all $t\in(0,\pi/2)$, note that
$$\frac{1}{1+\sin^2 t} = \frac{\sec^2 t}{\sec^2 t + \tan^2 t} =  \frac{\sec^2 t}{1+ 2\tan^2 t},$$
using $\sec^2 t = 1 + \tan^2 t$.
Now a substitution of $u=\tan t$ will allow you to get to the answer.
A: Ported from the comments:

The mistakes were


*

*The substitution $z=e^{2it}$ over $t\in[-\pi,\pi]$ causes $z$ to loop around the unit circle twice i.e. a winding number of 2, so the end result needs to be doubled.

*$6z-z^2-1\ne z^2-6z+1=[z-(3+2\sqrt2)][z-(3-2\sqrt2)]$, so you missed a negative sign when factoring the denominator.
In total, this gives an extra factor of $-2$ to your final answer, which gives the correct result of $\pi\sqrt2$.
