Slow cubature

This is not a static array, which will slow down everything because it will make your integrand allocating. Try to make sure your integrand is non-allocating for SVector arguments t. (Also make t_lb and t_ub static arrays or tuples.)

That said, this might be a situation where a specialized quadrature scheme like Hermite–Gauss quadrature may be be a good idea, to avoid the singularity you are introducing from the coordinate transformation for an infinite domain. (Using a non-adaptive method requires some manual tuning of the number of quadrature points, however.)

It might be worthwhile to change to N-d spherical coordinates so that only one (radial) coordinate has singular endpoints.

PS. Type assertions like t::Union{Real, AbstractVector} probably accomplish nothing.

2 Likes