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

5 次查看(过去 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