Search code examples
pythonalgorithmmathintegral

How do I integrate a multivariable function?


I have a function f(x_1, x_2, ..., x_n) where n >= 1 that I would like to integrate. What algorithm should I use to provide a decently stable / accurate solution?

I would like to program it in Python so any open source examples are more than welcome!

(I realize that I should use a library but this is just a learning exercise.)


Solution

  • It depends on your context and the performance criteria. I assume that you are looking for a numerical approximation (as opposed to a algebraic integration) A Riemann Sum is the standard 'educational' way of numerically calculating integrals but several computationally more efficient algorithms exist.