# Why does Mathematica report that $\int_1^\infty\frac{\sin(\sqrt{x})}{\sqrt{x}}dx$ = $2\cos(1)$?

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,

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


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

Edit

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}$

• 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. – J. M.'s discontentment Feb 11 '16 at 13:08
• WolframAlpha returns the same. – thedude Feb 11 '16 at 13:23
• The Bugs tag applies imo. – george2079 Feb 11 '16 at 17:03
• @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. – Alexey Popkov Feb 12 '16 at 7:53
• @VadimPonomarenko what are you expecting for your bounty? – george2079 Feb 19 '16 at 15:22

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 InternalIntegratedebugSwitch,

Block[{InternalIntegratedebugSwitch = 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

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


if you compare it with

Trace[
Integrate[Exp[-x], {x, 1, ∞}],
_Limit,
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.

• 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 – J. M.'s discontentment Feb 21 '16 at 2:22
• @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.) – Michael E2 Feb 21 '16 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.

• 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. – Michael E2 Feb 21 '16 at 0:18
• 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["IntegrateImproperDump*"] 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. – Schopenhauer Feb 21 '16 at 3:03
• 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. – Michael E2 Feb 21 '16 at 4:12