Home
getexp.m
Aug 31
BuiltByNOF
getexp.m

function y = getexp(x)
%---------------------------------
% Use Taylor series to evaluate
% exp(x). Continue adding terms
% until there is no change in the
% answer.
%---------------------------------
% Usage: y = getexp(x)
%---------------------------------
y = 1;
term = 1;
n = 1;
term = term*x/n;
while (y+term)~=y;
  y = y + term;
  n = n + 1;
  term = term*x/n;
end;

[Home] [getexp.m] [Aug 31]