Hacker News new | ask | show | jobs
by SPACECADET3D 3 days ago
Thanks for the clarification! Hyperreal sounds very useful for zero testing (at the moment I use ErrorPropagatingFloat for this, but it is fickle), I will play around with this in the near future.
1 comments

Yes, it should be useful for that. Hyperreal's trig and approximate functions performance is also stellar. Perhaps the biggest compromise in terms of the math supported by hyperreals at the moment is that although Rational equality can be exactly tested, Computable equality is currently structural. So it's possible to end up with two mathematically equivalent Computables which aren't structurally equal. Because it's not a full CAS.

It's still possible to approximate them both, and test them against each other, but since the whole architecture is built to reduce, avoid, and cache approximations because they're expensive, it's not the default.

In the end the zero test problem is undecidable for reasonably complicated expressions, so sadly there is no guarantee that you can rewrite one Computable into another even if they evaluate to the same. For polynomials you can do finite field evaluation tests to prove equality with a likelihood bound of your choosing. That may be interesting for hyperreal too.
Yes. One of those problems with no neat solution, and worse no performant one. :)

You might find this bit of performance engineering interesting: https://github.com/timschmidt/hyperreal/blob/8a016808f4b0ba3...

The matrix math layer wanted that kind of optimization to avoid worst case operations.