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-Konrod 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

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

epsabs = epsrel = 1e-14
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=1e-14, atol=1e-14)

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.0.tar.gz (32.2 kB view details)

Uploaded Source

Built Distribution

quadax-0.2.0-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: quadax-0.2.0.tar.gz
  • Upload date:
  • Size: 32.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for quadax-0.2.0.tar.gz
Algorithm Hash digest
SHA256 64f9c85c932e10918bd4a1a55fd89af10ad411d03d279404dc9db55415689641
MD5 f31e751e4af15b4d26c8da0a85d404a4
BLAKE2b-256 5ca91cfdca2ef6366e1ecb96c6101238cb879c9d7004355332ca0610b477a32e

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: quadax-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 28.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for quadax-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f3ebd579e01697a2d1bf9582dc42f6b957c72322fb4a63b1b97f49312f98c37c
MD5 04d7f26402a7efc646ab7eb1a699eb09
BLAKE2b-256 3f110d40b88fe6a6e03eb2841229f2990816f2f6594b8736738353c3265b95ff

See more details on using hashes here.

Provenance

Supported by

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