c - Rounding a double to avoid round off in subsequent summation -
how implement this?
// round nearest double x + ref doesn't cause round off error double round(double x, double ref) { } so that
double x = ....; double y = ....; double x_new = round(x, y); return x_new + y; // no round off! in other terms (y + x_new) - x_new strictly equal y
let assume x , y both positive.
let s double-precision sum x + y.
there 2 cases:
if
x≤y,s - yexact sterbenz's lemma. follows addition(s - y) + yexact (it producess, double-precision number). therefore, can picks - yx_new. noty + x_newexact, produces same resultsy + x.if
x>y, depending on number of bits set in significand ofy, may have problem. if last bit in significand ofyset, instance, no numberzin binade after binade ofycan have propertyz + yexact.
this answer vaguely related that answer.
Comments
Post a Comment