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 Center および File ExchangeBessel functions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by