% Plot the first four Taylor polynomials for exp(x). x = [-3:.01:2]; % Set x values fx = exp(x); p0 = ones(size(x)); % Compute Taylor polynomials p1 = p0 + x; p2 = p1 + (x.^2)/2; p3 = p2 + (x.^3)/6; subplot(2,2,1) % Plot results plot(x,fx,'--', x,p0,'-'); legend('f(x)','P_0(x)') title('plot of P_0(x) and f(x)') subplot(2,2,2) plot(x,fx,'--',x,p1,'-'); legend('f(x)','P_1(x)') title('plot of P_1(x) and f(x)') subplot(2,2,3) plot(x,fx,'--',x,p2,'-'); legend('f(x)','P_2(x)') title('plot of P_2(x) and f(x)') subplot(2,2,4) plot(x,fx,'--',x,p3,'-'); legend('f(x)','P_3(x)') title('plot of P_3(x) and f(x)')