Skip to main content

Compute Gauss quadrature nodes and weights for arbitrary weight functions.

Project description

gaussquad

A mini-package to compute Gauss quadrature nodes and weights for arbitrary weight functions on finite intervals using the Golub–Welsch algorithm.

Based on:

Documentation is available at thatmariia.github.io/gaussquad

GitHub Pages


Features

  • Compute quadrature nodes and weights for custom weight functions
  • Use them directly to approximate integrals

Installation

From PyPI:

pip install gaussquad

From GitHub:

pip install git+https://github.com/thatmariia/gaussquad.git

Requirements: Python 3.13 or newer, numpy, scipy

Usage

You can integrate x^2 * w(x) from 0 to 5 with a weight function w(x)=exp(-x):

import numpy as np
from gaussquad import wquad

result = wquad(
    fn=lambda x: x**2,
    weight_fn=lambda x: np.exp(-x),
    interval=(0, 5),
    degree=5,
    moment_method="legendre"  # approximation for moments
)

print(f"Integral of x^2 from 0 to 5 with weight function exp(-x): {result}")  # ≈ 1.7507

More examples: docs » usage.md.

Development & docs

git clone https://github.com/thatmariia/gaussquad.git
cd gaussquad
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows

pip install -e ".[dev,docs]"
Command Description
pytest Run tests
flake8 src/ Check code style
black --check src/ Check code style
cd docs && make html Build docs
open docs/build/html/index.html View docs (macOS)
python -m http.server --directory docs/build/html View docs (all OS)

Citation

If you use this package in your research, please cite it using the information under "Cite this repository" on the right side of the GitHub page.

If you need a version-specific citation, you can find it on Zenodo.


License

This project is licensed under the Apache-2.0 License. See the LICENSE file for details.

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

gaussquad-1.0.1.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

gaussquad-1.0.1-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file gaussquad-1.0.1.tar.gz.

File metadata

  • Download URL: gaussquad-1.0.1.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gaussquad-1.0.1.tar.gz
Algorithm Hash digest
SHA256 bee1354182f5c93283370d45bbed64f68efafd9414ddc6bc32f50c64758dd8a8
MD5 43f1f94cc278e4db8afcafff24d4cfe6
BLAKE2b-256 408da8ae5d1201f549d84913e8277a2b94bbce57d2b4fab063899a10181ff49b

See more details on using hashes here.

Provenance

The following attestation bundles were made for gaussquad-1.0.1.tar.gz:

Publisher: ci.yml on thatmariia/gaussquad

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

File details

Details for the file gaussquad-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: gaussquad-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gaussquad-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 97ff00b1126e1666a1b34e131c2ed91720a81335e67cafe4b0febfc006bf2ec8
MD5 0e2c188d5369b951fc4f7a4852037277
BLAKE2b-256 d0587e01e0ea0bff681b0d97ef41d483f505c88f4f014e89ebd34e9804f8ad26

See more details on using hashes here.

Provenance

The following attestation bundles were made for gaussquad-1.0.1-py3-none-any.whl:

Publisher: ci.yml on thatmariia/gaussquad

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