function s = nTermSine3(x,n)
% nTermSine3  Evaluate the n-term series approximation to sin(x)
%             Recursive evaluation of terms and check convergence
%
% Synopsis:  s = nTermSine3(x,n)
%
% Input: x = argument of sine(x)
%        n = number of terms in the series
%
% Output: s = approximation to sin(x) with a maximum of n terms
%             of the series.  Stop when abs(term/sum) < tol
%             where tol = 5e-6

term = x;
s = term;   %  initialize the sum and the sign of the term
tol = 5e-6;
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)
  if abs(term/s) < tol
	  break;
  end
end