From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 30521 invoked from network); 29 Jul 1999 21:07:52 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 29 Jul 1999 21:07:52 -0000 Received: from saaz.cam.nist.gov (donahue@saaz.cam.nist.gov [129.6.88.116]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id RAA05226 for ; Thu, 29 Jul 1999 17:07:51 -0400 Received: (from donahue@localhost) by saaz.cam.nist.gov (8.8.7/8.8.7) id RAA18034; Thu, 29 Jul 1999 17:07:49 -0400 Date: Thu, 29 Jul 1999 17:07:49 -0400 Message-Id: <199907292107.RAA18034@saaz.cam.nist.gov> X-Authentication-Warning: saaz.cam.nist.gov: donahue set sender to donahue@saaz.cam.nist.gov using -f From: "Michael J. Donahue" To: axp-list@redhat.com In-reply-to: (hjstein@bfr.co.il) Subject: Re: Float Pt Precision Reply-to: michael.donahue@nist.gov (Michael Donahue) References: <199907291557.LAA17800@saaz.cam.nist.gov> Harvey J. Stein writes: >"Michael J. Donahue" 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/