# 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.

-
How does the considered integral relate to Fresnell's integral? Could you tell me? Thanks. :-) –  Venus Dec 5 '14 at 20:18
@Venus: To evaluate $\int_{-\infty}^\infty \cos(x^2) \, \mathrm dx$, substitute $t = x^2$ and use $t^{-1/2} = \pi^{-1/2} \int_{-\infty}^\infty e^{-tu^2} \, \mathrm du$. Then use Fubini's theorem. –  Huy Dec 5 '14 at 20:25
Sorry Huy, I can't follow you. What happen with the bounds of integral after substitution? Could you elaborate your answer more detail? You can reply my comment in chat room. Thanks. –  Venus Dec 6 '14 at 4:01

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

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)$.

-

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


With $\ds{t \equiv {1 \over x^{4} + 1}\quad\imp\quad x = \pars{{1 \over t} - 1}^{1/4}}$: \begin{align} &\color{#c00000}{\int_{-a}^{a}{x^{2} \over x^{4} + 1}\,\dd x} = 2\sgn\pars{a}\int_{1}^{1/\pars{a^{4} + 1}}t\pars{{1 \over t} - 1}^{1/2} \bracks{{1 \over 4}\,\pars{{1 \over t} - 1}^{-3/4}\,\pars{-\,{1 \over t^{2}}}\,\dd t} \\[3mm]&=\half\,\sgn\pars{a}\int^{1}_{1/\pars{a^{4} + 1}} t^{-3/4}\pars{1 - t}^{-1/4}\,\dd t \\[3mm]&=\half\,\sgn\pars{a}\bracks{% \int^{1}_{0}t^{-3/4}\pars{1 - t}^{-1/4}\,\dd t - \int_{0}^{1/\pars{a^{4} + 1}}t^{-3/4}\pars{1 - t}^{-1/4}\,\dd t} \\[3mm]&=\half\,\sgn\pars{a}\bracks{% {\rm B}\pars{{1 \over 4},{3 \over 4}} -{\rm B}\pars{{1 \over a^{4} + 1};{1 \over 4},{3 \over 4}}} \end{align} where $\ds{{\rm B}}$'s are Beta Functions.

Moreover, $\ds{{\rm B}\pars{{1 \over 4},{3 \over 4}} = \Gamma\pars{1 \over 4} \Gamma\pars{3 \over 4} = {\pi \over \sin\pars{\pi/4}} = \root{2}\,\pi}$. $\ds{\Gamma\pars{z}}$ is the Gamma Function and we used well known properties of $\ds{\rm B}$'s and $\ds{\Gamma}$'s.

$$\color{#00f}{\large\int_{-a}^{a}{x^{2} \over x^{4} + 1}\,\dd x =\half\,\sgn\pars{a}\bracks{\root{2}\pi -{\rm B}\pars{{1 \over a^{4} + 1};{1 \over 4},{3 \over 4}}}}$$

-

I can show you a method to solve this integral and a somewhat larger class of functions. The technique is taken from my notes on integration and is the most elementary method I know. This is somewhat of a sketch and I leave it to you to fill in any holes, if you do have a specific question, feel free to leave a comment below. In the very samme document there is a proof for the Fresnel Integrals see page 133. I am working on including an alternative proof, but alas this will use a fair bit of complex analysis.

Lemma 1

The following integrals converge \begin{align} \frac12 \int_{0}^{\infty} \frac{1+x^{n-2}}{1+x^n}\mathrm{d}x = \int_{0}^{\infty} \frac{\mathrm{d}x}{1+x^n} = \int_{0}^{\infty} \frac{x^{n-2}}{1+x^n} \mathrm{d}x \tag{1} \end{align} Given that $n$ is a real number greater than one $1$.

Taking this lemma for granted and letting $n=2$ in $(1)$ we get $$\int_{0}^{\infty} \frac{x^2}{1+x^4} \mathrm{d}x = \frac{1}{2}\int_{0}^{\infty} \frac{1+x^{2}}{1+x^4} \mathrm{d}x$$ Note that $n$ is an even number and hence the integrands are even. We can then write $$\int_{-\infty}^{\infty} \frac{x^2}{1+x^4} \mathrm{d}x = \int_{0}^{\infty} \frac{1+x^{2}}{1+x^4} \mathrm{d}x$$ I deliberately use the limits over the entire plane instead of $-a$ to $a$ since you say that you are using this integral to compute the Fresnel integrals. The integral on the right is easier to integrate and we have $$\int_{0}^{\infty} \frac{1+x^{2}}{1+x^4} \mathrm{d}x = \int_0^\infty \frac{1+1/x^2}{x^2+1/x^2}\mathrm{d}x = \int_0^\infty \frac{1+1/x^2}{(x-x^{-1})^2 + 2} \mathrm{d}x$$ To compute the last integral let $u \mapsto x-x^{-1}$ so $\mathrm{d}u= (1+1/x^2)\mathrm{d}x$ and the limits now becomes $(-\infty,\infty)$ $$\int_{0}^{\infty} \frac{1+x^{2}}{1+x^4} \mathrm{d}x = \int_{-\infty}^\infty \frac{\mathrm{d}u}{u^2 + 2} = \frac{1}{\sqrt{2}}\int_{-\infty}^\infty \frac{\mathrm{d}y}{y^2 + 1}$$ Hence we can finally conclude that $$\int_{-\infty}^{\infty} \frac{ x^2}{1+x^4} \mathrm{d}x = \int_{0}^{\infty} \frac{1+x^2}{1+x^4} \mathrm{d}x = \frac{1}{\sqrt{2}}\int_{-\infty}^\infty \frac{\mathrm{d}y}{y^2 + 1} = \frac{\pi}{\sqrt{2}}$$ where one recognizes the last integral as the anti-derivative of the $\arctan x$ function. A proof of the lemma can be found on page 40 in my documents and is easily proven.

proof. By using the substitution $x \mapsto 1/x$ on the integral $\int 1/(1+x^n)\mathrm{d}x$ we have $$\int_{0}^{\infty} \frac{\mathrm{d}x}{1+x^n} = -\int_{0}^{\infty} \frac{1}{1+x^{-n}} \frac{x^n}{x^n}\frac{\mathrm{d}x}{x^2} = \int_{0}^{\infty} \frac{x^{n-2}}{1+x^n}\mathrm{d}x \tag{2}$$ and this establishes the first equality in lemma 1. These two integrals have the same value and addition gives $$\int_{0}^{\infty} \frac{\mathrm{d}x}{1+x^n} + \int_{0}^{\infty} \frac{x^{n-2}}{1+x^n}\mathrm{d}x = \int_{0}^{\infty} \frac{1+x^{n-2}}{1+x^n} \mathrm{d}x$$ dividing by $2$ and using $(2)$ finishes the proof.

-