Live data from Hacker News

Toward an API for the Real Numbers

blog.acolyer.org

11–20 of 85 posts

Re: Toward an API for the Real Numbers

#11

Representing reals as fractions (rationals) goes a long way toward achieving this goal.

The real numbers are notoriously non-equivalent to the rational numbers.

sure, but supporting rational numbers solves for 2/3 of the types of "real" numbers in a dramatically better way than just making less crappy decimal representations.

Re: Toward an API for the Real Numbers

#12
In "safe" languages we often talk about how you can't ignore errors in return values. Your program "leaks" if that happens. But with integer overflows and floating point precision, we just ignore the leaks as something that programmers already know about and have to consider while coding. Of course, it's not an easy problem to deal with, as computers don't have infinite memory and they need to be performant, but we really need to spend more time thinking about and supporting improvements like this. If it only takes 6k lines to provide an API for more precise real numbers, then almost every programming language should have it. The ideas of allowing programmers to get information about the real and potential precision errors in operations are also interesting. Well, in general the ability to define the kind of numbers you want to be working with and their precision is fairly poor in computer science as a whole, there's still a long road ahead.

Re: Toward an API for the Real Numbers

#13
The API itself is perhaps less interesting than the implementation strategy. I'm presently developing a C library for exact real and complex numbers (http://fredrikj.net/calcium/) that goes much further to make equality decidable even in complicated cases while also enabling efficient computations. Still working on implementing functionality and writing up a formal paper.

Re: Toward an API for the Real Numbers

#15
Quote: "Operations complete in under a millisecond, not GFLOPS performance, but certainly good enough for many applications".

Then you have a scientist reading this, wants it for research and then wonders why a simple 3 lines in Python code takes 3 days to complete. True story!

Re: Toward an API for the Real Numbers

#16
post #2

Tangentially related, the stock Android calculator app is fantastic. It has good accuracy as mentioned in the article and an easy to explore and use history. It is one of the few things that will make me hunt around for my phone when I am working on my desktop.

As a refugee from Windows Phone I actually use Uno Calculator on Android, which is a port of Windows Calculator. It also has good accuracy and easy to explore history, and also sane interface without Android's idiosyncrasies. And you can install it on your presumably non-Windows desktop too.

Re: Toward an API for the Real Numbers

#18

Representing reals as fractions (rationals) goes a long way toward achieving this goal.

I haven't read the paper yet, but if I understand the post correctly, this interface represents numbers as the product of a rational and a recursive real, where the latter may be 1.

Re: Toward an API for the Real Numbers

#19
post #12

In "safe" languages we often talk about how you can't ignore errors in return values. Your program "leaks" if that happens. But with integer overflows and floating point precision, we just ignore the leaks as something that programmers already know about and have to consider while coding. Of course, it's not an easy problem to deal with, as computers don't have infinite memory and they need to be performant, but we r…

> the ability to define the kind of numbers you want to be working with and their precision is fairly poor in computer science...

It's poor because it's undecidable. We would ideally want to work with the real numbers, but no computational model can represent all real numbers (by a trivial cardinality argument).

Obviously, we can make useful progress in practice and evolve beyond the floating point representation (at least for general tasks), similar to what we did for other theoretically undecidable problems (like garbage collectors), but let's not pretend it's something that's easy to fix.

The paper is interesting and talks about very real problems, but it's still a far cry from something that can be used in production.

Post reply on HN