matlab guide for Calculating 6 dimensional numerical integral Dosen't work
23 次查看(过去 30 天)
显示 更早的评论
How should I calculate 6 dimentinal numerical integration in matlab? my first try failed as below code :
I Know this problem can be solved symbolicly. but i need to calculate integral of a very complicated 6-D integral. which its integrand has product term of bessel fuctions, sin functions and exponential functions. and this simple example will guide me to solve that question.
My code in based on guide for 4-D numercal integration in https://nl.mathworks.com/help/matlab/ref/integral3.html which matlab stated : "The integral quadrature functions in MATLAB® directly support 1-D, 2-D, and 3-D integrations. However, to solve 4-D and higher order integrals, you need to nest calls to the solvers."
but matlab guide dosen't work ??!!
f = @(x,y,u,t,v,r) x*y*u*t*v*r ;
xmin = 0 ;
xmax = 1 ;
ymin = 0 ;
ymax = @(x) x;
umin = 0 ;
umax = @(x,y) x+y;
tmin = 0;
tmax = @(x,y,u) x+y+u;
vmin = 0;
vmax = @(x,y,u,t) x+y+u+t;
rmin = 0;
rmax = @(x,y,u,t,v) x+y+u+t+v;
Q1 = @(x,y,u) integral3(@(t,v,r) f(x,y,u,t,v,r) ,tmin,tmax,vmin,vmax,rmin,rmax)
Q2 = integral3(@(x,y,u) Q1(x,y,u) ,xmin,xmax,ymin,ymax,umin,umax)
5 个评论
Dyuman Joshi
2024-3-19
As I mentioned above - When using integral3, you need to provide atleast 1 set of limits as numbers.
And, the example you linked uses numerical limits, not function handles.
What exactly are you trying to do? It would be helpful if you could specify the objective and provide more information.
采纳的回答
Torsten
2024-3-19
编辑:Torsten
2024-3-19
tmax in Q1 must be a scalar, not a function handle.
Try "integralN":
f = @(x,y,u,t,v,r) x.*y.*u.*t.*v.*r ;
xmin = 0 ;
xmax = 1 ;
ymin = 0 ;
ymax = @(x) x;
umin = 0 ;
umax = @(x,y) x+y;
tmin = 0;
tmax = @(x,y,u) x+y+u;
vmin = 0;
vmax = @(x,y,u,t) x+y+u+t;
rmin = 0;
rmax = @(x,y,u,t,v) x+y+u+t+v;
value = integralN(f,xmin,xmax,ymin,ymax,umin,umax,tmin,tmax,vmin,vmax,rmin,rmax,'AbsTol',1e-5,'RelTol',1e-3)
2 个评论
Torsten
2024-3-21
编辑:Torsten
2024-3-21
Within integralN, the 6-fold integration is done by using MATLAB's integral2 three times.
But if think you can do better than Mike Hosea from the MATLAB staff (e.g. by using integral3 two times or something similar), you are invited.
I tried your example for the 5-fold problem, and the integral was solved quite fast (1.5 min) with Mike Hosea's code. But - as noted in the documentation to the code - 6-fold integrals can take much longer.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calculus 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!