Home > K25104 > Fundamentals > sinbysum_script.m

sinbysum_script

PURPOSE ^

Usage example for sinbysum

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 Usage example for sinbysum
 related to Exercise 1.2

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Usage example for sinbysum
0002 % related to Exercise 1.2
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)]);

Generated on Mon 18-Jan-2016 10:25:49 by m2html © 2005