Bug introduced in 7.0 or earlier and fixed in 11.0

Mathematica 10 gives the following very odd result,

Integrate[Sin[Sqrt[x]]/Sqrt[x], {x, 1, ∞}]
(* 2 Cos[1] *)

which seems unintuitive. The integrand has an easy to find antiderivative,

Integrate[Sin[Sqrt[x]]/Sqrt[x], x]
(* -2 Cos[Sqrt[x]] *)

When we evaluate this at the limits of integration, nothing surprising,

Function[x, -2 Cos[Sqrt[x]]] /@ {∞, 1}
(* {Interval[{-2, 2}], -2 Cos[1]} *)

And it isn't that Mathematica can't handle the difference between an Interval object and a number,

(* {Interval[{-2 - 2 Cos[1], 2 - 2 Cos[1]}]} *)

So why does it seem so confident that the answer is 2 Cos[1]?


We can even go further to see that this is wrong by making the substitution $u^2=x$ ($2u \mathrm{d}u=\mathrm{d}x$)

Integrate[2*u*(Sin[u]/u), {u, 1, Infinity}]

During evaluation of Integrate::idiv:Integral of Sin[u] does not converge on {1,∞}. >>

(* Integrate[2*Sin[u], {u, 1, Infinity}] *)

And just to drive this home even further, we try with NIntegrate, which after spitting out error messages gives an answer on the order of $10^{114}$

  • 8
    $\begingroup$ Do not use the bugs tag until your observation has been verified to be a bug. Also, please include your version number and OS. Finally, there's no question here that I see; SE is supposed to be used for asking questions. $\endgroup$ Commented Feb 11, 2016 at 13:08
  • 2
    $\begingroup$ WolframAlpha returns the same. $\endgroup$ Commented Feb 11, 2016 at 13:23
  • 6
    $\begingroup$ The Bugs tag applies imo. $\endgroup$
    – george2079
    Commented Feb 11, 2016 at 17:03
  • 3
    $\begingroup$ @J.M. I have checked it with versions 8.0.4, 9.0.1 and 10.3.1 on Windows and the result is the same (2 Cos[1]). With version 5.2 I get the Integrate::idiv message and the integral returns unevaluated. $\endgroup$ Commented Feb 12, 2016 at 7:53
  • 9
    $\begingroup$ @VadimPonomarenko what are you expecting for your bounty? $\endgroup$
    – george2079
    Commented Feb 19, 2016 at 15:22

2 Answers 2


I don't know what Mathematica is doing, but there are two ways to justify the result (if you're willing to accept different formulations of integrability).

In an analogy with Cesàro summability, the 2 Cos[1] is the "Cesàro sum" $$\int_0^\infty f(u) \; du \buildrel C \over = \lim_{z \rightarrow \infty} {1 \over z} \int_0^z \int_0^y f(u) \; du \; dy$$ of the integral $$\int_1^\infty {\sin \sqrt{x} \over \sqrt{x}} \; dx = \int_0^\infty 2 \sin(u+1) \; du$$ In Mathematica code:

Limit[Integrate[2 Sin[u + 1], {y, 0, z}, {u, 0, y}]/(z), z -> Infinity]
(*  2 Cos[1]  *)

Alternatively, and perhaps controversially, one might accept that the result is consistent with theory of the Dirac delta distribution. Now a constant function is not the normal sort of test function I'm familiar with, but if, say, you were a physicist designing a mathematical computation system, you might think it was OK. After all, you could check the reasonableness of the answer with physical reality.

If we take $$\delta(x) \buildrel \text{def} \over = {1 \over 2\pi} \int_{-\infty}^{\infty} \cos(xt) \; dt\,,$$ then $$ \eqalign{ \int_1^{\infty}{\sin \sqrt{x} \over \sqrt{x}} \; dx &= \int_1^{\infty}2 \cos(u-\pi/2) \; du\cr &= 2 \int_{1-{\pi\over2}}^\infty \cos w \; dw\cr &= \int_{-\infty}^{\infty} \cos w \; dw + \int_{1-{\pi\over2}}^{{\pi\over2}-1} \cos w \; dw\cr &= 2\pi\,\delta(1) + 2 \cos(1) = 2 \cos(1) }$$

Well, delta functions aside, at least the first method is a mathematically valid way to define the value of a divergent integral.

Update: Looking at the trace as well as using Internal`Integrate`debugSwitch,

Block[{Internal`Integrate`debugSwitch = 10},
 Integrate[Sin[Sqrt[x]]/Sqrt[x], {x, 1, ∞}]

it is pretty clearly a bug. The end point 1 is checked, but not , for convergence. The output above is quite long. One can also see the omission in

 Integrate[Sin[Sqrt@x]/Sqrt@x, {x, 1, ∞}],
 TraceInternal -> True]

if you compare it with

 Integrate[Exp[-x], {x, 1, ∞}],
 TraceInternal -> True]

Normally it seems to check the limit at infinity of x f[x], where f[x] is the integrand, provided f[x] vanishes at infinity. Not all integrands are checked in this way. For instance, this convergent integral is not checked at infinity:

Integrate[Sin[x]/Sqrt[x], {x, 1, ∞}]

Perhaps it is related to the OP's integral.

  • 6
    $\begingroup$ Apart from Cesàro summability, one could also consider Abel summability for this formally divergent integral, in which case you also obtain the result $2\cos 1$: Limit[Integrate[Exp[-c x] Sinc[Sqrt[x]], {x, 1, ∞}, GenerateConditions -> False], c -> 0, Direction -> -1] // FullSimplify $\endgroup$ Commented Feb 21, 2016 at 2:22
  • 1
    $\begingroup$ @J.M. Probably most regularizations will give the same answer. Don't know why Abel didn't occur to me first. I actually use that from time to time. (Thank for the spelling correction.) $\endgroup$
    – Michael E2
    Commented Feb 21, 2016 at 2:37

Improper integrals cannot be computed using a normal Riemann integral. Because $\int_1^{\infty } \frac{\sin \left(\sqrt{x}\right)}{\sqrt{x}} \, dx$ is an improper integral it can be computed by replacing infinite limits with finite values:

In:=  Table [Integrate[Sin[Sqrt[x]]/Sqrt[x] Boole[x < i], {x, 1, Infinity}] // N,  {i, 1, 10, 1}]

Out:= {0., 0.768717, 1.40172, 1.9129, 2.31515, 2.62042, 2.83974, 2.98333, 3.06059, 3.08018}

(* It could be faster to use NIntegrate than to use Integrate and follow it with N. *)

By abuse of notation, improper integrals are often written symbolically just like standard definite integrals, perhaps with infinity among the limits of integration.

  • 4
    $\begingroup$ Do you think Integrate can only compute a proper Riemann integral? You seem to think Mathematica cannot deal with improper integrals. Your remarks, as far as they concern the workings of the Mathematica function Integrate, seem inaccurate. $\endgroup$
    – Michael E2
    Commented Feb 21, 2016 at 0:18
  • $\begingroup$ Here are some references that can help to find a specific cause or accurate solution related to the implementation details of Integrate for symbolic integration: goo.gl/egZBgM . Anyone could also look at the output of: ToExpression["??" ~~ #] & /@ Names["Integrate`ImproperDump`*"] after evaluating Integrate[Sin[Sqrt[x]]/Sqrt[x], {x, 1, \[Infinity]}] to get an idea of the approach that is suggested in the original question. $\endgroup$ Commented Feb 21, 2016 at 3:03
  • 2
    $\begingroup$ You should use @user to ensure the user is notified. I was not attacking you, but what you said. That is by definition the opposite of ad hominem. The question is about Integrate, and I assume the answer is meant to explain how it works. The point of my comment was that what you said, supported by the code supplied, makes it seem that you think that Mathematica's Integrate cannot handle integrals over infinite intervals, which is wrong. If that is not what you meant, then maybe you should consider rephrasing your answer. $\endgroup$
    – Michael E2
    Commented Feb 21, 2016 at 4:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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