Live data from Hacker News

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

victorpoughon.github.io

11–20 of 61 posts

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

#11

Excellent!! I love interval arithmetic and also wrote a TS implementation for a graphing calculator project. Agree that it's very underrated, and I wish that directed rounding was exposed in more languages.

Yeah it's super interesting. Like you said, I learned that the IEEE 754 spec actually requires that complete implementations of floating point numbers expose a way to programmatically choose the rounding mode. As far as I know only C allows you to do that, and even then it depends on hardware support. For JS I had to use ugly typedarray casts. Which kinda only accidentally work due to endianess. But technically there should be an API for it!

There's other unused stuff in IEEE 754 like that: the inexact bit or signaling NaNs!

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

#12
post #5

Very nice, thanks for sharing! Maybe show which upper or lower values are included in the intervals? A notation I am familiar with uses outward facing brackets if the value is not included in the interval. That always applies to infinity. Applied to the cases here: ]-∞, -1] U [0.5, +∞[ The excluded interval in between becomes ]-1, 0.5[ then. That’s how min (and analogously max) works, right? min(A, B) = [lo(A,B), lo…

I was also a bit confused by this. I thought the standard notation was round brackets, but maybe doesn't work well in ASCII?

Round brackets are standard in the US but that notation is used in France and some other places.

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

#14
You could add a feature where it will compute the global optimum of any function of a small number of variables. Branch and bound with interval arithmetic works well for a small number of variables.

Disjoint unions of intervals seems like a nice thing to have

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

#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 =

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

#16
The last point in your intro description can't be stressed enough: this allows for safe handling of rounding errors in floating point operations.

Though you are inherently losing precision: there are values in the output interval which don't have a corresponding input that causes this output.

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

#17

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’s astonishing how nobody hasn’t mentioned abstract interpretation yet. Under classical static analysis, if you can “prove” that a variable does not have values in some unsound zones, you can e.g. “prove” soundness or apply further optimizations.

The interval abstract domain works under interval analysis with an algebra that’s the same of this calculator. It’s funny to implement something like that on source/binary level :)

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

#18
post #5

Very nice, thanks for sharing! Maybe show which upper or lower values are included in the intervals? A notation I am familiar with uses outward facing brackets if the value is not included in the interval. That always applies to infinity. Applied to the cases here: ]-∞, -1] U [0.5, +∞[ The excluded interval in between becomes ]-1, 0.5[ then. That’s how min (and analogously max) works, right? min(A, B) = [lo(A,B), lo…

I was also a bit confused by this. I thought the standard notation was round brackets, but maybe doesn't work well in ASCII?

  (0, 1)
Is this an twice-open interval or a 2D vector?

See, this is why Bourbaki introduced the ]0,1[ notation.

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

#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 before they move on to more sophisticated analysis with error distributions.

Post reply on HN