quadax.rombergts

quadax.rombergts(fun: Callable[[...], Array], interval: Array | ndarray | bool | number | bool | int | float | complex, args: tuple = (), full_output: bool = False, epsabs: Array | ndarray | bool | number | bool | int | float | complex | None = None, epsrel: Array | ndarray | bool | number | bool | int | float | complex | None = None, divmax: int = 20, norm: float | int | Callable[[Array], Array] = inf)Source

Romberg integration with tanh-sinh (aka double exponential) transformation.

Returns the integral of fun (a function of one variable) over interval.

Performs well for functions with singularities at the endpoints or integration over infinite intervals. May be slightly less efficient than quadgk or quadcc for smooth integrands.

Parameters:
  • fun (callable) – Function to integrate, should have a signature of the form fun(x, *args) -> float, Array. Should be JAX transformable.

  • interval (array-like) – Lower and upper limits of integration. Use np.inf to denote infinite intervals.

  • args (tuple) – additional arguments passed to fun

  • full_output (bool, optional) – If True, return the full state of the integrator. See below for more information.

  • epsabs (float) – Absolute and relative tolerances. If I1 and I2 are two successive approximations to the integral, algorithm terminates when abs(I1-I2) < max(epsabs, epsrel*|I2|). Default is square root of machine precision.

  • epsrel (float) – Absolute and relative tolerances. If I1 and I2 are two successive approximations to the integral, algorithm terminates when abs(I1-I2) < max(epsabs, epsrel*|I2|). Default is square root of machine precision.

  • divmax (int, optional) – Maximum order of extrapolation. Default is 20. Total number of function evaluations will be at most 2**divmax + 1

  • norm (int, callable) – Norm to use for measuring error for vector valued integrands. No effect if the integrand is scalar valued. If an int, uses p-norm of the given order, otherwise should be callable.

Returns:

  • y (float, Array) – Approximation to the integral

  • info (QuadratureInfo) – Named tuple with the following fields:

    • err : (float) Estimate of the error in the approximation.

    • neval : (int) Total number of function evaluations.

    • status : (int) Flag indicating reason for termination. status of 0 means normal termination, any other value indicates a possible error. A human readable message can be obtained by print(quadax.STATUS[status])

    • info : (dict or None) Other information returned by the algorithm. Only present if full_output is True. Contains the following:

      • table : (ndarray, size(dixmax+1, divmax+1, …)) Estimate of the integral from each level of discretization and each step of extrapolation.

Notes

Due to limitations on dynamically sized arrays in JAX, this algorithm is fully sequential and does not vectorize integrand evaluations, so may not be the most efficient on GPU/TPU.

Also, it is currently only forward mode differentiable.