how can I evaluate a four fold integral with four variables numerically ?
6 次查看(过去 30 天)
显示 更早的评论
i used the functions quad, dblquad, and triplequad to evaluate up to three integrals, but i need to evaluate 4 integrals, how can i do that?
2 个评论
Muthu Annamalai
2014-9-22
Can you separate the kernel of the integral? This is usally the better way to solve the problem. It also provides a computational speeds up to the solution as well from O(n^4) to say 2*O(n^2) if you can split kernel into a function (product?) of 2 double integrals.
HTH.
采纳的回答
Mike Hosea
2014-9-23
编辑:Mike Hosea
2014-9-23
There's one thing that people often find difficult: the requirement that the integrand accepts arrays and returns arrays, operating element-wise.
integral(@(x)integral3(@(y,z,w)f(x,y,z,w),ymin,ymax,zmin,zmax,wmin,wmax),xmin,xmax,'ArrayValued',true)
For smooth integrands over finite regions, a double integral of a double integral is usually a lot faster
integral2(@(x,y)arrayfun(@(x,y)integral2(@(z,w)f(x,y,z,w),zmin,zmax,wmin,wmax),x,y),xmin,xmax,ymin,ymax)
5 个评论
Mike Hosea
2014-9-29
You can't use integralN, but you should be able to do this:
quad2d(@(x,y)arrayfun(@(x,y)quad2d(@(z,w)f(x,y,z,w),zmin,zmax,wmin,wmax),x,y),xmin,xmax,ymin,ymax)
If your version is so old that you don't have QUAD2D, you can try this with DBLQUAD, but I don't recommend it. BTW, depending on how x and y are used in f(x,y,z,w), you might need to expand those arguments manually like so:
quad2d(@(x,y)arrayfun(@(x,y)quad2d(@(z,w)f(x*ones(size(z)),y*ones(size(z)),z,w),zmin,zmax,wmin,wmax),x,y),xmin,xmax,ymin,ymax)
更多回答(1 个)
Roger Stafford
2014-9-22
Set up a function which, when given the value of the outermost variable of integration, calculates the triple integral of the inner three iterated integrals for the particular value of that fourth variable. Then take the integral of the value of this newly-defined function over the appropriate limits for that fourth variable. There's nothing very difficult about that. Let the computer do all the hard work. You can expect it to take a fairly long time at it. That's inherent in doing integration in four dimensions.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!