Skip to main content
╔════════════════════════════════════════════════════════════════════════════════════════════╗
║                                                                                            ║
║                    ██████╗███████╗██████╗ ████████╗██╗██╗   ██╗██╗                         ║
║                   ██╔════╝██╔════╝██╔══██╗╚══██╔══╝██║██║   ██║██║                         ║
║                   ██║     █████╗  ██████╔╝   ██║   ██║██║   ██║██║                         ║
║                   ██║     ██╔══╝  ██╔══██╗   ██║   ██║╚██╗ ██╔╝██║                         ║
║                   ╚██████╗███████╗██║  ██║   ██║   ██║ ╚████╔╝ ███████╗                    ║
║                    ╚═════╝╚══════╝╚═╝  ╚═╝   ╚═╝   ╚═╝  ╚═══╝  ╚══════╝                    ║
║                                                                                            ║
║                               certified interval arithmetic                                ║
║                                                                                            ║
╚════════════════════════════════════════════════════════════════════════════════════════════╝

certivl

Exact rational and certified interval arithmetic. Every quantity is a Fraction or an Ivl — a closed interval with exact rational endpoints guaranteed to contain the true value — and every operation rounds outward, so containment survives composition.

That is the whole point: if x.hi < 0 then the true value is negative. Not probably, not to within tolerance. A computed inequality becomes a proof.

pip install certivl
from certivl import Ivl, pi_ivl, sqrt_ivl

p = pi_ivl()
print(float(p.hi - p.lo))          # 2e-80

x = Ivl(3, 3) * sqrt_ivl(2) - p    # 3*sqrt(2) - pi
assert x.lo > Ivl(11, 10).lo       # proved > 1.1, not estimated

What is in it

Ivl with the arithmetic operators, and validated enclosures for sqrt, sin, cos, tan, sec, asin, atan, pi, sqrt2, sqrt3, deg, abs, integer isqrt, plus isolate_root for certified root bracketing of an integer polynomial by bisection with exact sign evaluation.

The algebraic half runs on the standard library alone — Ivl arithmetic, sqrt, isqrt, sqrt2, sqrt3, abs, isolate_root. The transcendental enclosures — pi, sin, cos, tan, sec, asin, atan, deg — are built from mpmath's validated interval type, widened outward, so mpmath is a dependency rather than an extra.

Why not mpmath, Arb, or python-flint

Those are faster and more general, and if you want validated numerics at scale you should use them. This exists for a narrower job: plane geometry where the answer has to be a proof and the constants are algebraic. Exact Fraction endpoints throughout, no binary float anywhere on the path, and denominators sized so the final interval widths are irrelevant to the conclusion rather than tuned to it.

Where it came from

This is the kernel underneath four deposited papers on certified computation for classical plane-covering problems — the Lebesgue universal covering ladder, opaque sets for the unit disc, and Fejes Tóth's point-goalie problem. It certified Pál, Sprague and Hansen's published areas to the digits their authors quoted, and adjudicated a disagreement between a published table and its author's own write-up.

The bug that explains the design

An earlier version converted mpf values by re-creating them in the ambient mpmath context before reading their tuple. mp.prec in a fresh process is 53, so the first conversions of a run were silently rounded to double precision — a one-sided error near 1e-17, inside intervals padded to 1e-80.

Nothing caught it for weeks. It surfaced through a cross-check between two independently computed results that should have summed to zero and instead missed by 8.1e-19 — a discrepancy only visible because everything around it was exact. The conversion now reads the raw (sign, man, exp, bc) tuple, which cannot round.

That is the argument for exact endpoints in one paragraph: a rounding error inside a tolerance is invisible, and a rounding error inside a proof is fatal.

Tests

python tests/test_exact.py

Constants are checked against published decimal expansions quoted from elsewhere, never generated by this code — a kernel checked against itself is checked against nothing. The suite finishes by confirming a value known to lie outside its interval is rejected, because a test that has never failed is not evidence.

Note what is being tested: containment, not accuracy. A wide interval is useless and honest; an interval that excludes the true value is a broken proof. Ivl(-2, 3) ** 2 returns [-6, 9] rather than [0, 9] — loose, and correct.

Licence

MIT.


╔════════════════════════════════════════════════════════════╗
║                                                            ║
║      ███████╗      ██╗  ██╗███████╗██╗   ██╗███████╗       ║
║      ██╔════╝      ██║ ██╔╝██╔════╝╚██╗ ██╔╝██╔════╝       ║
║      █████╗  █████╗█████╔╝ █████╗   ╚████╔╝ ███████╗       ║
║      ██╔══╝  ╚════╝██╔═██╗ ██╔══╝    ╚██╔╝  ╚════██║       ║
║      ██║           ██║  ██╗███████╗   ██║   ███████║       ║
║      ╚═╝           ╚═╝  ╚═╝╚══════╝   ╚═╝   ╚══════╝       ║
║                                                            ║
║               ·   C  R  E  A  T  I  V  E   ·               ║
║                                                            ║
║          ────────────────────────────────────────          ║
║                                                            ║
║                      Vincent Gonzalez                      ║
║                         f-keys.com                         ║
║                 ORCID 0009-0005-3640-014X                  ║
║                                                            ║
╚════════════════════════════════════════════════════════════╝

Part of F-Keys — independent hardware, software and internet products. See the working log and live status.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

certivl-0.1.1.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

certivl-0.1.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file certivl-0.1.1.tar.gz.

File metadata

  • Download URL: certivl-0.1.1.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for certivl-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3db59469b4faafe071948dd83e1d41947f04b19b83ca07d775c627f70c3a6afe
MD5 4dd6fa2b136fbc255bba0d6df6761fae
BLAKE2b-256 61f535b7299a74960df799fe21613a64f2813b700aeed7eadb7ef098953b0e2a

See more details on using hashes here.

File details

Details for the file certivl-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: certivl-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for certivl-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e8ede4954eee2efe22bf6cd2beb5815782df734438f82183db06814de6e685c
MD5 b4dac0774a09eec515cac6fd8cce459f
BLAKE2b-256 e2ab4bd13c2536a323e66aa4e29bd626de868cf1e6322d3cf821b61acb06c576

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.0

2 files

0.1.2

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page