Numerical integration of a nested integral; limits of inner integral depend on the outer integration variable

조회 수: 7 (최근 30일)
I have 2 nested integrals. I want to integrate a bessel function multiplied by x. And the integration limits depend on the integration variable of the outer intergral.
The outer integral should go till inf. But for simplification i set it to 1e6.
The following code is a example code, which doesnt work. because the integration limits arent scalar values.
This integral doesnt habe a analytical solution so i cant simplify it.
How can i change my implementation to solve this problem?
Thank you!
Bessel_integrand = @(x) x .* besselj(0,x);
Integrand_B = @(a) integral(Bessel_integrand,a * 1, a * 2);
result = integral ( Integrand_B, 0 , 1e6);
Error using integral
Limits of integration must be double or single scalars.

Error in solution (line 2)
Integrand_B = @(a) integral(Bessel_integrand,a * 1, a * 2);

Error in integralCalc/iterateScalarValued (line 314)
fx = FUN(t);

Error in integralCalc/vadapt (line 132)
[q,errbnd] = iterateScalarValued(u,tinterval,pathlen);

Error in integralCalc (line 75)
[q,errbnd] = vadapt(@AtoBInvTransform,interval);

Error in integral (line 87)
Q = integralCalc(fun,a,b,opstruct);

답변 (1개)

Torsten
Torsten 2023년 3월 8일
편집: Torsten 2023년 3월 8일
I'm not sure your integral exists ...
Bessel_integrand = @(x) x .* besselj(0,x);
Integrand_B = @(a) integral(Bessel_integrand,a, 2*a)
Integrand_B = function_handle with value:
@(a)integral(Bessel_integrand,a,2*a)
result = integral(Integrand_B,0,1000,'ArrayValued',true)
result = 17.1918
  댓글 수: 1
Martin
Martin 2023년 3월 8일
Thanks for the answer! Yes this integral doesnt exist. I forgot a very important part of my simplified code.
Now it works!
Bessel_integrand = @(x) x .* besselj(0,x);
Integrand_B = @(a) integral(Bessel_integrand,a, 2*a).^2 * 1/a^4
Integrand_B = function_handle with value:
@(a)integral(Bessel_integrand,a,2*a).^2*1/a^4
result = integral(Integrand_B,0,1000,'ArrayValued',true)
result = 1.8843

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

카테고리

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