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.


A bit late to the game, but in more generality this is a Mellin Transform.

First, use the fact that $\cos(x^2)$ is even to get an integral from $0$ to $\infty$. We can actually evaluate $$I=\int_0^\infty \cos(x^a)\mathrm dx$$ for $a>1$. Let $u=x^a$, $dx=\frac1{a}u^{\frac1{a}-1}$ so that $$I=\frac{1}{a}\int_0^\infty \cos(u)u^{1/a-1}\mathrm du=\frac1{a}\mathcal{M}\left(\cos(t)\right)\left(\frac1{a}\right).$$ We can evaluate this Mellin transform by using a pizza-slice contour integral in the complex plane to find that for $0 < z < 1$ we have $$\mathcal{M}\left(\cos(t)\right)(z)=\Gamma(z)\cos\left(\frac{\pi z}{2}\right).$$ Consequently, for $a > 1$, $$\int_0^\infty \cos(x^a)\mathrm dx=\frac1{a}\Gamma\left(\frac1{a}\right)\cos\left(\frac{\pi}{2a}\right).$$

Hope that helps,

Remark: If desired, I can upload the full explanation of the pizza slice contour. It is worth mentioning that an identical proof gives the mellin transform for $\sin(t)$.