function [ xtab2, diftab2 ] = dif_append ( xtab, diftab, xval, yval )

%*****************************************************************************80
%
%% dif_append() adds a pair of data values to a divided difference table.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    16 November 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real XTAB(NTAB), the abscissas of the table.
%
%    real DIFTAB(NTAB), the difference table.
%
%    real XVAL, the X data value to be inserted as XTAB(1).
%
%    real YVAL, the Y data value to be inserted as YTAB(1).
%
%  Output:
%
%    real XTAB2(NTAB+1), the updated abscissas.
%
%    real DIFTAB2(NTAB+1), the updated difference table.
%
  ntab = length ( xtab );
%
%  Move the original data up one index and insert the new data.
%
  ntab2 = ntab + 1;
  xtab2 = zeros ( ntab2, 1 );
  diftab2 = zeros ( ntab2, 1 );

  diftab2(2:ntab2) = diftab(1:ntab);
  diftab2(1) = yval;

  xtab2(2:ntab2) = xtab(1:ntab);
  xtab2(1) = xval;
%
%  Recompute the difference table.
%
  for i = 2 : ntab2
    diftab2(i) = ( diftab2(i) - diftab2(i-1) ) / ( xtab2(i) - xtab2(1) );
  end

  return
end
