Matlab Numerical integral improvement

조회 수: 6 (최근 30일)
Shan  Chu
Shan Chu 2017년 2월 4일
편집: Karan Gill 2017년 10월 17일
Hi, I have the integral below:
F_A_I=@(x) besselj(1,x.*3.5).*besselj(1,x.*0.5);
A=integral(F_A_I,0,Inf,'RelTol',1e-6,'AbsTol',1e-12,'ArrayValued',true);
But Matlab said:
Warning: Reached the limit on the maximum number of intervals in use. Approximate bound on error is 1.7e+00. The integral may not exist, or it may be difficult to approximate numerically to the requested accuracy.
while Mathematica can give the answer straightforward A=0.0205664
Could you please help me to improve my code. Thanks
  댓글 수: 1
Niels
Niels 2017년 2월 4일
probably a definition gap in your function, integral might converge to inf, in these cases matlab displays -> Reached the limit on the maximum number of intervals in use.

댓글을 달려면 로그인하십시오.

채택된 답변

Karan Gill
Karan Gill 2017년 2월 13일
편집: Karan Gill 2017년 10월 17일
Updated answer for R2017b. Use int and convert the symbolic solution to floating point.
>> syms x
f = int(besselj(1, x/2)*besselj(1, (7*x)/2),x,0,inf)
f =
-(4*(100*ellipticE(1/49) - 99*ellipticK(1/49)))/(21*pi)
>> f_dbl = double(ans)
f_dbl =
0.0022
>> f_vpa = vpa(f)
f_vpa =
0.0022054352588140668793354496265733
OLD ANSWER from 13-Feb-2017
The convert to double using "double".
  댓글 수: 2
Walter Roberson
Walter Roberson 2017년 2월 14일
편집: Walter Roberson 2017년 2월 14일
vpaintegral() with up to 10000 MaxFunctionCalls complains it cannot reach required precision.
The ratio oscillates a lot.
Karan Gill
Karan Gill 2017년 9월 25일
Updated answer with solution starting R2017b.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by