Live data from Hacker News

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

victorpoughon.github.io

21–30 of 61 posts

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

#22
Very cool! I don't entirely understand some of the operations, but for what I do understand its pretty neat.

I wish in classes we were introduced to a notion of arithmetic on intervals as it comes up. Like in basic statistics with confidence intervals there's ±, as well as in the quadratic equation. It found some what dissatisfying we couldn't chain the resulting a series of operations and instead repeat the operations for the 2 seperate values of the ±. I get a teacher would rather not get hung up on this because they want to bring it back to the application generally, like solving a more complicated equation or hypothesis testing in basic stats. I just wish they hinted at the idea we can do arithmetic on these kinds of things more generally.

I realise what you've got here is well beyond this, but seeing this was some level of validation that treating the interval as a piece of data with its own behaviour of certain operations does make some sense.

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

#23

[flagged]

I don't handle it, ahah. You are right that if you take any classical numerical computing algorithm and replace the floating point reals by interval unions, most of the time the number of intervals in the unions in each of your variables will grow very fast. This is one of the problems of unions and as far as I'm aware it's a topic of active academic research.

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

#25

Author here. Outward rounding to combat precision issues is what interval arithmetic is most known for (try 0.1+0.2 with "full precision mode" enabled), but that's really a shame in my opinion. Outward rounding is cool, but the "inclusion property", as it's known in research papers, works at every scale! This is what enables things like: 50 * (10 + [-1, 1]) [450, 550] which is lovely, I think. Adding the union layer…

Nice! I am interested in how the arithmetic you implemented differs from the IEEE 1788 Standard for Interval Arithmetic (and how the two linked papers relate to it). To address the challenges you mention, did you have to start from scratch or was it something that can build on top of the IEEE standard?

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

#26
post #20

I just read up on interval arithmetic. I understand its desirable properties. Where in practice have you applied it? What’s a real world application for interval arithmetic?

In physics, whenever you make a measurement it has a precision. Usually you represent this as a normal distribution, but for calculations it can be easier to represent this as an interval. The police measure the distance my car travelled [ 99.9, 100.1 ] m and the time it took [ 3.3, 3.4 ] s - how fast was my car going? [29.38, 30.33] m/s according to the interval calculator. Physics students learn exactly this method…

And one might want to approximate error distribution calculus with a method that will look like the one here

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

#27
post #15

I just read up on interval arithmetic. I understand its desirable properties. Where in practice have you applied it? What’s a real world application for interval arithmetic?

It can be used in static analysis or type checking. E.g. if (x >= 0) { x += 10 if (x = By maintaining an interval of possible values of x, you can detect the unreachable branch, because the interval becomes empty: initial: [-oo, oo] x >= 0 : [0, oo] x += 10: [10, oo] x =

We recently implemented this idea in an LLVM optimisation pass based on value-range information from sensor datasheets [1].

[1]: https://dl.acm.org/doi/pdf/10.1145/3640537.3641576

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

#29
post #25

Author here. Outward rounding to combat precision issues is what interval arithmetic is most known for (try 0.1+0.2 with "full precision mode" enabled), but that's really a shame in my opinion. Outward rounding is cool, but the "inclusion property", as it's known in research papers, works at every scale! This is what enables things like: 50 * (10 + [-1, 1]) [450, 550] which is lovely, I think. Adding the union layer…

Nice! I am interested in how the arithmetic you implemented differs from the IEEE 1788 Standard for Interval Arithmetic (and how the two linked papers relate to it). To address the challenges you mention, did you have to start from scratch or was it something that can build on top of the IEEE standard?

Interesting! I'm not familiar with IEEE 1788. The TypeScript library (not-so-float) that I wrote which powers the calculator uses the JS Number type which is double precision IEEE 754. Outward rounding is not supported by JS so I used a bit level manipulation hack by casting to TypedArray [0] to implement the equivalent of C's nextafter() function. Otherwise I mostly followed Hickey & van Emden paper which is really delightful [1]. The real hard work is actually generating all the test cases. Good luck getting 100% test coverage on interval division!

[0] https://github.com/victorpoughon/not-so-float/blob/main/src/...

[1] https://fab.cba.mit.edu/classes/S62.12/docs/Hickey_interval....

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

#30
post #15

I just read up on interval arithmetic. I understand its desirable properties. Where in practice have you applied it? What’s a real world application for interval arithmetic?

It can be used in static analysis or type checking. E.g. if (x >= 0) { x += 10 if (x = By maintaining an interval of possible values of x, you can detect the unreachable branch, because the interval becomes empty: initial: [-oo, oo] x >= 0 : [0, oo] x += 10: [10, oo] x =

I’m working on a static analyser at the moment that does this, and the inferences that can be made just from the information of intervals is quite impressive. One thing you run into pretty quickly though in a lot of languages is integer overflow ruining your day - in your example above the commented section is reachable for signed ints that support overflow and that adds a whole other layer of complexity to things.
Post reply on HN