function F = NewtonDividedDifference2(x,f,df) % % This function implements Newton's Divided Difference Algorithm % for Hermite Interpolation. F is the vector of coefficients % % Written by Ming Gu for Math 128A, Fall 2008 % n = length(x); z = kron(x(:),ones(2,1)); P = diag(kron(f(:),ones(2,1))); for k=2:2*n j = k - 1; if (mod(k,2)== 0) P(k,j) = df(k/2); else P(k,j) = (P(k,j+1)-P(k-1,j))/(z(k)-z(j)); end for j = k-2:-1:1 P(k,j) = (P(k,j+1)-P(k-1,j))/(z(k)-z(j)); end end F = P(:,1);