quadax.STATUS

class quadax.STATUS(value)Source

Reason a quadrature terminated.

Each member is the integer code the routine reports, and carries the message explaining it. QuadratureInfo.status is that integer, so it can be compared against a member, read as an int, or held in an array under vmap.

Codes run from least to most severe, and a run that meets more than one condition reports the most severe of them. The order is what a reader should do about each.

The message is the member’s message, and is what printing the member shows:

>>> y, info = quadgk(fun, [0, 1])
>>> if info.status != STATUS.normal:
...     print(STATUS[info.status])

Members

normal (code 0)

Normal convergence. The estimated error fell below the requested tolerance.

max_ninter (code 1)

The subdivision used all max_ninter sub-intervals without reaching the tolerance. The value returned is the total over the mesh it ended with, and the reported error is that mesh’s own estimate for it. Raising max_ninter helps if the subdivision was still making progress; where the integrand has a singularity or a jump at a known point, passing that point in interval as a breakpoint is worth more, since the mesh no longer has to find it.

max_nregion (code 2)

The subdivision used all max_nregion regions without reaching the tolerance. The value returned is the total over the mesh it ended with, and the reported error is that mesh’s own estimate for it. A box is cut along one axis at a time, so resolving a feature that is a surface rather than a point costs regions in proportion to how finely the axes along it must be divided, and raising max_nregion helps only if the subdivision was still making progress. Where the integrand has a singularity or a jump on a known axis aligned plane, passing that coordinate in interval as a breakpoint on its axis is worth more, since the mesh no longer has to find it.

max_divisions (code 3)

The schedule used all divmax refinement levels without reaching the tolerance. A Romberg mesh halves the whole interval uniformly and cannot refine near a difficulty, so an integrand with a local feature is better given to quadgk or quadcc.

no_converge (code 4)

The convergence acceleration stopped making progress: six extrapolations in a row produced nothing better than the one already held, while claiming an error far below what the subdivision reports. The best of them is returned, with its error widened to cover how far the later ones moved away from it. The running totals most likely have no asymptotic form for the extrapolation to fit.

truncation (code 5)

The tanh-sinh map leaves more of the integral outside the range its abscissae cover than the tolerance allows, so refining further cannot reach it. This is a property of the map in finite precision rather than of the mesh, and more levels would only spend evaluations arriving at the same answer. The reported error includes an estimate of what the map omits and remains a bound on the value returned; it is the tolerance that is out of reach. Using higher precision may allow lower error.

bad_integrand (code 6)

Subdivision drove sub-intervals down to a width of order the floating point spacing across the interval, where the abscissae within one can no longer be told apart, so the mesh cannot localize the difficulty any further. This is what a non-integrable singularity looks like, or a feature narrower than the abscissae can resolve. Check that the integral exists, and that any singularity or discontinuity sits at a limit or a breakpoint rather than in the interior of a sub-interval.

roundoff (code 7)

The achievable accuracy is limited by roundoff. Subdivision has stopped buying accuracy: the error estimate has reached the floor the arithmetic imposes, or the total stopped moving while its error stayed where it was. The tolerance asked for is below what the integrand can be summed to at this precision. The reported error may be understated, being built from the same arithmetic that has bottomed out. Try loosening tolerances, or use higher precision.

divergent (code 8)

The integral is suspected to be divergent, either because the extrapolated value bears no relation to the running total it was built from, or because that total left the range of the arithmetic. A finite value may still be returned, but do not use it without establishing that the integral converges.