This page is no longer maintained — Please continue to the home page at

Recursive formulation of multi-dimensional integration

No replies
felix 2
Joined: 2011-12-14,
User offline. Last seen 42 years 45 weeks ago.

Dear all,

I wonder whether it is possible to give a recursive formulation for
the multi-dimensional integration function. The idea is to define the
most inner integral as a function in dim-1 parameters. Proceeding in a
recursive way, one should end up with a 1-dimensional integral, which
can be solved easily.

The challenge is that I cannot access the Array parameter of function
f. Therefore I cannot define a new function on a subset of parameters
of it.

Does anyone know a solution?

Thanks and regards


def integrate( f: (Double) => Double, a : Double, b: Double, n: Int) :
Double = {
// n is some approximation parameter
// a and b are lower and upper bounds, respectively
// do 1-d integration
// res = \int_a^b f(x)dx
// solved


def integrate (f: (Array[Double]) => Double, a: Double, b: Double,
n: Int, m: Int) : Double = {
if (m == 1) {
def g(x: Double) : Double = f(Array(x))
else {
//recursively call integrate(\int_a^b g(x_2,...,x_m) dx_2,...dx_m )

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland