2 ms·
This one I'm entirely unconvinced of. It is easier for the computer to adapt to us, rather than vice versa. And over time things get easier and easier for the
by btilly 11y ago
This one I'm entirely unconvinced of.
It is easier for the computer to adapt to us, rather than vice versa. And over time things get easier and easier for the computer, while staying the same for us. Which is why over time we wind up interacting with computers in ways that are more and more adapted to us rather than them.
We already have acceptably good algorithms to convert to/from different representations, and roundoff errors are generally acceptable. (If they weren't, we wouldn't default to using floating point for most things.) Where precision matters, we have reasonably efficient implementations of exact integer arithmetic and exact fraction arithmetic. The performance hit from using these is less than the hit from using a high level language like Python versus a low-level language like C.
The main challenge is getting programmers to use the right representation for the purpose that they are using it for. Which is mostly challenging exactly because floating point works so well in practice that it is easy not to learn what its limitations are.
- dnautics 11y agoyou can't use exact fraction arithmetic to take a square root, which comes up, you know, just a little bit, in physics. Of course this is a problem for binary representations, too, but you might as well not start out with an input that is already imprecise.
- lmm 11y agoOn the contrary, you might as well accept imprecision and work with the level of precision you need throughout - or, if you don't know or need to adjust it, work with a symbolic representation.
- btilly 11y agoEvery representation has its limits. :-) In physics it is uncommon to have exact measurements for much of anything except integers. In physics, measurement error is usually a bigger issue than roundoff errors from floating point, so the non-existence of an exact floating point representation of the stated measurement is a non-issue. In the real world, most cases that I'm aware of where we need exact base 10 calculations have to do with dealing with money in a single currency. You would be amazed how often square roots don't come up in this context! Fractions show up as soon as you start doing currency conversions. (In fact the Euclidean algorithm for finding the GCD is believed to have been first developed by merchants for exactly this problem.) They are easy to add to a programming language, but you'd only use them in contexts (like finance) where square roots make no sense. If you want to go beyond fractions to add square roots and so on, you can do algebraic numbers. This is a fairly specialized mathematical need, but Mathematica has done it perfectly well for decades. For arbitrary real numbers, we're sort of stuck. We can come up with representations that can cover any real number that we can talk about. But we can't take 2 arbitrary representations of a real number and in finite time decide whether or not they are actually the same number. That said, Mathematica again solves this problem "well enough" for most practical purposes. See http://mathworld.wolfram.com/Ferguson-ForcadeAlgorithm.html http://mathworld.wolfram.com/Ferguson-ForcadeAlgorithm.html for more.
- dnautics 11y agodepends. If you're running a simulation in physics, e.g. n-body problem, you can choose your parameters to be exact to start off with, and rescale your units to be exact. Moreover, even if you start with measurement error, the error moves in generally a predictable fashion, so it tends to be O(1). A floating point roundoff error is a martingale, with O(sqrt(N)) - unless you "always round up" or "always round down" which is O(N). In the initial domain, the measurement error dominates, but over time fp roundoff gets bigger.
- btilly 11y agoIt still depends. Many simulations in physics are of chaotic systems where the initial measurement error grows exponentially over time and quickly exceeds fp roundoff. Other simulations (for example this comes up in fluid mechanics) can have discretization errors feed back on themselves in an unstable way resulting in artifacts that quickly overwhelm the simulation. This is a complex topic, with ongoing research across multiple fields of study. That said, floating point is a "good enough" default for a surprisingly wide variety of situations.