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
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3293ad3e5f7aec616a929ca10da24f030ec252fd47aa81f7c11d9fba1a3433a
|
|
| MD5 |
da41876445486c09e2c583423ea11aef
|
|
| BLAKE2b-256 |
0b7335880d421081cc77672532806141151dce13446820710313e8f311361230
|
Provenance
The following attestation bundles were made for gaussquad-1.0.0.tar.gz:
Publisher:
ci.yml on thatmariia/gaussquad
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gaussquad-1.0.0.tar.gz -
Subject digest:
e3293ad3e5f7aec616a929ca10da24f030ec252fd47aa81f7c11d9fba1a3433a - Sigstore transparency entry: 215359616
- Sigstore integration time:
-
Permalink:
thatmariia/gaussquad@0bbd792bfb5c9543aa23a45cbe415d618fa2b908 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/thatmariia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@0bbd792bfb5c9543aa23a45cbe415d618fa2b908 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09975a79f2905f388d7cc42ea41995fe20ddfc540815aa182504c4dab70f95d2
|
|
| MD5 |
e52529cc7575922ee916705bc6caf0ec
|
|
| BLAKE2b-256 |
94d134ba9a44a5455063878ff7bdb0552393ba120657f3d6b0a335fadb5f26ae
|
Provenance
The following attestation bundles were made for gaussquad-1.0.0-py3-none-any.whl:
Publisher:
ci.yml on thatmariia/gaussquad
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gaussquad-1.0.0-py3-none-any.whl -
Subject digest:
09975a79f2905f388d7cc42ea41995fe20ddfc540815aa182504c4dab70f95d2 - Sigstore transparency entry: 215359618
- Sigstore integration time:
-
Permalink:
thatmariia/gaussquad@0bbd792bfb5c9543aa23a45cbe415d618fa2b908 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/thatmariia
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@0bbd792bfb5c9543aa23a45cbe415d618fa2b908 -
Trigger Event:
push
-
Statement type: