The following infinite series can be used to approximate ex
     The following infinite series can be used to approximate e^x;  e^x  = 1 + x +x^2/2! + x^3/3! + ...  Starting with the simplest version, e^x = 1, add terms one at a time to estimate e^3.5. After each new term is added, compute the true and approximate relative percent error. Use your pocket calculator or MATLAB to determine the true value. Add terms until the absolute value of the approximate error estimate falls below 0.01%. Write a MATLAB code to perform this process. 
  
  Solution
% Attached matlab code for the question
actual = exp(3.5); %actual value of e^3.5
 x = 3.5;
 calculated = 1.0; % temperory value of e^3.5
 pow = 1;
 fact = 1;
 while(abs(calculated - actual)/actual*100 > 0.01) % check if the error is less than 0.01%
 calculated = calculated + (x^pow)/(fact*pow); % add new term in the expansion of e^3.5
 fact = fact*pow;
 pow = pow + 1;
 end
 calculated % final aproximate value of e^3.5

