function esumx = exp_sum(x,tol)
%Approximation to e^x to a given tolerance
esumx = 1;
term = 1;
k = 1;
while (max(abs(term)) >= tol)
    term = term.*x./k;
    esumx = esumx + term;
    k = k + 1;
end 
 k-1
end

