How to do numerical multiple integral (more than triple)?

强颜欢笑 提交于 2020-01-07 07:48:42

问题


How to do numerical multiple integral (more than triple) by using Matlab?

For example, I have a function,Y = Func. It has 5 var. Hence, Y= func(a,b,c,d,e). If I want to do the integration with respect to a,b,c,d,e. (var a is the first one, e is the last one.) And region of a = [0 ,b] (this is a function handle), b = [0,c], c= [0.d], d= [0,e], e=[0, Inf].

Now, here is my 'real' question. The code is below

%%%==== just some parameters ====
a=4;
la1=1/(pi*500^2); la2= la1*5;
p1=25; p2=p1/25;
sgma2=10^(-11);
index=1;
g=2./a;
syms r u1 u2 u3 u4 u5
index = -2;  
    powe= index ;
    seta= 10^powe;
    xNor = ( (u5./u1).^(a./2)+ (u5./u2).^(a./2) + (u5./u3).^(a./2)+ (u5./u4).^(a./2) + 1    ).^(2./a);
    x = (xNor).^(0.5) * seta^(-1/a);
    q=pi.*(la1.*p1.^(2./a)+la2.*p2.^(2./a));
%%%====  parameters end ====   

      fun1 =  r./(1+ r.^a );

   out1 = int(fun1, x, Inf) ;
 out1fcn = matlabFunction(out1); %%===Convert symbolicto function handle 

 y  = @(u5,u4,u3,u2,u1) exp(-u3.*(1+2.*... %%<== in method 3, replace as 'y= exp(-u3.*(1+2.*...' 
    (  out1fcn   )./... %%<== in method 3, replace as '(  out1   )./...' 
          (  (( (u5./u1).^(a./2)+ (u5./u2).^(a./2) + (u5./u3).^(a./2)+ (u5./u4).^(a./2) + 1    ).^(2./a)).*seta.^(-2./a)))).*...
          exp(-sgma2.*q.^(-a./2).* seta.*u3.^(a./2)./...
          ((( (u5./u1).^(a./2)+ (u5./u2).^(a./2) + (u5./u3).^(a./2)+ (u5./u4).^(a./2) + 1    ).^(2./a)).^(a./2))  );

%%%=== method 1, not working ============ upper ,lower bound should be a number
%      y1 =   integral(  y  ,0,@(u2) u2);  
%      y2 =   integral(  y1 ,0,@(u3) u3); 
%      y3 =   integral(  y2 ,0,@(u4) u4); 
%      y4 =   integral(  y3 ,0,     Inf);     

%%%=== method 2, not working, y1 is already wrong  =============== 
%%%Undefined function 'minus' for input arguments of type 'function_handle'.
%      y1 =   quad(  y  ,0,@(u2) u2);  
%      y2 =   quad(  y1 ,0,@(u3) u3); 
%      y3 =   quad(  y2 ,0,@(u4) u4); 
%      y4 =   quad(  y3 ,0,     Inf);     

%%%=== method 3. not working, DOUBLE cannot convert the input expression into a double array. ==============
%      y1 =   int(  y  ,0,@(u2) u2);  
%      y2 =   int(  y1 ,0,@(u3) u3); 
%      y3 =   int(  y2 ,0,@(u4) u4); 
%      y4 =   int(  y3 ,0,     Inf);     
%      y5 =   double(y4)

回答1:


A Google search showed that it is possible that by 2011 there was no standard numerical option available. This is a library you could consider. Finally, how about using Monte Carlo?




回答2:


It would depend on if your function is defined symbolically or otherwise. However, if it is defined symbolically then five nested int functions would do the trick.



来源:https://stackoverflow.com/questions/27681213/how-to-do-numerical-multiple-integral-more-than-triple

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!