AI Briefing
KO

Show HN: I built a calculator that operates on disjoint sets of intervals

·2026.04.18 10:15

Key point

Introduction of a calculator implementation supporting interval union arithmetic.

Details

Interval Calculator is a calculator that operates not on a single real number but on a union of intervals.

The core is interval union arithmetic, which is more powerful than ordinary interval arithmetic in that division is closed even for intervals containing 0. For example, 2 / [-2, 1] yields a disjoint union like [-∞, -1] U [2, +∞].

This approach also guarantees the inclusion property. If you pick an arbitrary real number from each input union and evaluate the same expression using real-number arithmetic, the result is guaranteed to fall within the output union. It can also be used to express uncertainty, so an expression like 50 * (10 + [-1, 1]) evaluates to [450, 550].

The range of supported features is fairly broad.

  • Basic operations: +, -, *, /, ^
  • Functions: abs, sqrt, sqinv, log, log2, log10, exp, cos, sin, tan, acos, asin, atan, min, max
  • Constants: inf, ∞, pi, e
  • Auxiliary functions: lo, hi, hull

Syntactically, you can input intervals in the form [a, b] and unions joined by U, and entering just a number is interpreted as a narrow interval. Interestingly, intervals can be nested inside intervals, and when an interval appears in a bound position, it is handled by taking the upper bound.

In Full precision mode, outward rounding of IEEE 754 doubles is used so that, even accounting for floating-point error, the returned interval contains the actual value. For example, even if 0.1 + 0.2 doesn't come out to exactly 0.3, the resulting interval is computed so that it encloses the true value.

The author notes that bugs may still remain and is accepting issues on GitHub. The code and the engine, not-so-float, have also been open-sourced, and future plans include separating input interpretation from display precision, an ans variable, an intersection operation, improving U precedence, and supporting empty union input.

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.