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

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

Uploaded Source

Built Distribution

quadax-0.2.2-py3-none-any.whl (31.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: quadax-0.2.2.tar.gz
  • Upload date:
  • Size: 34.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for quadax-0.2.2.tar.gz
Algorithm Hash digest
SHA256 842f95315f6f444f34713596d6e158f21cc54dc25b1ea1e1231821ff21f27723
MD5 c50229a0cab4f1ebe4302227fa4ce498
BLAKE2b-256 91227177e0f43d08b6e7fdf4557ea2f6ac917adbfb1a8767750d1e6b34340ff0

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: quadax-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 31.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for quadax-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0905a6a5acf9e83f66c5069e4823192c87d5a5280ca1e85f7be83eb1a31351e6
MD5 8ee7492c73b28cee29c007bb3e33b264
BLAKE2b-256 9474f7399c96a0cc0c5ad62ac24c4c039b773ab37f8daa69d7f98bfe227af3e6

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