Consider the following example, executed in Matlab:
x = linspace(-pi, pi, 10^4);
x_R = chop(x, 3);
y = sin(x);
y_R = sin(x_R);
s = sum(y);
s_R = sum(y_R);
abs_err_sum = abs(s_R - s);
rel_err_sum = abs_err_sum/abs(s);
m = mean(y);
m_R = mean(y_R);
abs_err_mean = abs(m_R - m);
rel_err_mean = abs_err_mean/abs(m);
The relative error for the sums ended up being minutely bigger than that of the means (not by much: a difference of 1.1102e-16), but I do not understand why, particularly since computing the mean also involves computing the same sum (unless Matlab mean() does not itself use the same sum() function itself?).
To give more context, this is part of an assignment that we are creating for students, based on an assignment that I myself had when I was a student. The original question in that assignment was "In this case, is the sum operator more robust to digit cancellation or the mean operator? Why?" I am beginning to think that the question was not phrased in the best way and perhaps both are equally robust.