From: "Michael J. Donahue" <donahue@saaz.cam.nist.gov>
To: axp-list@redhat.com
Subject: Re: Float Pt Precision
Date: Thu, 29 Jul 1999 17:07:49 -0400 [thread overview]
Message-ID: <199907292107.RAA18034@saaz.cam.nist.gov> (raw)
In-Reply-To: <m2k8rj8f1v.fsf@blinky.bfr.co.il> (hjstein@bfr.co.il)
Harvey J. Stein writes:
>"Michael J. Donahue" <donahue@saaz.cam.nist.gov> writes:
>
> > The difference in the floating point calculations on the x86 vs the
> > Alpha trace back to the hardware implementations. The extra
> > precision in the x86 makes life much easier---it narrows the window
> > of numerical instability in almost every situation.
>
>Can you substantiate this?
Yes. William Kahan had some nice examples using classical triangle
formulae. See
Miscalculating Area and Angles of a Needle-like Triangle
http://www.cs.berkeley.edu/~wkahan/Triangle.pdf
Here's an excerpt:
Nobody can say in advance how badly such inconsistencies might disrupt
a program's logic. Prudence requires their extirpation, and that is
straightforward if the specification of a triangle in object oriented
software is designed by a programmer aware of the problems with
classical formulas and acquainted with reliable numerical algorithms to
solve some of those problems. A programmer unaware of the problems is
unlikely to be enlightened by casual or random testing; those problems
are confined to "ill conditioned" triangles in so tiny a sliver of the
space of all triangles that its location, unknown to the unaware
programmer, is likely to stay unknown.
Fortunately, the same phenomenon as tends to keep the unaware
programmer unenlightened tends to protect his unwitting clients from
harm. As arithmetic precision increases beyond what the data
"deserve," the sliver of triangles treated too inaccurately by the
program shrinks, the likelihood that the programmer will notice it
shrinks, and the risk of harm to his clients shrinks, and usually
shrinks quickly. As algebra has shown above and a picture will show
below,
Every three additional decimal digits of arithmetic precision
carried, in excess of the precision to which data and results are
stored, reduces the incidence of intolerably "ill conditioned"
triangles by factors ...
* near 1/1,000,000 for triangles too nearly right angled,
* less than 1/1,000 for triangles too nearly needle like.
Carrying arithmetic precision somewhat more than twice the precision
to which data and results are stored practically eliminates
intolerably "ill conditioned" triangles.
Wider is better. Plus large, c'est mieux. Breiter ist besser. ...
Notice in the first case (right angled triangles) that you cut the
percentage of "bad triangles" by a factor of _100_ for each additional
decimal digit of precision.
> I've found x86 arithmetic to be
>substantially harder to work with because the excess precision shows
>up unpredicably. After setting two different variables via the same
>computation it's possible for the two variables to be not equal. It
>depends on exactly what goes into registers when. This problem
>doesn't exist on the alphas.
You might want to try the -ffloat-store switch on gcc, although in
general relying on exact representations in floating point is tricky.
For example, (a+b)+c is in general not equal to a+(b+c). If your
compiler is doing any optimizing it is hard to say what you are going to
get...
-m
--
Michael J. Donahue
National Institute of Standards and Technology
Mathematical & Computational Sciences Division
100 Bureau Dr Stop 8910
Gaithersburg, MD 20899-8910
email: michael.donahue@nist.gov
voice: (301) 975-5424
fax: (301) 990-4127
web: http://math.nist.gov/mcsd/Staff/MDonahue/
next prev parent reply other threads:[~1999-07-29 21:07 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-07-29 13:24 Float Pt Precision Uncle George
1999-07-29 14:03 ` Alvin Starr
1999-07-29 14:32 ` Phil Carmody
1999-07-29 15:57 ` Michael J. Donahue
1999-07-29 18:51 ` Harvey J. Stein
1999-07-29 19:47 ` Wes Bauske
1999-07-29 21:05 ` Harvey J. Stein
1999-07-29 21:07 ` Michael J. Donahue [this message]
1999-07-29 14:17 ` Phil Carmody
1999-07-29 14:24 ` Christopher C Chimelis
1999-07-29 16:39 ` Wes Bauske
1999-07-29 23:42 ` Richard Henderson
1999-07-30 13:19 ` Harvey J. Stein
1999-07-30 14:38 ` Uncle George
1999-07-30 14:55 ` Uncle George
1999-07-30 11:18 ` Phil Carmody
1999-07-30 14:52 ` Uncle George
1999-07-30 15:31 ` Phil Carmody
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox