MATLAB Answers

Integral of bessel function returns all zeros

3 views (last 30 days)
besselfunc = @(x) besselk(5/3,x);
for n = 1:length(l)
xmin = 4*pi*Rc/(3*l(n)*gamma^3); % lower bound integral
K(n) = integral(besselfunc,xmin,Inf); %integral
end
I am trying to compute the integral of a Bessel function for all values of an array.
The issue is that the integral function always returns zero, so that K(n) is just an array of zeros. I have tried with other more simple functions instead of a Bessel function and it all works. I have also plotted the Bessel function and it seems correct. So what is going wrong here?
The formula for xmin contains some parameters but seems to work so disregard it.
Thanks for any help!

  0 Comments

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 11 Sep 2020
It is a really bad idea to use gamma as a variable name because you are now stepping on the name of a very useful function in MATLAB.
Regardless, we cannot tell you when you did, since you never give the value for that variable, nor for Rc or the vector l.
Odds are some of those variables are such that the lower limit of integration is relatively large. It need to be too huge for that integral to be zero anyway.
Consider that:
besselfunc(100)
ans =
4.7214e-45
besselfunc(1000)
ans =
0
What is the numerical integral of a function that is zero or effectively so over the entire domain of the integral? Even if the interval is infinite in width, integral will return zero.

  0 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!