function s = nTermSine2(x,n) % nTermSine2 Evaluate the n-term series approximation to sin(x) % Recursive evaluation of each term % % Synopsis: s = nTermSine2(x,n) % % Input: x = argument of sine(x) % n = number of terms in the series % % Output: s = approximation to sin(x) with n terms of the series term = x; s = term; % initialize the sum and the sign of the term fprintf('\n i term s\n'); fprintf(' %4d %18.13f %8.5f\n',1,term,s); for i=3:2:(2*n-1) term = -term*(x^2)/(i*(i-1)); s = s + term; fprintf(' %4d %18.13f %8.5f\n',i,term,s) end