← All packages

Numerics & statistics

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:

python -m pip install star_poly-0.1.0-py3-none-any.whl

In Python: import star_poly

Get started →

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"

README · tests · evidence (GitHub)

Technical sheet

Package
star-poly
Import name
star_poly
Version
0.1.0
Licence
Apache-2.0
Python
>=3.9
Dependencies
none (standard library only)
Capability
star.numerics.polynomial-roots
Maturity
Released & Verified (RELEASED)
Published commit
dc09f61d

Requirements

  • R1 quadratic_roots(a, b, c) and cubic_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

CheckStatusRecordedWhat was observed
Clean install from the release tagVERIFIED2026-10-06pytest outside the tree: 95 passed in 0.69s
Unit testsVERIFIED2026-10-0695 passed in 0.85s
ReviewVERIFIED2026-10-06Requirements, interface, units, data provenance, dependency surface and failure behaviour reviewed
ReviewVERIFIED2026-10-06Re-running the cross-check gives a byte-identical evidence file
Reference valueVERIFIED2026-10-06quadratic_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 librariesVERIFIED2026-10-06star_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
BenchmarkVERIFIED2026-10-06largest relative difference from the exact roots: 0.0e+00

Fingerprints (SHA-256)

star_poly-0.1.0-py3-none-any.whl2160a527334ecdc2004cedb4baf613b2ba7e3f727dbcd77dd7c3a1250a9f83ca
star_poly.py48e0a38adaf7c7bef52feb07780c5c42ff7f62edfe5f8e92a078b095547287e7
star_poly-0.1.0-source.zip1018a62e0fdd88d231f1c13f050829d4714f80f52e2bc76bfc2f00d8ca99e49e

results