% Plots the error in the Taylor series approximation of e as a function % of the number of terms used in the series. function plot_approx_e % Compute the Taylor series approximation of e with n = 1,2,4,8,16,32,64,128 % terms. n = [1 2 4 8 16 32 64 128]; for j = 1:length(n); en(j) = compute_e(n(j)); end % Compute the absolute error in the approximations using MATLAB's computation % of e as the true value. err = abs(en-exp(1)); % Plot the error on a loglog scale to see how the error decays as a function % of the number of terms in the series. loglog(n,err,'b-');