# Integration including bessel function

I’m trying to evaluate an improper integral of a 0th order Bessel function of the first kind using Matlab:

v = integral(@(x)besselj(0, x), 0, Inf)


which returns v = 3.7573e+09. However, this should be 1, in theory. What should I do to get 1 in the Matlab?

• I assume that you also receive a warning, as I do in R2015a, that the "limit on the maximum number of intervals" has been reached and that "it may be difficult to approximate numerically to the requested accuracy"? If so, edit your question, to provide the full warning message. Do you want to do this numerically, or are symbolic solutions acceptable? Since you know what the answer is, this might seem pointless, but I'm guessing it relates to this Math.StackExchange question? – horchler Mar 9 '15 at 19:03
• yes, actually this related to that question that I asked. I am the same person ;). I know the answer just for specific inputs not for every inputs. this is the analytical solution of one specific problem that I've already solve numerically and by solving this equation numerically I want to compare with my numeric method. but unfortunately I'm sure that the answer in wrong here. as I said in the question – Rasa Mar 10 '15 at 20:09

The problem is that you are integrating an oscillatory function over an infinite interval. The MATLAB website doesn't give specifics on the algorithm behind their integral function (it just says 'globally adaptive'). The older quad function used to be adaptive Simpson, so I can assume that integral is the same. What probably is happening is that the code transforms the interval $[0,\infty]$ to $[0,1]$ or $[-1,1]$ or so and hence it is squeezing all the oscillations in this interval. As a result it is adding a lot of positive contributions and subtracting a lot of negative contributions. Hence a totally wrong answer.
Finally, since you already know the correct answer to your integral, why do it numerically? Just to understand why integral fails or is there a bigger picture?