quadax


Namequadax JSON
Version 0.2.5 PyPI version JSON
download
home_pagehttps://github.com/f0uriest/quadax
SummaryNumerical quadrature with JAX
upload_time2025-01-21 02:25:45
maintainerNone
docs_urlNone
authorRory Conlin
requires_python>=3.8
licenseMIT
keywords integration quadrature gauss kronrod tanh sinh romberg adaptive
VCS
bugtrack_url
requirements equinox jax numpy
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
########
quadax
########
|License| |DOI| |Issues| |Pypi|

|Docs| |UnitTests| |Codecov|

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`:

.. code-block:: console

    pip install quadax



Usage
=====

.. code-block:: python

    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 <https://quadax.readthedocs.io/en/latest/api.html>`__


.. |License| image:: https://img.shields.io/github/license/f0uriest/quadax?color=blue&logo=open-source-initiative&logoColor=white
    :target: https://github.com/f0uriest/quadax/blob/master/LICENSE
    :alt: License

.. |DOI| image:: https://zenodo.org/badge/709132830.svg
    :target: https://zenodo.org/doi/10.5281/zenodo.10035983
    :alt: DOI

.. |Docs| image:: https://img.shields.io/readthedocs/quadax?logo=Read-the-Docs
    :target: https://quadax.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation

.. |UnitTests| image:: https://github.com/f0uriest/quadax/actions/workflows/unittest.yml/badge.svg
    :target: https://github.com/f0uriest/quadax/actions/workflows/unittest.yml
    :alt: UnitTests

.. |Codecov| image:: https://codecov.io/github/f0uriest/quadax/graph/badge.svg?token=MB11I7WE3I
    :target: https://codecov.io/github/f0uriest/quadax
    :alt: Coverage

.. |Issues| image:: https://img.shields.io/github/issues/f0uriest/quadax
    :target: https://github.com/f0uriest/quadax/issues
    :alt: GitHub issues

.. |Pypi| image:: https://img.shields.io/pypi/v/quadax
    :target: https://pypi.org/project/quadax/
    :alt: Pypi

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/f0uriest/quadax",
    "name": "quadax",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "integration quadrature gauss kronrod tanh sinh romberg adaptive",
    "author": "Rory Conlin",
    "author_email": "wconlin@princeton.edu",
    "download_url": "https://files.pythonhosted.org/packages/71/35/e1c7820f2b4d2612a6559b8807f455210cf3d3ae28b8a59d4242676cdeb3/quadax-0.2.5.tar.gz",
    "platform": null,
    "description": "\n########\nquadax\n########\n|License| |DOI| |Issues| |Pypi|\n\n|Docs| |UnitTests| |Codecov|\n\nquadax is a library for numerical quadrature and integration using JAX.\n\n- ``vmap``-able, ``jit``-able, differentiable.\n- Scalar or vector valued integrands.\n- Finite or infinite domains with discontinuities or singularities within the domain of integration.\n- Globally adaptive Gauss-Kronrod and Clenshaw-Curtis quadrature for smooth integrands (similar to ``scipy.integrate.quad``)\n- Adaptive tanh-sinh quadrature for singular or near singular integrands.\n- Quadrature from sampled values using trapezoidal and Simpsons methods.\n\nComing soon:\n\n- Custom JVP/VJP rules (currently AD works by differentiating the loop which isn't the most efficient.)\n- N-D quadrature (cubature)\n- QMC methods\n- Integration with weight functions\n- Sparse grids (maybe, need to play with data structures and JAX)\n\nInstallation\n============\n\nquadax is installable with `pip`:\n\n.. code-block:: console\n\n    pip install quadax\n\n\n\nUsage\n=====\n\n.. code-block:: python\n\n    import jax.numpy as jnp\n    import numpy as np\n    from quadax import quadgk\n\n    fun = lambda t: t * jnp.log(1 + t)\n\n    epsabs = epsrel = 1e-5 # by default jax uses 32 bit, higher accuracy requires going to 64 bit\n    a, b = 0, 1\n    y, info = quadgk(fun, [a, b], epsabs=epsabs, epsrel=epsrel)\n    assert info.err < max(epsabs, epsrel*abs(y))\n    np.testing.assert_allclose(y, 1/4, rtol=epsrel, atol=epsabs)\n\n\nFor full details of various options see the `API documentation <https://quadax.readthedocs.io/en/latest/api.html>`__\n\n\n.. |License| image:: https://img.shields.io/github/license/f0uriest/quadax?color=blue&logo=open-source-initiative&logoColor=white\n    :target: https://github.com/f0uriest/quadax/blob/master/LICENSE\n    :alt: License\n\n.. |DOI| image:: https://zenodo.org/badge/709132830.svg\n    :target: https://zenodo.org/doi/10.5281/zenodo.10035983\n    :alt: DOI\n\n.. |Docs| image:: https://img.shields.io/readthedocs/quadax?logo=Read-the-Docs\n    :target: https://quadax.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation\n\n.. |UnitTests| image:: https://github.com/f0uriest/quadax/actions/workflows/unittest.yml/badge.svg\n    :target: https://github.com/f0uriest/quadax/actions/workflows/unittest.yml\n    :alt: UnitTests\n\n.. |Codecov| image:: https://codecov.io/github/f0uriest/quadax/graph/badge.svg?token=MB11I7WE3I\n    :target: https://codecov.io/github/f0uriest/quadax\n    :alt: Coverage\n\n.. |Issues| image:: https://img.shields.io/github/issues/f0uriest/quadax\n    :target: https://github.com/f0uriest/quadax/issues\n    :alt: GitHub issues\n\n.. |Pypi| image:: https://img.shields.io/pypi/v/quadax\n    :target: https://pypi.org/project/quadax/\n    :alt: Pypi\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Numerical quadrature with JAX",
    "version": "0.2.5",
    "project_urls": {
        "Contributing": "https://github.com/f0uriest/quadax/blob/master/CONTRIBUTING.rst",
        "Documentation": "https://quadax.readthedocs.io/",
        "Homepage": "https://github.com/f0uriest/quadax",
        "Issues Tracker": "https://github.com/f0uriest/quadax/issues",
        "Source Code": "https://github.com/f0uriest/quadax/"
    },
    "split_keywords": [
        "integration",
        "quadrature",
        "gauss",
        "kronrod",
        "tanh",
        "sinh",
        "romberg",
        "adaptive"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "df6e42790d8e403b9fa99afb8f8d73911f856a1777b096efe24ef63589ead0d0",
                "md5": "342d296ee2694c85ea4d7ca1b973d965",
                "sha256": "1c12c1aab71ff306905a660eb33baf4046918cabf1321c5da7f9ab85b0788b85"
            },
            "downloads": -1,
            "filename": "quadax-0.2.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "342d296ee2694c85ea4d7ca1b973d965",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 31217,
            "upload_time": "2025-01-21T02:25:43",
            "upload_time_iso_8601": "2025-01-21T02:25:43.939088Z",
            "url": "https://files.pythonhosted.org/packages/df/6e/42790d8e403b9fa99afb8f8d73911f856a1777b096efe24ef63589ead0d0/quadax-0.2.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7135e1c7820f2b4d2612a6559b8807f455210cf3d3ae28b8a59d4242676cdeb3",
                "md5": "1d69cbe410d0ae673ff5562f0f466a0b",
                "sha256": "26b57477ea869fba8040ffbb6d9f67be3f63850856d0c5fb2e755676b640007b"
            },
            "downloads": -1,
            "filename": "quadax-0.2.5.tar.gz",
            "has_sig": false,
            "md5_digest": "1d69cbe410d0ae673ff5562f0f466a0b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 35089,
            "upload_time": "2025-01-21T02:25:45",
            "upload_time_iso_8601": "2025-01-21T02:25:45.931571Z",
            "url": "https://files.pythonhosted.org/packages/71/35/e1c7820f2b4d2612a6559b8807f455210cf3d3ae28b8a59d4242676cdeb3/quadax-0.2.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-21 02:25:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "f0uriest",
    "github_project": "quadax",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "equinox",
            "specs": [
                [
                    ">=",
                    "0.11.0"
                ],
                [
                    "<=",
                    "0.11.11"
                ]
            ]
        },
        {
            "name": "jax",
            "specs": [
                [
                    ">=",
                    "0.3.2"
                ],
                [
                    "<=",
                    "0.5.0"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    ">=",
                    "1.20.0"
                ],
                [
                    "<=",
                    "2.2.2"
                ]
            ]
        }
    ],
    "lcname": "quadax"
}
        
Elapsed time: 0.44502s