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.

Thanks for any answers in advance.

  • $\begingroup$ How does the considered integral relate to Fresnell's integral? Could you tell me? Thanks. :-) $\endgroup$ – Venus Dec 5 '14 at 20:18
  • 1
    $\begingroup$ @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. $\endgroup$ – Huy Dec 5 '14 at 20:25
  • $\begingroup$ 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. $\endgroup$ – 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.

  • 2
    $\begingroup$ Lovin the adjectives... :) "fractious, rational, irresistible" etc $\endgroup$ – The Chaz 2.0 May 5 '11 at 20:54
  • 4
    $\begingroup$ Yes, +1 for style. $\endgroup$ – Uticensis May 5 '11 at 21:19
  • $\begingroup$ 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. $\endgroup$ – Huy May 5 '11 at 22:22
  • $\begingroup$ 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. $\endgroup$ – Huy May 6 '11 at 12:18
  • 1
    $\begingroup$ I don't know why, but "completing the square is irresistible" sounds to me like a really funny phrase. $\endgroup$ – recursive recursion May 3 '14 at 0:06

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.

  • 1
    $\begingroup$ $(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$. $\endgroup$ – Huy May 5 '11 at 17:58
  • $\begingroup$ Thanks. I forgot the $\sqrt{2}$'s. $\endgroup$ – wckronholm May 5 '11 at 18:02
  • $\begingroup$ 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 :( ) $\endgroup$ – Huy May 5 '11 at 18:03
  • 6
    $\begingroup$ 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. $\endgroup$ – 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.

  • $\begingroup$ 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$? $\endgroup$ – Huy May 5 '11 at 22:13
  • 2
    $\begingroup$ 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$. $\endgroup$ – wckronholm May 5 '11 at 22:58
  • $\begingroup$ 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. $\endgroup$ – Huy May 5 '11 at 23:32
  • 2
    $\begingroup$ 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. $\endgroup$ – Did May 6 '11 at 12:20
  • 3
    $\begingroup$ 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... :-) $\endgroup$ – 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}$$

  • 1
    $\begingroup$ 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}$. $\endgroup$ – Sam May 6 '11 at 16:45
  • 1
    $\begingroup$ It looks to me like you have salvaged my suggestion above. $\endgroup$ – wckronholm May 6 '11 at 20:39
  • $\begingroup$ 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$? $\endgroup$ – Huy May 6 '11 at 22:38
  • $\begingroup$ @Huy: integration by parts $\endgroup$ – Sam May 6 '11 at 23:09

$\newcommand{\+}{^{\dagger}} \newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle} \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack} \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,} \newcommand{\dd}{{\rm d}} \newcommand{\down}{\downarrow} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,{\rm e}^{#1}\,} \newcommand{\fermi}{\,{\rm f}} \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,} \newcommand{\half}{{1 \over 2}} \newcommand{\ic}{{\rm i}} \newcommand{\iff}{\Longleftrightarrow} \newcommand{\imp}{\Longrightarrow} \newcommand{\isdiv}{\,\left.\right\vert\,} \newcommand{\ket}[1]{\left\vert #1\right\rangle} \newcommand{\ol}[1]{\overline{#1}} \newcommand{\pars}[1]{\left(\, #1 \,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\pp}{{\cal P}} \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,} \newcommand{\sech}{\,{\rm sech}} \newcommand{\sgn}{\,{\rm sgn}} \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}} \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert} \newcommand{\wt}[1]{\widetilde{#1}}$ $\ds{\int_{-a}^{a}{x^{2} \over x^{4} + 1}\,\dd x:\ {\large ?}.\qquad a \in {\mathbb R}}$. $$ \color{#c00000}{\int_{-a}^{a}{x^{2} \over x^{4} + 1}\,\dd x} =2\sgn\pars{a}\int_{0}^{\verts{a}}{x^{2} \over x^{4} + 1}\,\dd x $$

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.


I'm late to the party, but here's a simple way to derive the result shown in W|A without knowing before hand that $x^4+1$ factors as $(x^2-\sqrt{2}x+1)(x^2+\sqrt{2}x+1)$. We have that $$\int_{-a}^a\dfrac{x^2}{x^4+1}\,\mathrm dx=\int_{-a}^a\dfrac{\tfrac1{x^2}\cdot x^2}{\tfrac1{x^2}\cdot \left(x^4+1\right)}\,\mathrm dx=\int_{-a}^a\dfrac{1}{x^2+\tfrac1{x^2}}\,\mathrm dx.$$ Now here's the trick, since $\left(x+\tfrac1x\right)^2=x^2+2+\tfrac1{x^2}$ it follows that $x^2+\tfrac1{x^2}=\left(x+\tfrac1x\right)^2-\sqrt{2}^2$. Hence the fraction decomposes nicely as follows, $$\begin{align} \frac{1}{\tfrac1{x^2}+x^2}&=\frac{1}{\left(\tfrac{1}x+x\right)^2-2} \\&=\dfrac{1} {\left (\tfrac{1}{x}+x+\sqrt{2}\right)\left(\tfrac{1}{x}+x-\sqrt{2}\right)}\\&= \dfrac{A}{\tfrac{1}{x}+x+\sqrt{2}}+\dfrac{B}{\tfrac{1}{x}+x-\sqrt{2}}. \end{align}$$ Using standard techniques we find that $A=\tfrac{-1}{2\sqrt{2}}$ and $B=\tfrac{1}{2\sqrt{2}}$, and so the last expression can be reduced to, $$\dfrac{x}{2\sqrt{2}\left(x^2+\sqrt{2}x+1\right)}-\dfrac{x}{2\sqrt{2}\left(x^2-\sqrt{2}x+1\right)}.$$ The rest will be messy but still pretty straightforward.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.