Optimizing a+b-a-b etc.

James Demmel uunet!imafs.ima.umn.edu!demmel
Sun May 10 07:51:19 PDT 1992


These sorts of expressions appear in code which simulates double precision,
and are an essential part of least one current LAPACK routine, and I plan
to use it more widely in an IEEE arithmetic version of LAPACK currently
under development. A typical code sequence is the following, which returns
A and B representing the exact sum of C and D, where B is precisely the
roundoff committed while computing A.

  A = C+D
  if (abs(C)<abs(D)) swap C and D
  B = (A-C)-D

Parentheses must be respected. It would break the code to replace B by 0.
For more details, see, for example, the paper by Doug Priest in the 
Proceedings of the 10th Symposium on Computer Arithmetic (IEEE, 1991). Jim Demmel



More information about the Numeric-interest mailing list