When reading about numerical methods, then subtraction cancellation is often a topic.
Simple example of cancellation:
a = 1;
b = 1e-16;
a-(a+b) = 0
hence we loss all information of b.
However, i rarely read about how to check for this problem. Could we not use a simple function to subtract number, which also warns us of problems? Example:
function c = subtract(a,b)
c = a-b;
if abs(c) < 1e-14*a
disp('Warning: Low precision on subtraction');
end
end
There are probably some deficiencies of this simple function - it was just my first idea. Anyway, would something like this work? And why is it not done? (i.e. i have never seen/heard about such checks before).