Integrals.jl
Integrals.jl copied to clipboard
Inf Integrand handling
Many of the quadrature algorithms do not handle Inf
in the integrand well.
QuadGK
throws a DomainError
, 2D or higher HCubature returns NaN
. Cubature has similar issues but at different dimensions (see https://github.com/JuliaMath/HCubature.jl/issues/29). Some Cuba methods seem to work, i.e. return Inf, while others segfault after a significant amount of computation time.
I'm not quite sure how to approach this issue. Seems like it should be handled upstream by the various algorithms, but this may be a big task to get cleaned up across the board.
I guess the surprising thing is that there are integrable singularities, but in practice if an algorithm encounters an infinity, it will either throw an error, give a NaN or Inf, or silently return an underconverged result depending on how proactive it is about numerical errors. I think the best we can do is provide informative return codes, which are currently available from SciMLBase but unused. @agerlach do you think that would address the issue?
I think that is probably the best solution.