Integral of bessel function returns all zeros

조회 수: 3 (최근 30일)
Alessandro Sona
Alessandro Sona 2020년 9월 11일
답변: John D'Errico 2020년 9월 11일
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!

채택된 답변

John D'Errico
John D'Errico 2020년 9월 11일
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개)

카테고리

Help CenterFile Exchange에서 Bessel functions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by