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.
Bugs
tag applies imo. $\endgroup$2 Cos[1]
). With version 5.2 I get theIntegrate::idiv
message and the integral returns unevaluated. $\endgroup$