Closed jmarcellopereira closed 6 years ago
Putting in a huge number for the integration limit is a terrible way to do improper integrals numerically, because any quadrature scheme will initially sample the integrand extremely coarsely over the interval and will probably get fooled, e.g. if the integrand decays rapidly. (In this case, both quadgk
and hquadrature
are using the same Gauss–Kronrod quadrature schemes IIRC, but I think they default to different orders.)
A better way to do improper integrals is to do a coordinate transformation to a finite interval, as explained here: https://github.com/stevengj/cubature#infinite-intervals … if you do quadgk(f9, 1, Inf)
, the quadgk
routine will do this coordinate transformation for you automatically.
(There are other fancier methods, e.g. Gauss–Laguerre quadrature, but they depend upon you knowing the asymptotic decay rate of your integrand.)