%-----------------------------------------------------------------------
  function y = MyExp4(x)
% y = MyExp4(x)
% x is a p-vector
% y is a p-vector of the same shape as x
% and with the property that y(i) is the
% Taylor approximation to exp(x(i)) for 
% i = 1:p; p = size(x)
y = zeros(size(x));
term = ones(size(x));
k = 0;
while any(abs(term) > eps*abs(y))
   y    = y + term;
   k    = k + 1;
   term = x.* term/k;
end
