function s = powersin ( x )

%*****************************************************************************80
%
%% powersin() evaluates the power series for sin(x).
%
%  Discussion:
%
%    y = POWERSIN(x) tries to compute sin(x) from its power series.
%
%  Licensing:
%
%    Copyright 2014 The MathWorks, Inc.
%
%  Author:
%
%    Cleve Moler
%
%  Reference:
%
%    Cleve Moler,
%    Numerical Computing with MATLAB,
%    SIAM, 2004,
%    ISBN13: 978-0-898716-60-3,
%    LC: QA297.M625,
%    ebook: https://www.mathworks.com/moler/chapters.html
%
  s = 0.0;
  t = x;
  n = 1;
  while ( s+t ~= s );
    s = s + t;
    t = -x.^2/((n+1)*(n+2)).*t;
    n = n + 2;
  end

  return
end
