HN
Today

Show HN: I made a calculator that works over disjoint sets of intervals

This Show HN presents an interactive calculator implementing "Interval Union Arithmetic," a specialized field that addresses limitations in standard interval arithmetic. It elegantly handles challenging cases like division by zero-containing intervals by allowing results to be disjoint unions of intervals. Hacker News users appreciate such clever, open-source solutions to fundamental computational problems, especially when they offer practical tools for complex mathematical concepts.

33
Score
3
Comments
#1
Highest Rank
19h
on Front Page
First Seen
Apr 18, 5:00 AM
Last Seen
Apr 18, 11:00 PM
Rank Over Time
2123455789101419201822252829

The Lowdown

Victor Poughon introduces an open-source, interactive calculator that implements Interval Union Arithmetic, a mathematical discipline he believes is underappreciated. This advanced form of interval arithmetic overcomes significant limitations of its standard counterpart, particularly in handling operations like division by intervals that contain zero, by representing results as unions of disjoint intervals.

  • Core Problem Solved: Standard interval arithmetic often yields useless results (like [-∞, +∞]) or defines operations as undefined when dividing by intervals containing zero. Interval Union Arithmetic provides a precise, non-interval result, such as [-∞, -1] U [0.5, +∞] for 1 / [-1, 2]. This means it can confidently exclude real numbers from the set of possible outcomes.
  • Inclusion Property: A key benefit is its inclusion property, which guarantees that if any real number from each input union is chosen and the expression is computed over the reals, the result will be contained within the output union. This makes it ideal for representing uncertainty.
  • Implementation: The calculator is built with a dependency-free TypeScript library that uses IEEE 754 double precision floats and outward rounding. This ensures that the computed interval results are guaranteed to contain the true mathematical value, even with floating-point precision issues.
  • Features: It supports standard arithmetic operations, a wide range of functions (e.g., tan(), log(), sin()), and constants (pi, e). The syntax allows for intuitive input, including mixing bare numbers with intervals and even nesting intervals.
  • Full Precision Mode: This mode intelligently interprets input numbers and displays output with full decimal precision, ensuring that the computed intervals accurately bound the true values.
  • Open Source: Both the calculator project and its underlying not-so-float engine are open-source on GitHub.

This project provides a robust and practical tool for numerical computation, offering a more powerful and precise way to work with intervals and manage uncertainty, especially in scenarios where standard interval arithmetic falls short.