function tab = divdiff(x, y)
%
%  DIVDIFF(X, Y) return the table of divided differences based on the data
%  points X, Y. 
%  X, Y are column vectors. 
% 
n = length(x);
tab = zeros(n, n);
tab(:, 1) = y;
for k = 1 : n - 1
    for j = 1 : n - k
        tab(j, k + 1) = (tab(j + 1, k) - tab(j, k)) / (x(j + k) - x(j));
    end
end

% Include the x-values in the table.
tab = [x, tab];
    
