Numerical multidimensional integration over function of six variables

WraithM
Messages
32
Reaction score
0
So, I'm writing a program in matlab. I have a function of six variables, say f(x1,x2,x3,x4,x5,x6). I want to integrate over x4, x5, and x6 numerically. f is defined over a 10 sided 6-cube of points. I also want to integrate over the whole cube.

So I want,

F(x_1, x_2, x_3) = \int\int\int f(x_1, x_2, x_3, x_4, x_5, x_6) dx_4 dx_5 dx_6

Does anybody have a hint to get me started down some path? I'm really stuck. It's sort of an insane problem.

The internet seems to point me toward monte carlo integration. These methods handle multidimensional integrals well apparently. Can monte carlo methods handle my problem of not integrating over all 6 dimensions? I don't know why I think monte carlo wouldn't, but if so, does anybody have an idea of how to do this? I'm not an expert in numerical integration at all. I'm also not opposed to turning this project into a C program or Mathematica or something. Anything that will solve the problem would be much appreciated!
 
Physics news on Phys.org
In what form do you have f? Is it an analytic function that could be integrated analytically? Or is it a numeric table? In either case, why can't you just discretize the function, multiply by the volume element dx4 dx5 dx6 and add up the contribution from all of the little cubes? You would basically be evaluating the sum:
\sum_{x4_{min}}^{x4^{max}}\sum_{x5_{min}}^{x5^{max}}\sum_{x6_{min}}^{x6^{max}}f(x1,x2,x3,x4,x5,x6)\Delta x4 \Delta x5 \Delta x6
 
For 3 or more dimensions, Monte Carlo is faster than straightforward method (suggested by phyzguy).
 
Thank you for the replies!

I have it stored in a 6D array. I've considered the way that phyzguy suggested. It seems that method would take a very long time. I've got a grid of a 10^6 points on it, but this method would be extremely easy to implement. It'd be like 5 - 6 lines of code in Matlab, tops. It would not scale well with size at all... If I make the size of the 6-cube larger by even 1, the time the problem would take goes up tremendously. It goes up as O(N^d). Where N is the size of one side of the cube, and d is the dimension. If I can't figure out monte carlo integration, I will definitely do this, but I want to avoid this method if at all possible.

Mathman, do you have any suggestions on how to implement the monte carlo integration? I have only a rough idea of what monte carlo integration even is, let alone how to implement it in higher dimensions. Could you give me a rough outline of what my algorithm should look like? Your description may be very rough.

If not, do you have a suggestion on a website, already implemented package, or book where I could learn how to do this?

Thank you again!
 
Last edited:
WraithM,

You're not doing an entirely numerical calculation since some of the variables remain as variables. It's best if you reveal the specific function that you are integrating so you can get advice about how to handle the symbolic part of the calculation.
 
Back
Top