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.

Metadata

Release files for certivl 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for certivl 0.2.0
File Size Uploaded
certivl-0.2.0.tar.gz 20.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for certivl 0.2.0
File Interpreter ABI Platform
certivl-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 36.2 kB

Release files / certivl-0.2.0.tar.gz

Download URL certivl-0.2.0.tar.gz
Size 20.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c1dfa4229fbd753a25fd32f9c2119dfacd3e546dfe6550980b81c0f431d993ef
BLAKE2b-256 checksum
How to use checksums
bbff368a004a392ea7af9577567f61628162de05a4b3f7b7d6cd7d79663e1c6f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / certivl-0.2.0-py3-none-any.whl

Download URL certivl-0.2.0-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b801dc8aee118d27c8e93f89996fb4233c1ad74b908d2f53c51adaace149cf79
BLAKE2b-256 checksum
How to use checksums
f6e89a5437ac2c5ef1de97372d03e12c5a6ac95a4d465d5d9128e260f5dee098
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release 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