0001
0002
0003
0004 format shortE;
0005 x = 2.449;
0006 e = 1e-6;
0007 [res, abserr, relerr, n] = sinbysum(x, e);
0008 disp(['using tolerance ', num2str(e), ' sin of ', num2str(x), ...
0009 ' is approximated by ', num2str(res), ' after ', num2str(n), ...
0010 ' iterations with absolute error ', num2str(abserr), ...
0011 ' and relative error ', num2str(relerr)]);
0012
0013 x =20;
0014 e=1;
0015 [res, abserr, relerr, n] = sinbysum(x, e);
0016 disp(['using tolerance ', num2str(e), ' sin of ', num2str(x), ...
0017 ' is approximated by ', num2str(res), ' after ', num2str(n), ...
0018 ' iterations with absolute error ', num2str(abserr), ...
0019 ' and relative error ', num2str(relerr)]);
0020
0021 e = 1e-6;
0022 [res, abserr, relerr, n] = sinbysum(x, e);
0023 disp(['using tolerance ', num2str(e), ' sin of ', num2str(x), ...
0024 ' is approximated by ', num2str(res), ' after ', num2str(n), ...
0025 ' iterations with absolute error ', num2str(abserr), ...
0026 ' and relative error ', num2str(relerr)]);