quadax


Namequadax JSON
Version 0.2.4 PyPI version JSON
download
home_pagehttps://github.com/f0uriest/quadax
SummaryNumerical quadrature with JAX
upload_time2024-12-07 20:01:30
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/fd/f1/75ab0013bd80e7bc77c804dfde7c935e0dc44257e86c993749b3f1412802/quadax-0.2.4.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.4",
    "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": "d2ce217b48057a3f797728a5229f1640a8b587b89be48be0e360a8a1fbcd2775",
                "md5": "b496044db2a21a4c46508167473e96c7",
                "sha256": "3337f36fe629f6ac1800d30eaf18def045b93d83d1311a7b4a6eb8028d85a246"
            },
            "downloads": -1,
            "filename": "quadax-0.2.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b496044db2a21a4c46508167473e96c7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 31126,
            "upload_time": "2024-12-07T20:01:28",
            "upload_time_iso_8601": "2024-12-07T20:01:28.163137Z",
            "url": "https://files.pythonhosted.org/packages/d2/ce/217b48057a3f797728a5229f1640a8b587b89be48be0e360a8a1fbcd2775/quadax-0.2.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fdf175ab0013bd80e7bc77c804dfde7c935e0dc44257e86c993749b3f1412802",
                "md5": "5ef895401c32af61b6d3e9e84bab9467",
                "sha256": "c0cb80b3abb26b6b7cda5e30ceb6f1e8fd3c1a82ef21ecbcbd903cc58d6821e7"
            },
            "downloads": -1,
            "filename": "quadax-0.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "5ef895401c32af61b6d3e9e84bab9467",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 34899,
            "upload_time": "2024-12-07T20:01:30",
            "upload_time_iso_8601": "2024-12-07T20:01:30.266602Z",
            "url": "https://files.pythonhosted.org/packages/fd/f1/75ab0013bd80e7bc77c804dfde7c935e0dc44257e86c993749b3f1412802/quadax-0.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-07 20:01:30",
    "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.12"
                ],
                [
                    ">=",
                    "0.11"
                ]
            ]
        },
        {
            "name": "jax",
            "specs": [
                [
                    "<=",
                    "0.5.0"
                ],
                [
                    ">=",
                    "0.3.2"
                ]
            ]
        },
        {
            "name": "numpy",
            "specs": [
                [
                    ">=",
                    "1.20.0"
                ],
                [
                    "<",
                    "2.2"
                ]
            ]
        }
    ],
    "lcname": "quadax"
}
        
Elapsed time: 0.42799s