function A = divdifs(DA) %this function calculates the divided diff table for DA; %DA is the n,2 input data; %A is the vector of coef of the Newton Form; [n,m] = size(DA); D=zeros(n,n); D(:,1)= DA(:,2); X=DA(:,1); for j=2:n for i=j:n D(i,j)= (D(i,j-1)-D(i-1,j-1))/(X(i)-X(i-j+1)); end end %D A=diag(D);