% Clear the screen and display a header
clc
fprintf('     x      x - sin(x)     x - sin(x)     Error     Error\n');
fprintf('             (Exact)        (Naive)        Abs.      Rel.\n');
fprintf('==============================================================\n');

for i=1:10
	% Directly calculate x-sin(x)
	x = 10^-i;
	naive = x - sin(x);
		
	% Exact comparison
	exact = double(sym(10^-i)-sin(sym(10^-i)));

	% Calculate relative and absolute errors
	abserror = abs(naive-exact);
	relerror = abserror / exact;
	
	fprintf(' %7.0e   %7.6e   %7.6e  %7.3e  %7.3e\n', x, exact, naive, abserror, relerror);
end
