Skip to content
Prev 69253 / 398526 Next

FAQ 7.31

Robin Hankin <r.hankin at noc.soton.ac.uk> writes:
Shouldn't matter in this sort of case, since the added term is bound
to underflow relative to the partial sum. 

The things to watch out for is that mathematical equality doesn't
imply numerical equality (3 * 0.1 != 0.3), and sometimes granularity
effects in correction terms. We've been bitten by code of the type

   x(n+1) = x(n) + f(x(n))

a couple of times in the numerical code, typically in Newton-type
iterations where the correction term alternates by +/- a few units in
the last place, and the program goes into an infinite loop. Optimizing
compilers can introduce such effects in otherwise functioning code by
applying mathematical transformations (see above...) to the code,
rearranging terms, moving terms outside of loops, folding constants,
etc.