How to use complex analysis to find the integral $\int^\pi_{−\pi} \frac 1 {1+\sin^2(\theta)} d\theta$? How can I use complex analysis to solve the following:
$$\int^\pi_{−\pi} \frac 1 {1+\sin^2(\theta)} d\theta$$
 A: Start with
$$
z=e^{i\theta} \\
\log z=i\theta \\
\theta=-i\log z \\
d\theta=-\frac izdz
$$
Now we substitute $z$ into our integral.
$$
\oint\frac{-i}{z(1+\sin^2(-i\log z))}dz \\
$$
Analyzing just the $\sin$ part for a moment:
$$
\begin{align}
\sin(-i\log z)&=-\frac i2\left(e^{i(-i\log z)}-e^{-i(-i\log z)}\right)\\
&=-\frac i2\left(e^{\log z}-e^{-\log z}\right) \\
&=-\frac i2\left(z-\frac 1z\right) \\
&=\frac{i(1-z^2)}{2z}
\end{align}
$$
Now we go back to the integral:
$$
\oint\frac{-i}{z\left(1+\left(\frac{i(1-z^2)}{2z}\right)^2\right)}dz \\
=\oint\frac{-i}{z\left(1-\frac{(1-z^2)^2}{4z^2}\right)}dz \\
=i\oint\frac{1}{\frac{1-6z^2+z^4}{4z}}dz \\
=i\oint\frac{4z}{1-6z^2+z^4}dz
$$
Now we can do partial fraction decomposition on the integrand to expose its poles:
$$
=\frac{i}{2\sqrt{2}}\oint\frac{1}{z-(-1-\sqrt{2})}-\frac{1}{z-(-1+\sqrt{2})}-\frac{1}{z-(1-\sqrt{2})}+\frac{1}{z-(1+\sqrt{2})}dz \\
$$
Two of these poles (the negative ones) are inside the unit circle, our integration contour.  By Cauchy's integral formula, we get the value of the integral:
$$
2\pi i\left(\frac{i}{2\sqrt{2}}(-1-1)\right)=2\pi\frac{-2}{-2\sqrt{2}}=\sqrt{2}\pi
$$
A: Put $z=e^{i\theta}$ and rewrite using Euler's forumulas to transform the integral to a complex curve integral along the unit circle.
A: A mixed technique is most suited for solving this problem. We have:
$$ I = 4\int_{0}^{\pi/2}\frac{d\theta}{1+\sin^2\theta}=4\int_{0}^{\pi/2}\frac{d\theta}{1+\cos^2\theta}$$
and substituting $\theta=\arctan t$:
$$ I = 4\int_{0}^{+\infty}\frac{dt}{(1+t^2)\left(1+\frac{1}{1+t^2}\right)}=2\int_{-\infty}^{+\infty}\frac{dt}{2+t^2},$$
where the last integral can be approached through the residue theorem or by explicit integration:
$$2\int_{-\infty}^{+\infty}\frac{dt}{2+t^2}=\sqrt{2}\int_{\mathbb{R}}\frac{du}{1+u^2}=\color{red}{\pi\sqrt{2}.}$$
