function F = NewtonDividedDifference(x,f) % % This function implements Newton's Divided Difference Algorithm % F is the vector of coefficients % % Written by Ming Gu for Math 128A, Fall 2008 % n = length(x); P = diag(f); for k=2:n for j = k-1:-1:1 P(k,j) = (P(k,j+1)-P(k-1,j))/(x(k)-x(j)); end end F = P(:,1);