Integrating quadruple integral ?

26 ビュー (過去 30 日間)
Tuong Nguyen Minh
Tuong Nguyen Minh 2021 年 5 月 9 日
回答済み: Tuong Nguyen Minh 2021 年 5 月 9 日
I am trying to integrate a quadruple integral with the following limit of integration
I am using the integralN.m function from Mike Hosea as follow
clear all;
syms w z y x real;
wmin = 0;
wmax = @(z) z;
zmin = 0;
zmax = @(y) y;
ymin = 0;
ymax = @(x) x;
xmin = 0;
xmax = Inf;
temp = -(x^2 + y^2 + z^2 + w^2)/2;
f_symbol = exp(temp);
f = matlabFunction(f_symbol)
q4 = integralN(f,wmin,wmax,xmin,xmax,ymin,ymax,zmin,zmax,'AbsTol',1e-5,'RelTol',1e-3)
And receive the following error
Error using integral2 (line 76)
XMAX must be a floating point scalar.
Error in integralN>integral4 (line 139)
q = integral2( ...
Error in integralN (line 92)
q = integral4(f,varargin{:});
Error in myprogram (line 34)
q4 = integralN(f,wmin,wmax,xmin,xmax,ymin,ymax,zmin,zmax,'AbsTol',1e-5,'RelTol',1e-3)
I am having a feeling that this error come from the order of integration wmin,wmax,xmin,xmax,ymin,ymax,zmin,zmax
So my second attempt is as follow
syms w z y x real;
wmin = 0;
wmax = @(z) z;
zmin = 0;
zmax = @(y) y;
ymin = 0;
ymax = @(x) x;
xmin = 0;
xmax = Inf;
temp = -(x^2 + y^2 + z^2 + w^2)/2;
f_symbol = exp(temp);
fun1 = matlabFunction(f_symbol,'Vars',[x,y,z,w])
q = integralN(fun1,xmin,xmax,ymin,ymax,zmin,zmax,wmin,wmax,'AbsTol',1e-3,'RelTol',1e-3)
This lead to another error
Error using myprogram>@(y)y
Too many input arguments.
Error in
integralN>@(x,y)integral2(@(z,w)f(x*ones(size(z)),y*ones(size(z)),z,w),zmin(x,y),zmax(x,y),@(z)wmin(x*ones(size(z)),y*ones(size(z)),z),@(z)wmax(x*ones(size(z)),y*ones(size(z)),z),varargin{9:end},method_override{:})
(line 135)
zmax(x,y), ...
Error in integralN>@(xv,yv)arrayfun(inner,xv,yv) (line 140)
@(xv,yv)arrayfun(inner,xv,yv), ...
Error in integral2Calc>@(y)fun(xi*ones(size(y)),y) (line 18)
@(y)fun(xi*ones(size(y)),y),y1i,y2i,opstruct.integralOptions), ...
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
integral2Calc>@(xi,y1i,y2i)integralCalc(@(y)fun(xi*ones(size(y)),y),y1i,y2i,opstruct.integralOptions)
(line 17)
innerintegral = @(x)arrayfun(@(xi,y1i,y2i)integralCalc( ...
Error in
integral2Calc>@(x)arrayfun(@(xi,y1i,y2i)integralCalc(@(y)fun(xi*ones(size(y)),y),y1i,y2i,opstruct.integralOptions),x,ymin(x),ymax(x))
(line 17)
innerintegral = @(x)arrayfun(@(xi,y1i,y2i)integralCalc( ...
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 83)
[q,errbnd] = vadapt(@AToInfInvTransform,interval);
Error in integral2Calc>integral2i (line 20)
[q,errbnd] = integralCalc(innerintegral,xmin,xmax,opstruct.integralOptions);
Error in integral2Calc (line 7)
[q,errbnd] = integral2i(fun,xmin,xmax,ymin,ymax,optionstruct);
Error in integral2 (line 106)
Q = integral2Calc(fun,xmin,xmax,yminfun,ymaxfun,opstruct);
Error in integralN>integral4 (line 139)
q = integral2( ...
Error in integralN (line 92)
q = integral4(f,varargin{:});
Error in myprogram (line 36)
q = integralN(fun1,xmin,xmax,ymin,ymax,zmin,zmax,wmin,wmax,'AbsTol',1e-3,'RelTol',1e-3)
Please help me overcome this issue
Thank you for your enthusiasm !

採用された回答

Tuong Nguyen Minh
Tuong Nguyen Minh 2021 年 5 月 9 日
I have been able to deduce the answer after much frustration. The corresponding syntax should be
clear all;
clc;
syms w z y x real;
wmin = 0;
wmax = @(x,y,z) z;
zmin = 0;
zmax = @(x,y) y;
ymin = 0;
ymax = @(x) x;
xmin = 0;
xmax = Inf;
temp = -(x*x + y*y + z*z + w*w)/2;
f_symbol = exp(temp);
fun1 = matlabFunction(f_symbol,'Vars',[x,y,z,w])
q = integralN(fun1,xmin,xmax,ymin,ymax,zmin,zmax,wmin,wmax,'AbsTol',1e-3,'RelTol',1e-3)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Computations についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by