# Benchmark of numerical integration packages for multi-dimensional integration

**URL:** <https://discourse.julialang.org/t/benchmark-of-numerical-integration-packages-for-multi-dimensional-integration/44273>\
**Category:** Numerics\
**Created:** [August 4, 2020, 4:27pm UTC](https://discourse.julialang.org/t/benchmark-of-numerical-integration-packages-for-multi-dimensional-integration/44273 "2020-08-04T16:27:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mleprovost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mleprovost/32/7166_2.png) [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Post date:** [August 4, 2020, 4:27pm UTC](https://discourse.julialang.org/t/benchmark-of-numerical-integration-packages-for-multi-dimensional-integration/44273/1 "2020-08-04T16:27:09Z")

</div>

Hello,

I need to integrate a vector valued function F: \mathbb{R} \xrightarrow{} \mathbb{R}^n, with n \sim 5000 over [0.0, 1.0]. I don’t need to very accurate result, an error estimate of 1e-6 is sufficient for my application, but I need the fastest integration possible.

There are a lot of packages for numerical integrations in Julia: FastQaussQuadrature, QuadGK, Cuba, Cubature, HCubature, Quadrature…

Is there a benchmark for these different packages?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [August 4, 2020, 4:55pm UTC](https://discourse.julialang.org/t/benchmark-of-numerical-integration-packages-for-multi-dimensional-integration/44273/2 "2020-08-04T16:55:42Z")

</div>

Look at [https://github.com/SciML/Quadrature.jl](https://github.com/SciML/Quadrature.jl). It just wraps them all in one interface so you can flip through and benchmark them quite easily. We haven’t done the benchmarking yet, but that would be a nice thing to do and then just get a JOSS paper out, so if you want to join in on that let us know.

---

<div class="post-metadata">

**Author:** ![mleprovost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mleprovost/32/7166_2.png) [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Post date:** [August 4, 2020, 4:59pm UTC](https://discourse.julialang.org/t/benchmark-of-numerical-integration-packages-for-multi-dimensional-integration/44273/3 "2020-08-04T16:59:41Z")

</div>

Thanks Chris, I will look for Quadrature.jl !

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 5, 2020, 9:50am UTC](https://discourse.julialang.org/t/benchmark-of-numerical-integration-packages-for-multi-dimensional-integration/44273/4 "2020-08-05T09:50:36Z")

</div>

I am not sure you need any fancy methods if your function is “nice” enough (smooth, differentiable) since the domain is the real line.

The first thing I would try is Gaussian quadrature with FastGaussQuadrature: calculate nodes & weights _once_, then evaluate F on the nodes, and just use a matrix product (or dot product of vectors, depending on how your formulate it).

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [August 5, 2020, 10:33am UTC](https://discourse.julialang.org/t/benchmark-of-numerical-integration-packages-for-multi-dimensional-integration/44273/5 "2020-08-05T10:33:11Z")

</div>

I’d also note that benchmarks highly depends on the characteristics of the integrand function, it’s hard to provide benchmarks that cover all possible cases. As an example, among the methods provided by `Cuba.jl`, `cuhre` _tends_ to be the fastest and most accurate one in many cases, but if the function has some very sharp peaks whose position is known, `divonne` is a much better choice as you can provide the position of the peaks in order to increase sampling around them (to be honest, I’ve never used this feature in `Cuba.jl` even though it should be somewhat exposed, I did it some years ago with the Fortran library).

To summarise, you should really benchmark the different methods with your integrand function.
