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

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

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.


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.