# What is the best state-of-the-art numerical integral algorithm?

I'm trying to implement a numerical integrator that should have the minimum relative error and is not slow. So I was looking for the best accepted state-of-the-art algorithm to do so but there seems to be so many approaches that I could not understand which one should I choose. So I'm turning to you for a recommendation.

Thank you for your attention,

-
I suggest you try adaptive quadrature. –  lhf Apr 17 '12 at 12:30
There is no such thing as "one algorithm to evaluate them all". Methods for "nice integrals" are quite different from methods for, say, infinite oscillatory integrals, or Cauchy principal value integrals. That's why there are a lot of algorithms, since families of integrals might carry their own unique set of difficulties. –  Ｊ. Ｍ. Apr 17 '12 at 12:31
Yes, and that is precisely the route taken by packages like QUADPACK... –  Ｊ. Ｍ. Apr 17 '12 at 13:10
Offhand: check for singularities. Improper integrals often require special methods. Functions with rapidly decaying or very oscillatory factors also need special treatment. Discontinuous functions require splitting at discontinuities. Everything else is fair game for adaptive quadrature. –  Ｊ. Ｍ. Apr 17 '12 at 13:37
Well, not my fault that you weren't specific at the outset, no? Efficient cubature methods remain an active area of research, and unless you have the expertise, I caution against rolling out your own implementation. You will want to look at the work already done by Ronald Cools and Terje Espelid. –  Ｊ. Ｍ. Apr 17 '12 at 13:47
show 4 more comments

## 1 Answer

As @J.M noted, there are many methods, each suited for a certain purpose. If you don't know what the function are in advance, then for low-dimensional ($d < 3$) integrals a adaptive Gauss–Kronrod rule quadrature is probably the fastest.

In higher dimensions, you can really only use Monte-Carlo methods.

If know apriori that the functions have a very large range, you can use a weighted Monte-Carlo approach, in which you select more points in the "large" regions, than in the "smaller" ones.

-
Double-exponential quadrature is claimed to be competitive with adaptive Gauss-Kronrod for "smooth enough" integrals, or integrals with endpoint singularities that aren't too "wild". I haven't done tests myself to confirm this, but I'm putting it out here in case somebody's inclined to play around a bit. –  Ｊ. Ｍ. Apr 17 '12 at 13:06
@J.M - Thanks for the info, I wasn't familiar with that method. The Wiki article claims that "Tanh-sinh quadrature is less efficient than Gaussian quadrature for smooth integrands, but unlike Gaussian quadrature tends to work equally well with integrands having singularities or infinite derivatives at one or both endpoints of the integration interval." –  nbubis Apr 17 '12 at 13:40
In any case, if the OP wants $d > 3$, neither of these will work. –  nbubis Apr 17 '12 at 13:42
Right, cubature is a different can of worms. There is Genz-Malik and a number of other multidimensional methods for a very restricted class of multiple integrals, but indeed as you say, (quasi-)Monte Carlo is something to be contented with for most problems. –  Ｊ. Ｍ. Apr 17 '12 at 13:45
add comment