star-poly 0.1.0
Real roots of quadratics and cubics
Public state: Released & Verified. The registry label is RELEASED. What the states mean →
Apache-2.0 Released & Verified single file
Summary
Distinct real roots of quadratics and cubics with the number of roots decided in exact arithmetic and each root isolated by exact-sign bisection, plus Horner evaluation; on 640 polynomials the count equals SymPy's exact count and every root equals the exact root rounded to a float; reproduces the classic cancellation example.
Run in your browser
Edit the code and press Run (or Ctrl+Enter). Python runs in your browser with this package's published code. The first run downloads Python once (about 12 MB).
Runs in the browser: all 95 tests pass in the browser's Python (Pyodide 314.0.7, Python 3.14.2), measured on 20 October 2026.
Use it on your computer
No account and no GitHub needed. Download, then install with one command:
- Install file · star_poly-0.1.0-py3-none-any.whl 4 kB
- Single file — copy it alongside your code · star_poly.py 7 kB
- Source code (.zip) 24 kB
python -m pip install star_poly-0.1.0-py3-none-any.whlIn Python: import star_poly
Cite it, and its bill of materials
For a paper, a report or a supplier file: the citation in two formats, and the software bill of materials (SBOM) in the two standard formats, with the fingerprint of the wheel.
@software{cavazzini_star_poly_0_1_0,
author = {Cavazzini, Andrea},
title = {{star-poly}: Real roots of quadratics and cubics},
version = {0.1.0},
year = {2026},
url = {https://andrea07072000.github.io/S.T.A.R.-/software/star_poly/},
note = {Apache-2.0. Source: https://github.com/Andrea07072000/S.T.A.R.-, commit dc09f61d}
}
For developers
Install directly from the public repository:
python -m pip install "star-poly @ git+https://github.com/Andrea07072000/S.T.A.R.-.git@dc09f61dcee098d518f070d6a23a8815defc1109#subdirectory=packages/star_poly"
Technical sheet
Requirements
- R1
quadratic_roots(a, b, c)andcubic_roots(a, b, c, d)return the distinct real roots, sorted. The number of roots is decided by the discriminant computed in exact rational arithmetic: a double or triple root is reported once, and a polynomial with no real root returns an empty tuple. - R2 Each root is located inside an interval that holds no other root, by bisection over the floats driven by the exact sign of the polynomial (at most 64 steps, no starting guess): roots of very different size keep their digits and none is lost to a neighbour.
evaluate(coefficients, x)returns the value and the first derivative (Horner). - R3 Measured on 640 quadratics and cubics (random, exact multiple roots, roots separated by up to 1e12, leading coefficients down to 1e-30): the number of real roots equals SymPy's exact count in every case, and every root equals the exact root rounded to a float; all are roots for mpmath at 60 digits and for NumPy.
- R4 Every function returns floats or raises
ValueError: a zero leading coefficient, a non-finite or non-numeric coefficient (booleans included), a coefficient beyond 1e60, a malformed coefficient list, an overflowing result.
Limits (what is not claimed)
Real roots only: no complex roots, no quartics or higher degrees. "Exact" refers to the polynomial whose coefficients are the floats given: if those are rounded measurements, a nearly double root may be reported as two, one or none, and that is the correct answer for the numbers supplied. Two distinct roots closer than one float are returned as two neighbouring floats. The exact arithmetic makes these functions slower than a closed formula (tens to hundreds of microseconds): they are for correctness, not for inner loops. evaluate is plain double-precision Horner, not compensated.
Release gate
Computed by the registry from the result files, with the same function that decides RELEASED.
- Mutation score, latest measure of each module (needs at least 0.850)
- star_poly.py 0.893 (2026-10-06)
- Independent implementations written by others (needs 2)
- mpmath polyroots at 60 digits, numpy.roots, SymPy real_roots on exact rational coefficients
- Result
- Released & Verified
Evidence in the registry
| Check | Status | Recorded | What was observed |
|---|---|---|---|
| Clean install from the release tag | VERIFIED | 2026-10-06 | pytest outside the tree: 95 passed in 0.69s |
| Unit tests | VERIFIED | 2026-10-06 | 95 passed in 0.85s |
| Review | VERIFIED | 2026-10-06 | Requirements, interface, units, data provenance, dependency surface and failure behaviour reviewed |
| Review | VERIFIED | 2026-10-06 | Re-running the cross-check gives a byte-identical evidence file |
| Reference value | VERIFIED | 2026-10-06 | quadratic_roots(1, -1e8, 1) = (1e-08, 99999999.99999999): both roots correct to the last digit (suite: 95 passed in 0.85s) |
| Cross-check with independent libraries | VERIFIED | 2026-10-06 | star_poly returns the right NUMBER of distinct real roots of a quadratic or a cubic, double and triple roots included, and each root to the last digits |
| Benchmark | VERIFIED | 2026-10-06 | largest relative difference from the exact roots: 0.0e+00 |
Fingerprints (SHA-256)
| star_poly-0.1.0-py3-none-any.whl | 2160a527334ecdc2004cedb4baf613b2ba7e3f727dbcd77dd7c3a1250a9f83ca |
| star_poly.py | 48e0a38adaf7c7bef52feb07780c5c42ff7f62edfe5f8e92a078b095547287e7 |
| star_poly-0.1.0-source.zip | 1018a62e0fdd88d231f1c13f050829d4714f80f52e2bc76bfc2f00d8ca99e49e |
