%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Computational Physics % FALL 2008 % % Instructor: Kevin H. Knuth % % % HW 2 % Summing a Series % % The purpose of this homework set is to introduce you to writing % efficient Matlab functions that are designed to be conscious of both % numerical errors and speed. % % % TURN IN: % m-files titled mySINE.m % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Problem by: Kevin H. Knuth % Created on: 09 January 2008 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Write a function mySINE that computes the sine of an angle in radians % with an accuracy of 1e-15 % This routine should rely on summing a Taylor series expansion of sine. % % In a separate report, compare the accuracy of your routine for the % values: 0, pi/4, pi/2, pi, and 2 pi. % In addition, explain the strategy used in the summation, and how many % terms you used. % % Be sure to consider the range over which the Taylor series is reasonable. % % % Usage: y = mySINE(x) % Inputs: x - angle in radians % Outputs: y - sin(x) % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%