A simple way to evaluate $\int_{-a}^a \frac{x^2}{x^4+1} \, \mathrm dx$?

This answer addresses the question of finding the indefinite integral, and tries to show that there is less to the Wolfram Alpha answer than meets the eye.

Part of the reason the integral is frightening is that when we factor $x^4+1$, we run into a bunch of $\sqrt{2}$. Then completing the square, so natural with simpler numbers, suddenly becomes worrisome. We, who are so rational, are confronted by too many irrationals.

Here is a simple suggestion. Make the change of variable $x=y/\sqrt{2}$. Very quickly, we arrive at $$\int \frac{\sqrt{2}\,y^2}{y^4+4}dy$$
Why this change of variable? Maybe we recall from a contest the question about $n^4+4$ being hardly ever prime. The solution hinges on the fact that the polynomial $y^4+4$ factors nicely: $$y^4+4=(y^2-2y+2)(y^2+2y+2)$$ The factorization is an application of the fundamental result: $$2+2=2\times 2$$

We will forget about the $\sqrt{2}$ until the end. And because fractions can be so fractious, we look at the integral $$\int \frac{8y^2}{y^4+4}dy$$ Note that $$\frac{8y^2}{y^4+4}=\frac{2y}{y^2-2y+2} +\frac{-2y}{y^2+2y+2}$$ To integrate the first summand, note that we want $$\int\frac{(2y-2)+2}{y^2-2y+2}dy$$ The integral of $\frac{2y-2}{y^2-2y+2}$ is easy, the derivative of the bottom is sitting on top. The integral of $\frac{2}{y^2-2y+2}$ is almost as unthreatening, since completing the square is irresistible.

The other integral can be done in the same way. But it is more virtuous to recycle. Let $y=-z$ and notice that we get something familiar.


You'll want to make use of the fact that the polynomial $x^4+1$ is reducible and can be factored as $x^4+1=(x^2-\sqrt{2}x+1)(x^2+\sqrt{2}x+1)$. From here, you'll use a partial fraction decomposition.


Here's a cleaner way to get it:

Euler's Identity gives us $e^{-i x^2}=\cos(-x^2)+i\sin(-x^2)$.

Since cosine is even and sine is odd, this becomes $e^{-i x^2}=\cos(x^2)-i\sin(x^2)$.

Integrating yields $\int_{-\infty}^\infty e^{-i x^2}\;dx=\int_{-\infty}^\infty\cos(x^2)\;dx-i\int_{-\infty}^\infty\sin(x^2)\;dx$.

Thus $\int_{-\infty}^\infty\cos(x^2)\;dx = Re(\int_{-\infty}^\infty e^{-i x^2}\;dx)$.

Now you can use a substitution on the right and the fact that $\int_{-\infty}^\infty e^{- x^2}\;dx=\sqrt{\pi}$ to obtain the value of your integral.