polyinv – Discover Minimal Canonical Polynomial Invariants from Noisy Data
polyinv is a Python package that recovers minimal canonical polynomial invariants from noisy numerical data. Given a set of observations (points in ℝⁿ), it returns the reduced Gröbner basis of the polynomial ideal that vanishes on the data, up to a specified degree and rational coefficient tolerance.
The algorithm is based on the paper:
Canonical Minimal Polynomial Invariants from Noisy Data via Adaptive Sparse Nullspace Recovery and Gröbner Basis
Tesfay Zemuy Gebrekidan
PDF · Code
Features
- Unique canonical form – returns the reduced Gröbner basis (grevlex order), guaranteed minimal and irredundant.
- Handles multiple simultaneous invariants – Combinatorial Sparse Nullspace Pursuit (CSNP) separates linearly mixed conservation laws.
- Rationality prior – prefers coefficients with low bit-cost (small integers and denominators) over spurious irrational fits.
- Certified global search – Branch-and-Bound with dominance pruning ensures optimality (Theorem 4.4).
- Adaptive degree discovery – automatically finds the polynomial degree via an MDL-based sweep (default maximum degree 10).
- Noise-aware – errors-in-variables correction, adaptive snap-rounding, and scale-relative residual thresholds.
- Multiple input formats – NumPy arrays, Pandas DataFrames, or CSV files.
- Command-line interface – discover invariants directly from the terminal.
Installation
Install from PyPI:
pip install polyinv
Or install the latest development version:
git clone https://github.com/TesfayZ/polyinv
cd polyinv
pip install -e .
Quick Start
import numpy as np
from polyinv import discover
# Generate data on the unit circle
t = np.linspace(0, 2*np.pi, 500)
data = np.column_stack([np.cos(t), np.sin(t)])
var_names = ["x", "y"]
# Discover x² + y² − 1 = 0
result = discover(data, var_names=var_names, max_degree=2)
print(result.basis)
# [x**2 + y**2 - 1]
print(result.status)
# SUCCESS
print(result.certified)
# True
Command-Line Interface
polyinv data.csv --vars x,y --max-degree 2 --format json
For all available options:
polyinv --help
API Reference
discover(
data,
var_names=None,
*,
noise_sigma=None,
max_degree=None,
D_max=10,
max_denom=64,
k_max=6,
full_nullspace=False,
use_bb=True,
auto_escalate_denom=True,
standardize=False,
verbose=False,
)
Recovers the reduced Gröbner basis of the vanishing ideal.
Parameters
| Parameter | Description |
|---|---|
data |
np.ndarray, pd.DataFrame, or CSV filename |
var_names |
Optional variable names |
noise_sigma |
Estimated noise standard deviation. If None, estimated from the SVD tail. |
max_degree |
Maximum polynomial degree. If omitted, adaptive search is used. |
D_max |
Upper bound for adaptive degree discovery (default 10). |
max_denom |
Largest denominator allowed for rational coefficients (default 64). |
k_max |
Maximum support size (default 6). |
full_nullspace |
Enable full-nullspace deflation when multiple invariants are expected. |
use_bb |
Use Branch-and-Bound certification. |
auto_escalate_denom |
Retry using larger denominators if necessary. |
standardize |
Standardize variables before fitting. |
verbose |
Print progress information. |
Returns
A PolyInvResult object containing:
| Attribute | Description |
|---|---|
basis |
Reduced Gröbner basis (SymPy expressions) |
status |
"SUCCESS", "ABSTAINED", or "FAILED" |
certified |
Whether exhaustive search certified optimality |
message |
Human-readable status |
elapsed |
Runtime in seconds |
Additional diagnostic information (support sets, rationality cost, etc.) is also available.
Advanced Usage
Using a Pre-built Design Matrix
from polyinv._sr_gb import build_transition_difference_library
_, monomials, Phi = build_transition_difference_library(
old_data,
new_data,
var_names,
degree,
)
result = discover(
None,
var_names,
degree=degree,
monomials=monomials,
Phi=Phi,
)
How It Works
The algorithm proceeds through the following stages:
-
Monomial Expansion
- Builds the polynomial feature library up to the selected degree.
-
Numerical Nullspace Estimation
- Uses Singular Value Decomposition (SVD) to estimate the nullspace.
-
Combinatorial Sparse Nullspace Pursuit (CSNP)
- Searches for sparse polynomial relations using the lexicographic objective:
- Rationality cost
- Sparsity
- Stability gap
-
Snap-Rounding
- Converts floating-point coefficients into exact rational numbers using adaptive tolerances.
-
Algebraic Simplification
- Removes redundant factors and unnecessary higher-degree multiples.
-
Gröbner Basis Canonicalisation
- Computes the reduced Gröbner basis over ℚ using graded reverse lexicographic order (grevlex).
The final output is a unique minimal generating set for the polynomial ideal that vanishes on the observed data.
Citation
If you use polyinv or the underlying paper in your research, please cite both references separately:
Software citation
@software{Gebrekidan2026polyinv,
author = {Tesfay Zemuy Gebrekidan},
title = {polyinv: Canonical Minimal Polynomial Invariant Computation Package - based on the paper - Canonical Minimal Polynomial Invariants from Noisy Data via Adaptive Sparse Nullspace Recovery and Gröbner Basis},
year = {2026},
publisher = {Zenodo},
doi = {10.5281/zenodo.21838053},
url = {https://doi.org/10.5281/zenodo.21838053},
}
Paper citation
@misc{Gebrekidan2026srgb_csnp,
author = {Tesfay Zemuy Gebrekidan},
title = {Canonical Minimal Polynomial Invariants from Noisy Data via Adaptive Sparse Nullspace Recovery and Gröbner Basis},
year = {2026},
publisher = {Zenodo},
doi = {10.5281/zenodo.21836794},
url = {https://doi.org/10.5281/zenodo.21836794},
}
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Bug reports, feature requests, and pull requests are welcome.
Please open an issue or submit a pull request on GitHub.
Acknowledgements
This work builds upon ideas from the Sparse Identification of Nonlinear Dynamics (SINDy) and Approximate Vanishing Ideal (AVI) communities, and uses SymPy for symbolic algebra and Gröbner basis computations.
Metadata
Release files for polyinv 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| polyinv-0.1.2.tar.gz | 58.3 kB | Without provenance | Details for polyinv-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| polyinv-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for polyinv-0.1.2-py3-none-any.whl |
Total release size: 114.8 kB
Release files / polyinv-0.1.2.tar.gz
| Download URL | polyinv-0.1.2.tar.gz |
|---|---|
| Size | 58.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
531f2c6ea14bf7c4bf5c524df555940ee380518fe86f28ae08828cac0311fb07
|
|
BLAKE2b-256 checksum How to use checksums |
1f3d9d930b8af37b09d50e6b8aec39b3f99ade25e5ab111b954f6e72efc3fb3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / polyinv-0.1.2-py3-none-any.whl
| Download URL | polyinv-0.1.2-py3-none-any.whl |
|---|---|
| Size | 56.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
efcfd8ed4558fdc7f37dcdbb811617f0e843f81291eb9c5dc3fcf504bf29d53a
|
|
BLAKE2b-256 checksum How to use checksums |
00c777fb7b853267bd2c2bab94e67169e11341e111fb061b890486eec16e7932
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for polyinv 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.