% MyExp.m   8/31/2006 Darryl Yong
%
% This m-file computes exp(x) using Taylor's
% series.  The input x does not have to be a scalar.
%
function [result]=MyExp(x)
result=1+x;
summand=x;
n=2;
% This loops through until the summand has no further
% impact on the calculated value.
while max(result+summand~=result)
  summand=summand.*x/n;
% Uncomment the line below to get a better idea of what's happening.
%  disp(sprintf('%d   %0.15g  %0.15g',n,result,summand))
  result=result+summand;
  n=n+1;
end