dequad#

jeanspy.dequad.dequad

jeanspy.dequad.dequad(func, a, b, n, axis=-1, xp=<module 'numpy' from '/home/runner/work/jeanspy/jeanspy/.venv/lib/python3.12/site-packages/numpy/__init__.py'>, replace_inf_to_zero=False, replace_nan_to_zero=False, reshape_ws=None, verbose=False)[source]#

Integrate a vectorized function with fixed double-exponential nodes.

Parameters:
  • func (callable) – Receives nodes of shape (n,) and returns values whose integration axis has length n. For output (m, n), the default axis works.

  • a (float) – Integration limits in the input coordinate’s units. Supported domains are finite intervals, (a, +inf) and the two-sided infinite line.

  • b (float) – Integration limits in the input coordinate’s units. Supported domains are finite intervals, (a, +inf) and the two-sided infinite line.

  • n (int) – Number of nodes; use at least two and check refinement explicitly.

  • axis (int, optional) – Axis summed in the function output, default -1.

  • xp (module, optional) – Array namespace for node construction; NumPy by default. Validation and replacement logic use NumPy, so this is not a traced JAX API.

  • replace_inf_to_zero (bool, optional) – Replace the corresponding weighted values with zero. Both default to false; enabling either can discard real numerical failures.

  • replace_nan_to_zero (bool, optional) – Replace the corresponding weighted values with zero. Both default to false; enabling either can discard real numerical failures.

  • reshape_ws (tuple or None, optional) – Optional shape for broadcasting weights against function output.

  • verbose (bool, optional) – Print the weighted integrand if true.

Returns:

scalar or ndarray – Weighted sum with the integration axis removed, in function-output units times integration-coordinate units. No error estimate is returned.

Warns:

UserWarning – Nonfinite weighted values are present and their replacement is disabled.

Notes

Validity. Refine n to verify convergence; nonfinite replacement can discard failures.

Errors. Nonfinite weighted values issue warnings unless the explicit replacement option is enabled.

Backend. NumPy CPU; xp is not an end-to-end JAX contract.

Differentiation. No physical-parameter automatic differentiation on this API.

Examples. examples/docs_numerics.py

Examples

>>> from jeanspy.dequad import dequad
>>> bool(np.isclose(dequad(lambda x: x**2, 0., 1., 256), 1. / 3.))
True