% Math 5610/6860 - Numerical Analysis I % Computer lab #2, problem 3 % here is a demonstration of a series of operations where the relative error is % not guaranteed to be less than machine epsilon x = 1; y=2^-54; z=1; % this is rounded to 1 since y < machine epsilon fprintf('x+y= %e (rounding takes out y) \n',x+y); % therefore the following gives the wrong answer!! fprintf('(x+y)-z= %e (wrong answer)\n',(x+y)-z); % note: in Matlab you can find out what is machine epsilon by using the % builtin function eps: fprintf('machine epsilon is: %e and should be %e\n',eps,2^-52);