function s = nTermSine1(x,n,verbose)
% nTermSine1  Evaluate the n-term series approximation to sin(x)
%             Simplest approach: evaluate each term from scratch
%
% Synopsis:  s = nTermSine(x)
%            s = nTermSine(x,n)
%            s = nTermSine(x,n,verbose)
%
% Input:  x = argument of sine, i.e. compute sin(x)
%         n = (optional) number of terms to evaluate.  Default: n = 5
%         verbose = (optional) flag to control printing of intermediate
%                   results.  Default: verbose = false, no printing
%
% Output:  s = n-term approximation to sin(x)

if nargin<2, n=5;            end
if nargin<3, verbose=false;  end

% -- Initialize the series and print deader if desired
term = x;
s = term;
sgn = 1;
if verbose
  fprintf('\n    i   sign    k        term             s\n');
  fprintf(' %4d  %4d  %4d  %18.13f  %8.5f\n',1,sgn,1,term,s);
end

% -- Loop for terms 2 to n
for i=2:n
  sgn = -sgn;          %  switch sign of term
  k = 2*i - 1;
  term = sgn*(x^k)/factorial(k);
  s = s + term;
  if verbose, fprintf(' %4d  %4d  %4d  %18.13f  %8.5f\n',i,sgn,k,term,s); end
end