Skip to main content

Numerical quadrature with JAX

Project description

License DOI GitHub issues Pypi

Documentation UnitTests Coverage

quadax is a library for numerical quadrature and integration using JAX.

  • vmap-able, jit-able, differentiable.

  • Scalar or vector valued integrands.

  • Finite or infinite domains with discontinuities or singularities within the domain of integration.

  • Globally adaptive Gauss-Kronrod and Clenshaw-Curtis quadrature for smooth integrands (similar to scipy.integrate.quad)

  • Adaptive tanh-sinh quadrature for singular or near singular integrands.

  • Quadrature from sampled values using trapezoidal and Simpsons methods.

Coming soon:

  • Custom JVP/VJP rules (currently AD works by differentiating the loop which isn’t the most efficient.)

  • N-D quadrature (cubature)

  • QMC methods

  • Integration with weight functions

  • Sparse grids (maybe, need to play with data structures and JAX)

Installation

quadax is installable with pip:

pip install quadax

Usage

import jax.numpy as jnp
import numpy as np
from quadax import quadgk

fun = lambda t: t * jnp.log(1 + t)

epsabs = epsrel = 1e-5 # by default jax uses 32 bit, higher accuracy requires going to 64 bit
a, b = 0, 1
y, info = quadgk(fun, [a, b], epsabs=epsabs, epsrel=epsrel)
assert info.err < max(epsabs, epsrel*abs(y))
np.testing.assert_allclose(y, 1/4, rtol=epsrel, atol=epsabs)

For full details of various options see the API documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quadax-0.2.10.tar.gz (36.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quadax-0.2.10-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

Details for the file quadax-0.2.10.tar.gz.

File metadata

  • Download URL: quadax-0.2.10.tar.gz
  • Upload date:
  • Size: 36.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for quadax-0.2.10.tar.gz
Algorithm Hash digest
SHA256 c3128dfbe7c6cf598ce6437538d5da1b352d45c308a9f4f5ecbbada5d4221f4a
MD5 0cea0647304824de6a05a705def263a7
BLAKE2b-256 33413091229c43cf74b01c2151f1c25fdc0301fbafd307c460b688aada8dc134

See more details on using hashes here.

Provenance

The following attestation bundles were made for quadax-0.2.10.tar.gz:

Publisher: release.yml on f0uriest/quadax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file quadax-0.2.10-py3-none-any.whl.

File metadata

  • Download URL: quadax-0.2.10-py3-none-any.whl
  • Upload date:
  • Size: 31.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for quadax-0.2.10-py3-none-any.whl
Algorithm Hash digest
SHA256 334fcb547f5753c7804383ebd1f513eb31d5f3a5106abb5b4e0608b23e06a747
MD5 117a43eca458f4a461617ecc992f4292
BLAKE2b-256 13ca2b7bddeb66139a974f4a10778457b6f584d21f49c9406dfb58ffc5d32d47

See more details on using hashes here.

Provenance

The following attestation bundles were made for quadax-0.2.10-py3-none-any.whl:

Publisher: release.yml on f0uriest/quadax

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page