horzLine = '______________________________';
fprintf('\n\n Homework #5, problem 1c');
fprintf('\n\n  m  |   Error   |  myError \n%s\n', horzLine);
x = 1;

for m=1:19
    n = 10^m + 1;  % large odd number
    error(m)   = abs(    sin(x+n*pi) +    sin(x) );    
    myError(m) = abs( newSin(x+n*pi) + newSin(x) );
    fprintf(' %2d  |  %7.1e  |  %7.1e  \n', m, error(m), myError(m));
end

fprintf('%s\n\nCompare error to sin(1)=%.2e\n', horzLine, sin(1));
fprintf('Both "newSin" and built-in sine fail at around n=15-16,\n');
fprintf('e.g., try sin(1 + pi*(2e15+1)) + sin(1)\n\n');

plot(1:19, log(error), 'bo-', 1:19, log(myError), 'rx--', 'Linewidth', 2 ); grid;
legend('Built-in sin(x) error', 'newSin(x) error', 2);
xlabel('m (roughly equal to base 10 logarithm of the angle argument)');
ylabel('logarithm of error');
title('\bf Log of error grows linearly with log of function argument');
