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 (when released):

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.0.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.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gaussquad-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 e3293ad3e5f7aec616a929ca10da24f030ec252fd47aa81f7c11d9fba1a3433a
MD5 da41876445486c09e2c583423ea11aef
BLAKE2b-256 0b7335880d421081cc77672532806141151dce13446820710313e8f311361230

See more details on using hashes here.

Provenance

The following attestation bundles were made for gaussquad-1.0.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: gaussquad-1.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09975a79f2905f388d7cc42ea41995fe20ddfc540815aa182504c4dab70f95d2
MD5 e52529cc7575922ee916705bc6caf0ec
BLAKE2b-256 94d134ba9a44a5455063878ff7bdb0552393ba120657f3d6b0a335fadb5f26ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for gaussquad-1.0.0-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