function lagrange_value_test ( )

%*****************************************************************************80
%
%% lagrange_value_test() tests lagrange_value().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    06 October 2024
%
%  Author:
%
%    John Burkardt
%
  nd = 4;
  ni = 21;
%
%  Values of f(x) = x^3 - 12 x^2 + 39 x -28 = ( x - 1 ) * ( x - 4 ) * ( x - 7 )
%
  xd = [ 0.0, 2.0, 5.0, 10.0 ];
  yd = [ -28.0, +10.0, -8.0, +162.0 ];
 
  fprintf ( 1, '\n' );
  fprintf ( 1, 'lagrange_value_test():\n' );
  fprintf ( 1, '  lagrange_value() evaluates a Lagrange 1D interpolant.\n' );

  x_min = 0.0;
  x_max = 10.0;
  xi = linspace ( x_min, x_max, ni );

  fprintf ( 1, '\n' );
  fprintf ( 1, '       x      f(x)    Interp\n' );
  fprintf ( 1, '\n' );
  for i = 1 : ni
    yexact = xi(i)^3 - 12 * xi(i)^2 + 39 * xi(i) - 28;
    yi = lagrange_value ( nd, xd, yd, xi(i) );
    fprintf ( 1, '  %10.4f  %14.6g  %14.6g\n', xi(i), yexact, yi );
  end

  return
end

