matlab guide for Calculating 6 dimensional numerical integral Dosen't work
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mehdi Morshedi
am 19 Mär. 2024
Bearbeitet: Torsten
am 21 Mär. 2024
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 Kommentare
Dyuman Joshi
am 19 Mär. 2024
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.
Akzeptierte Antwort
Torsten
am 19 Mär. 2024
Bearbeitet: Torsten
am 19 Mär. 2024
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 Kommentare
Torsten
am 21 Mär. 2024
Bearbeitet: Torsten
am 21 Mär. 2024
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Calculus finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!