Live data from Hacker News

Toward an API for the Real Numbers

blog.acolyer.org

21–30 of 85 posts

Re: Toward an API for the Real Numbers

#21
IEEE 754. If you're going to do any serious computation in floating point, serious meaning people's lives are going to depend on the outcome or a lot of money is on the line, then you MUST know what you're doing. We have standards in place so people can learn it, people creating math libraries can adhere to it, and those creating these kinds of applications can have confidence that things are going to work. I'm sorry addition isn't commutative, there are known ways for dealing with it. I took two courses in Numerical Computing in college. Trust me, the people working in this space are serious, and really, there's a few basic rules of the road you need to learn and you're on your way.

Re: Toward an API for the Real Numbers

#22
post #17

(sin⁻¹(cos⁻¹(tan⁻¹(tan(cos(sin(9))))))−9)^−1 produces "Timeout. Undefined?". That's the closest I could get to baffling or tricking it. (it's division by zero)

Is there a typo in that? Where's the division by zero?

Wolfram alpha has that as exactly equal to

    1/(3pi - 18)
https://www.wolframalpha.com/input/?i=%28sin%E2%81%BB%C2%B9%...

Re: Toward an API for the Real Numbers

#25
post #22
post #17

(sin⁻¹(cos⁻¹(tan⁻¹(tan(cos(sin(9))))))−9)^−1 produces "Timeout. Undefined?". That's the closest I could get to baffling or tricking it. (it's division by zero)

Is there a typo in that? Where's the division by zero? Wolfram alpha has that as exactly equal to 1/(3pi - 18) https://www.wolframalpha.com/input/?i=%28sin%E2%81%BB%C2%B9%...

It's multi-valued, I suppose. tan^-1 (tan (x)) is equal to x plus any integer multiple of pi (or of 180°). Same for the other pairs of functions. But one of the values results in a division by zero.

Re: Toward an API for the Real Numbers

#26
post #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…

Surely working with computable reals is sufficient? There's no point in writing a computer program that attempts to work with non-computable reals, for obvious reasons. And computable reals are countable.

Re: Toward an API for the Real Numbers

#28
post #19

Earlier quoted context omitted.

> 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…

Surely working with computable reals is sufficient? There's no point in writing a computer program that attempts to work with non-computable reals, for obvious reasons. And computable reals are countable.

Equality of computable reals is undecidable.

https://mathoverflow.net/questions/40618/uncomputability-of-...

Re: Toward an API for the Real Numbers

#29
post #19

Earlier quoted context omitted.

> 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…

Surely working with computable reals is sufficient? There's no point in writing a computer program that attempts to work with non-computable reals, for obvious reasons. And computable reals are countable.

It certainly is. The point is, is it necessary? (To be really pedantic one could ask which computable reals, but let's assume the usual definition, i.e. the set of reals defined by a computable Dedekind cut.)

Although computable reals have many properties shared by the actual real numbers (e.g. they are a field, which is not that trivial of a property), they are also different in very significant ways, for example, they aren't computably comparable, they aren't computably enumerable, their order is not computable.

Also, real analysis works very differently on that set, for example, it is not guaranteed that the least upper bound of a bounded increasing sequence of elements of the computable reals is itself a computable real.

Even ignoring feasibility in practice, working with non-standard mathematical structures is very unintuitive, much more than floating point numbers can be. (Let alone reasoning about the time-complexity of operations in that setting!)

Re: Toward an API for the Real Numbers

#30
post #22
post #17

(sin⁻¹(cos⁻¹(tan⁻¹(tan(cos(sin(9))))))−9)^−1 produces "Timeout. Undefined?". That's the closest I could get to baffling or tricking it. (it's division by zero)

Is there a typo in that? Where's the division by zero? Wolfram alpha has that as exactly equal to 1/(3pi - 18) https://www.wolframalpha.com/input/?i=%28sin%E2%81%BB%C2%B9%...

You did it in radians. Try degrees.

Edit: (Or use 0.15708 instead of 9 in your link.)

Post reply on HN