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?

Notice that:
$$\begin{eqnarray*} \int_{-\infty}^{+\infty}\frac{x^2}{x^4+1}\,dx &=& 2\int_{0}^{+\infty}\frac{x^2}{x^4+1}\,dx\\ &=& 2\int_{0}^{1}\frac{x^2}{1+x^4}\,dx+2\int_{1}^{+\infty}\frac{x^2}{1+x^4}\,dx\\&=&2\int_{0}^{1}\frac{1+x^2}{1+x^4}\,dx\\&=&2\left(1+\frac{1}{3}-\frac{1}{5}-\frac{1}{7}+\frac{1}{9}-\frac{1}{11}+\ldots\right)\\&=&2\left(1+\frac{2}{4^2-1}-\frac{2}{8^2-1}+\frac{2}{12^2-1}-\ldots\right)\end{eqnarray*}$$
and, from the logarithmic derivative of the Weierstrass product for the sine and cosine function:
$$ \sum_{k\geq 0}\frac{1}{(2k+1)^2-x^2}=\frac{\pi}{4x}\,\tan\left(\frac{\pi x}{2}\right),$$
$$ \sum_{k\geq 1}\frac{1}{k^2-x^2}=\frac{1-\pi x\cot(\pi x)}{2x^2},$$
so by taking limits as $x\to\frac{1}{2}$ we get:
$$ \int_{-\infty}^{+\infty}\frac{x^2}{x^4+1}\,dx = \color{red}{\frac{\pi}{\sqrt{2}}}.$$
