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

I am currently trying to show that $\int_{-\infty}^\infty \cos(x^2) \, \mathrm dx = \sqrt{\frac{\pi}{2}}$ and the last integral I have to evaluate is $$\int_{-a}^a \frac{x^2}{x^4+1} \, \mathrm dx.$$ Now of course I'm familiar with wolframalpha, however the way it solves this integral seems very awkward and also not elegant to me, even though the function to me looks quite simple. So, is there a simpler way to solve this integral or is the way described on wolframalpha already (one of) the simplest approach(es)? I ask this because often wolframalpha doesn't see tricks (occurred to me when I wanted to find a formula for the n-th derivative of some function) which a human eye might see.

-

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.

-
Lovin the adjectives... :) "fractious, rational, irresistible" etc –  The Chaz 2.0 May 5 '11 at 20:54
Yes, +1 for style. –  Uticensis May 5 '11 at 21:19
This approach indeed does seem easier than wolframalpha's. I will try to solve the integral in this way as soon as I've had enough sleep. –  Huy May 5 '11 at 22:22
It worked like a harm. Thanks a lot. I accept this answer, as - opposed to the other two answers - it actually answers my original question. –  Huy May 6 '11 at 12:18
This is beautiful. –  Thomas Rot May 6 '11 at 13:39

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.

-
$(x^2-x+1)(x^2+x+1) = x^4 + x^3 + x^2 - x^3 - x^2 - x + x^2 + x + 1 = x^4 + x^2 + 1$. –  Huy May 5 '11 at 17:58
Thanks. I forgot the $\sqrt{2}$'s. –  wckronholm May 5 '11 at 18:02
Then, it's basically the way described by wolframalpha. I'm looking for a simpler way than that one. (if it's already the simplest way, I'd be quite disappointed :( ) –  Huy May 5 '11 at 18:03
Your integral appears to be equivalent to the integral $\int \sqrt{\tan(x)}\;dx$. This integral has the notorious reputation of being the most difficult integral capable of being solved using techniques learned in a standard second semester calculus course. I'm not aware of any simpler method of its solution, and would also be interested if someone has a different technique which works nicely. –  wckronholm May 5 '11 at 18:14

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.

-
This indeed is a very nice way to get it. However, how exactly do I solve $\int_{-\infty}^\infty e^{-i x^2} \, \mathrm dx$? –  Huy May 5 '11 at 22:13
With a substitution: let $u=\sqrt{i}x$. And by $\sqrt{i}$ I mean $\sqrt{2}/2 +i\sqrt{2}/2$. This will leave you with a constant times the integral $\int_{-\infty}^\infty e^{-x^2}\;dx$. –  wckronholm May 5 '11 at 22:58
Thank you very much for the quick answer, I wonder why our professor wants us to solve the integral the awkward way. Probably to actually solve that final integral. –  Huy May 5 '11 at 23:32
Wow! I hope @Huy does not present this solution to our professor because this could provoke some unpleasant questions. Such as: how comes that the value of the integral of $\exp(-x^2)$ on the real line determines the value of the integral of $\exp(-\mathrm{i}x^2)$ on the real line? Answer: it does not. At all. In other words I am awfully sorry to bring bad news but let me warn you: @wckronholm's solution is not correct. –  Did May 6 '11 at 12:20
First question: No you would not. To justify this kind of manipulation requires to delve into complex analysis matters (which seem to be out of your scope, forgive me if they are not). Second question: I am sure you can formulate a guess... :-) –  Did May 6 '11 at 12:52

I think one might turn wckronholm's answer into a correct argument along the following lines (though the following is by no means more than a heuristic argument as it stands):

Define $F(t) = \int_{-\infty}^\infty \exp(-tx^2) \, dx$. Then

\begin{align*} \frac{d}{dt} F(t) &= \int_{-\infty}^\infty -x^2 \exp(-tx^2) \, dx \\ &= \int_{-\infty}^\infty \frac{x}{2t} \left(-2tx \exp(-tx^2)\right)\, dx \\ &= \frac{-1}{2t} \int_{-\infty} \exp(-tx^2) \, dx \\ &= \frac{-1}{2t} F(t) \end{align*}

This differential equation is satisfied by $F(t) = C \exp\left(-\frac{1}{2}\log(t)\right)$ for some constant $C$. Since our $F$ should satisfy $F(1) = \sqrt{\pi}$, we must have

$$F(t) = \sqrt{\pi} \exp\left(\frac{-1}{2}\log(t)\right)$$

So in particular for $t = -i$ we get

\begin{align*} F(-i) &= \sqrt{\pi} \exp\left(\frac{-1}{2}\log(-i)\right) \\ &= \sqrt{\pi} \exp\left(\frac{-1}{2} \cdot\frac{-\pi i} 2\right) \\ &= \sqrt{\pi} \left(\frac1{\sqrt2} + \frac i {\sqrt{2}}\right) \end{align*}

Which would mean that

$$\int_{-\infty}^\infty \cos(x^2) \, dx + i\cdot \int_{-\infty}^\infty \sin(x^2) \, dx = \int_{-\infty}^\infty e^{ix^2} \, dx = F(-i) = \sqrt{\frac{\pi}2} + i \sqrt{\frac{\pi}2}$$

-
I acutally think the above is not very far from being perfectly rigorous. I guess $F(t)$ is nothing but an analytic continuation of $\int_{-\infty}^\infty \exp(-tx^2) \, dx$ to $\mathbb C - \mathbb R_{<0}$. –  Sam May 6 '11 at 16:45
It looks to me like you have salvaged my suggestion above. –  wckronholm May 6 '11 at 20:39
There's one part I don't understand at this very moment: Why is $\int_{-\infty}^\infty \frac{x}{2t} (-2tx \exp(-tx^2)) \, \mathrm dx = \frac{-1}{2t} \int_{-\infty}^\infty \exp(-tx^2) \, \mathrm dx$? –  Huy May 6 '11 at 22:38
@Huy: integration by parts –  Sam May 6 '11 at 23:09
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).$$
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)$.