function y = dividedDifference1(t,y)
% Divided difference for computing coefficients x
% in Newton's interpolant using a singly 
% subscripted variable rather than a 2D array.
% Given data points: (t1, y1), ... (tN, yN)
% t is the row or column vector (t1 t2 ... tN)
% y is the row or column vector (y1 y2 ... yN)
% Resulting coefficients stored back in y.
% Usage: x = dividedDifference1([-2 0 1], [-27 -1 0])
% K. Ming Leung, 03/06/03

N=length(t); 
for k=2:N
    for i=N:-1:k
        y(i)=(y(i)-y(i-1))/(t(i)-t(i-k+1));
    end
end

