Support for multidimensional array-valued integration in scipy.integrate

Hi everyone,

As part of my internship at Quansight Labs this summer and under mentorship from @izaid and @ev-br, I’ve just made a pull request implementing some enhancements to scipy.integrate:

This addresses some comments made earlier in March about extending the support for multidimensional integration of array-valued functions:

In summary, this is done by adding a new function, scipy.integrate.cub, which works to resolving some of the comments raised in that discussion by:

  • Supporting array-valued multidimensional integrands (and scalar/1D integrals as a special case).
  • Using an adaptive algorithm implemented in Python similar to quad_vec, with the eventual goal of supporting the array API. This works by subdividing the region being integrated until a tolerance is reached, rather than computing iterated 1D integrals as is currently done by dblquad, tplquad and ndquad.
  • Allowing custom integration rules, which are classes with an estimate(f, a, b) method and an estimate_error(f, a, b) method. There is built-in support for Cartesian products of 1D rules like Newton-Cotes, Gauss-Legendre, Gauss-Kronrod, and support for “true cubature” rules like Genz-Malik which only work in more than one dimensions. It also has methods available to let users write their own rules (these are currently private and located in scipy/integrate/_rules.

More detail on the specifics of the changes and the new interface can be found in the PR. Currently yet to be supported is:

  • Infinite endpoints
  • Accepting a points parameter like quad_vec
  • Broadcastable endpoints
  • Non-rectangular regions

but depending on how much further work is required for this PR, it is our hope that this can all be implemented by the end of September.

Any feedback from the community about these changes and any suggestions for improvements is definitely welcome here or in the PR. And of course I am happy to answer any questions anyone might have. Thanks for taking a look!

3 Likes