function box=difftable(x,y) %This routine calculates the table of divided differences %for the data (x(i),y(i)). s=size(y); n=s(1); box=zeros(n,n); %Initialize the first column of the difference table = y. for ii=1:n box(ii,1)=y(ii); end %Compute the table of divided differences. for k=2:n for ii=1:n-k+1 box(ii,k)=(box(ii+1,k-1)-box(ii,k-1))/(x(ii+k-1)-x(ii)); end end