%Script file to look at the maximum error: k=5; %Number of data points n=k-1; %Degree of polynomial to use x=[-1 -1/2 0 1/2 1]; f=inline('exp(x)'); y=f(x); %Construct the degree 4 polynomial and plot the results: coefs=newtdd(x,y); cx=linspace(min(x),max(x)); cy=nest(n,coefs,cx,x); ty=f(cx); plot(x,y,'k*',cx,cy); %Look at the error: P=inline('(exp(1)/factorial(5))*(x+1).*(x+1/2).*x.*(x-1/2).*(x-1)'); cf=P(cx); figure(2) plot(cx,cf,'k-',cx,ty-cy,'b-'); title('Maximum error (black) and actual error (blue)');