Topic: Numeric precision (was is_exact: what is meant?)
Author: dacut@ugcs.caltech.edu (David A. Cuthbert)
Date: 1996/09/29 Raw View
I've added comp.lang.c++.moderated to the newsgroups line and set
followups there since my article doesn't really apply to
standardization anymore.
Stan Friesen <swf@elsegundoca.ncr.com> wrote:
>Computers cannot really meaningfully represnt irrationals at all.
>No matter *what* representation one uses, the end product will ultimately
>be a rational number - albeit possibly with an enormous denominator.
"At all" is not quite correct; Mathematica, for example, will happily
represent something like Sqrt[2] exactly. It would not be a big leap
to create a class to represent numbers in this fashion.
Of course, there are an infinity of irrationals that cannot be
represented as the root of a rational number, either. The problem
here is that you can only define a finite set of such numbers (Pi, E,
etc.). Egyptian fractions (e.g., 1 + 1/(1 + 1/(1 + ...))) have no
obvious representation (that I can think of), whether they amount to a
rational or irrational number.
>The net result, of course, is that numeric results using machine FP can be
>unintuitive. Tuning numerical extensive calculations so that the final result
>does not lose too much precision is a trickly, and difficult process.
>[UC Berkeley even has an entire course just on that one subject].
The biggest danger probably comes from functions operating at the
limit of convergence (unstable equilibria and the like). A small
inaccuracy can cause the output to swing wildly (e.g., ArcTan near
Pi/2), making the results very unintuitive, as you point out.
Has anyone seen a good (perhaps non-C++ specific?) reference on
creating objects for precise numerical calculations? Better yet, are
there any freely-available objects for such calculations?
--
David A. Cuthbert
dacut@ugcs.caltech.edu
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]