function [ c, z ] = data_to_newton ( x, y )

%*****************************************************************************80
%
%% data_to_newton computes the Newton representation of an interpolant to data.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    16 November 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real x(n), y(n): the data.
%
%  Output:
%
%    c(d+1), z(d+1): the coefficients and centers of the Newton form of the
%    interpolating polynomial to the data.
%
  n = length ( x );
  d = n - 1;

  c = y;
  for i = 2 : d + 1
    for j = d + 1 : -1 : i
      c(j) = ( c(j) - c(j-1) ) / ( x(j) - x(j+1-i) );
    end
  end

  z(1:d+1) = x(1:n);

  return
end

