Search code examples
c++matlabnumerical-methodsnumerical-integration

evaluating multiple integrals


Is there any library to evaluate multidimensional integrals? I have at least 4 (in general much more than that), where the integrand is a combination of variables, so I cannot separate them. Do you know of any library for numerical evaluation? I'm especially looking for either matlab or c++, but I will use anything that will do the work.


Solution

  • Since you don't specify the kind of integrals or the actual dimensionality, I can only suggest that you take into account that

    $\int_A \int_B f(x, y) \, \mathrm{d} x \, \mathrm{d} y = \int_A F(x) \, \mathrm{d} x$

    where the function F(x) is defined as

    $x \mapsto F(x) = \int_B f(x, y) \, \mathrm{d} y$

    and use this fact to compute your integrals with the usual quadrature techniques. For example, you could use trapz or quad in MATLAB. However, if the dimensionality is truly high, then you are better off using Monte Carlo algorithms.