function F = myExp( x )
%  myExp exponential using Taylor series *****************************
%   Taylor series around x=0 computed to a given finite tolerance    *
%   Type "help myExp" in command window to see this header           *
%   Math 430 * Math 635 * Lecture 6 * Sep 21, 2015 * Victor Matveev  *
% ********************************************************************

F    = 1;
term = 1;
k    = 1;

while max(term) > 1e-6     % "max" needed in case "x" is a list of values
    term = term .* x / k;  % Note the dot in ".*": element-by-element product 
    F    = F + term; 
    k    = k + 1;
    disp( [ 'myExp terms = [', num2str(term), ']' ] );
end

