% Simple implementation of the exp() function w/o
% computing the x^i and the i! explicitely
% and termination when convergence is detected
% using a while loop.
% Minas Spetsakis, Feb. 2018

xx = 12.6;

trm = 1.0;
expres = 1.0;
i=1;

while abs(trm)>eps(expres)&(i<1000)
    trm = trm*xx/i;
    expres = expres + trm;
    i = i+1;
end;
fprintf('iter = %d\n',i);
expres
