Skip to content
Back to the collection

Towards an API for the real numbers

Hans-J. Boehm

2020 · Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation

Read the paper
HN score
0
Mentions
10
Readers
9
Months
6
What’s in a score?

In the conversation

Original HN comments, with labels from simple text rules. A label describes the whole comment and may miss context or irony. Read the discussion to make up your own mind. About the labels

10 selected excerpts · 10 total mentions

timschmidt
Neutral mention · rule
Absolutely. I have written a small but growing CAD kernel which is seeing use in some games and realtime visualization tools ( https://github.com/timschmidt/csgrs ) and can say that computing with numbers isn't really even a solved problem yet. All possible numerical representations come with inherent trade-offs around speed, accuracy, storage size, complexity, and even the kinds of questions one can ask (it's often not meaningful to ask if two floats equal each other without an epsilon to account for floating point error, for instance). "Toward an API for the Real Numbers" ( https://dl.acm.org/doi/epdf/10.1145/3385412.3386037 ) is one of the better papers I've found…
Read the full comment
detailing a sort of staged complexity technique for dealing with this, in which most calculations are fast and always return (arbitrary precision calculations can sometimes go on forever or until memory runs out), but one can still ask for more precise answers which require more compute if required. But there are also other options entirely like interval arithmetic, symbolic algebra engines, etc. One must understand the trade-offs else be bitten by them.
ChadNauseam
Neutral mention · rule
Haha, this is my thread. There’s a typo in the second tweet. Unfortunately there’s no way to edit threads on twitter. > (10^100) + 1 − (10^100) is 0, not 1. I should have said: (10^100) + 1 − (10^100) is 1, not 0. One other error is here: > I asked for 2π to within 0.01 decimals, so you need an approximation of π that's within 0.005 decimals. “0.01 decimals“ and “0.005 decimals“ should have simply been “0.01” and “0.005” respectively. I hope everyone enjoys! The original “API for the real numbers” paper is here: https://dl.acm.org/doi/pdf/10.1145/3385412.3386037 Someone is also implementing it in rust: https://crates.io/crates/realistic
nlewycky
Neutral mention · rule
From the abstract, "simulations of such systems are usually done on digital computers, which are able to compute with finite sequences of rational numbers only." Not at all! Digital computers can use computable reals which are defined as any function from a rational value (the error bound) to a rational value which is within the supplied error-bounds from the true value. Do not mistake this for computing in the rationals, these functions which perform the described task are the computable real numbers. There are countable-infinity many of these functions, one for each computable real. For instance, note that you can always compare two rationals for equality, but you can't always compare two computable reals for equality, just like reals. Hans Boehm (of Boehm garbage collector fame) has been working on this for a long time, here is a recent paper on it: https://dl.acm.org/doi/pdf/10.1145/3385412.3386037
aSanchezStern
Neutral mention · rule
I believe you're basically referring to the computable reals; for the curious, here's the wikipedia page (kind of abstract): https://en.wikipedia.org/wiki/Computable_number and here's the paper where they implement them programmatically, including for the android calculator application (I believe this is how the android calculator works now): https://dl.acm.org/doi/abs/10.1145/3385412.3386037
smasher164
Neutral mention · rule
Great work! I like how well considered the design is. This calculator takes a point in the design space with text input, equation rendering, a grapher, and Big Int/Floats for number representation. I wonder if the author considered an input method where keypresses translate directly into a rendered equation? Symbolab kind of does this, so instead of writing an expression in some functional style and seeing its rendered output, I can directly manipulate the rendered equation with the keyboard. The other point the author makes about discoverability of operators like sqrt and cbrt, I feel that you could circumvent it by introducing a semantic search feature for operators.…
Read the full comment
For example, typing "square root" would display a list of suggestions for operators that match that, like an IDE. The last question I have is if the author has looked at libraries like Calcium (https://fredrikj.net/calcium/) or the work that went into the Android calculator recently (https://dl.acm.org/doi/pdf/10.1145/3385412.3386037). They use exact arithmetic with computable real/complex numbers. It might serve as a cleaner abstraction that switching between different BigNum representations yourself.
zokier
Neutral mention · rule
If you want to move beyond standard floats, this paper could be good starting point: https://dl.acm.org/doi/pdf/10.1145/3385412.3386037 Right now 0.1+0.2-0.3 results = 2.775557562 \cdot 10^ {-17}, which depending on your viewpoint is either expected or unexpected. Also (0.1+0.2)-0.3 is simplified to 0.1+0.2-0.3 for display, but results a different value = 5.551115123 \cdot 10^ {-17}
aSanchezStern
Neutral mention · rule
Yeah there are a few number systems that can do this kind of thing, ranging from rational implementations where the numerator and denominator are stored, all the way to the computable reals (https://en.wikipedia.org/wiki/Computable_number), which can handle even trancendentals exactly! Fun fact, the built-in calculator on android actually uses the computable reals (https://dl.acm.org/doi/abs/10.1145/3385412.3386037), so you can do any calculation on it, and then ask for any number of digits (keep scrolling the result), and it will always be correct. The only downside is that they're a little too slow to use in a lot of performance-sensitive numerical applications.

Keep following the thread.

More in Other research

More from the same topics.