Finding $\int_{-\infty}^\infty \frac{x^2}{x^4+1}\;dx$ $$\int_{-\infty}^\infty \frac{x^2}{x^4+1}\;dx$$
I'm trying to understand trigonometric substitution better, because I never could get a good handle on it.  All I know is that this integral is supposed to reduce to the integral of some power of cosine.  I tried $x^2=\tan\theta$, but I ended up with $\sin\theta\cos^3\theta$ as my integrand.  Can someone explain how to compute this?

Note\begin{align*}
\int_{-\infty}^{\infty} \frac{x^2}{x^4+1} dx 
&\overset{x\to \frac1x}=\int_{-\infty}^{\infty} \frac{1}{x^4+1}dx
=\int_{0}^{\infty} \frac{x^2+1}{x^4+1}dx
=\int_{0}^{\infty} \frac{1+\frac1{x^2}}{x^2+\frac1{x^2}}dx
\\
&= \int_{0}^{\infty} \frac{d(x-\frac{1}{x} )}{\left(x-\frac{1}{x}\right)^2+2} =\frac{1}{\sqrt{2}} \tan^{-1}{\frac{x-\frac{1}{x}}{\sqrt{2}}} \bigg \rvert_{0}^{\infty} 
= {\frac{\pi}{\sqrt{2}}}
\end{align*}
