%
% s02lnx.m Taylor approximation to f(x)=ln(1+x)
%
X=0:0.05:2;
Y=log(1+X);    % log is the natural function ln
Z=X - X.^2/2 + X.^3/3 - X.^4/4 + X.^5/5;
% - X.^6/6 + X.^7/7;
plot(X,Y,'r-',X,Z,'b-');  axis([0,2, 0,1]);
legend('ln(1+x)','Taylor polynomial of degree 5','Location','Southeast')
title('Taylor approximation for ln(1+x)')