The essence of the trick is buried quite a few pages down. But read the
whole paper anyway.
>
> "What Every Computer Scientist Should Know about Floating-Point
> Arithmetic", by David Goldberg (including Doug Priest's supplement)
>
. . .
>
> Anyway, here's a good URL to the paper, available freely:
>
> http://www.validgh.com/
>
= = = = = = = = =
S = X[1];
C = 0;
for j = 2 to N
Y = X[j] - C;
T = S + Y;
C = (T - S) - Y;
S = T;
}
An optimizer that believed floating-point arithmetic obeyed the laws of
algebra would conclude that C = [T-S] - Y = [(S+Y)-S] - Y = 0, rendering
the algorithm completely useless . . . optimizers should be extremely
cautious when applying algebraic identities that hold for the
mathematical real numbers to expressions involving floating-point
variables.
= = = = = = = = =
= = =
Loren P Meissner
[log in to unmask]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|