Trouble with a substitution I'm struggling to show that
$$ \int_{-1}^{1} \frac{(1-x^2)^{1/2}}{1+x^2} dx $$ 
to
$$ -\pi + \int_{-\pi}^{\pi} (1+\cos^2(\theta))^{-1}d\theta$$
with $x=\cos(\theta)$
I'm aware I'm missing something obvious but I end up with a stray $\sin(\theta)$
 A: After the usual substitution, you get 
$$
\int \frac{\sqrt{1-x^2}}{1+x^2}dx = \int_0^\pi \frac{\sin^2\theta}{1+\cos^2 \theta}d\theta = \int_0^\pi \frac{1-\cos^2\theta}{1+\cos^2 \theta}d\theta = \int_0^\pi -1 + \frac{2}{1+\cos^2\theta} = \\-\pi + \int_{-\pi}^\pi \frac{1}{1+\cos^2\theta}d\theta.
$$
In the last steps I was using that 
$$
\frac{1-x^2}{1+x^2} = -1 + \frac{2}{1+x^2}
$$
and that $\frac{1}{1+\cos^2\theta}$ is an even function. 
A: You can use $u=\tan(\frac{\theta}{2})$ in the calculation. In fact,
\begin{eqnarray}
\int_{-\pi}^{\pi}\frac{1}{1+\cos^2\theta}d\theta&=&\int_{-\pi}^{\pi}\frac{1}{1+\frac{1+\cos(2\theta)}{2}}d\theta\\
&=&\int_{-\pi}^{\pi}\frac{2}{3+\cos(2\theta)}d\theta\\
&=&\int_{-2\pi}^{2\pi}\frac{1}{3+\cos(\theta)}d\theta\\
&=&2\int_{-\pi}^{\pi}\frac{1}{3+\cos(\theta)}d\theta\\
&=&4\int_{0}^{\pi}\frac{1}{3+\cos(\theta)}d\theta\\
&=&4\int_{0}^{\pi}\frac{1}{3+\frac{1-\tan^2(\frac\theta2)}{1+\tan^2(\frac\theta2)}}d\theta\\
&=&4\int_{0}^\infty\frac{1}{3+\frac{1-u^2}{1+u^2}}\frac{2}{1+u^2}du\\
&=&8\int_{0}^\infty\frac{1}{4+2u^2}du\\
&=&4\int_{0}^\infty\frac{1}{2+u^2}du\\
&=&4\cdot\frac{1}{\sqrt2}\arctan\frac{u}{\sqrt2}\bigg|_0^\infty\\
&=&\sqrt2\pi.
\end{eqnarray}
