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.2.0.tar.gz (20.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.2.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for certivl-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c1dfa4229fbd753a25fd32f9c2119dfacd3e546dfe6550980b81c0f431d993ef
MD5 52c1a3500a89ce3dd9c1fb9b31f6c717
BLAKE2b-256 bbff368a004a392ea7af9577567f61628162de05a4b3f7b7d6cd7d79663e1c6f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for certivl-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b801dc8aee118d27c8e93f89996fb4233c1ad74b908d2f53c51adaace149cf79
MD5 50e25c8a7a3c617520700151221c5ce5
BLAKE2b-256 f6e89a5437ac2c5ef1de97372d03e12c5a6ac95a4d465d5d9128e260f5dee098

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.2

2 files

0.1.1

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