% ATANSUM  Computes a partial sum of the Maclaurin series for
%   arctan(x).  Evaluates at x=0.3, and compares to value from
%   built-in function.

x = 0.3;
y = 0.0;
for i = 1:99
  y = y + (-1)^(i+1) * x^(2*i-1) / (2*i-1);  % y is partial sum
end

% print out partial sum, built-in value of arctan, and actual error:
y
atan(x)
err = abs(y - atan(x))

