function polint_test ( )

%*****************************************************************************80
%
%MATLAB program to try POLINT, the MATLAB version of the FORTRAN program on
% pages 68f of conte/deboor
%
%  Reference:
%
%    Samuel Conte, Carl de Boor,
%    Elementary Numerical Analysis,
%    Third Edition,
%    SIAM, 2017,
%    ISBN: 978-1-611975-19-2.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'polint_test:\n' );
  fprintf ( 1, '  Test polint()\n' );

% try it on the Hermite data on page 69 for the function
F = @(x) 1./x;
Y  = [ 2   2   2  1  4    4     5];
FY = [.5 -.25 .25 1 .25 -.0625 .2];

xx = 1.6:.1:5.1;
plot( xx , F(xx) - horner(polint(Y,FY),xx) ), hold on
plot([2,4,5],zeros(1,3),'ro')
title('the interpolation error'), hold off

  filename = 'polint_test.png';
  print ( '-dpng', filename );
  fprintf ( 1, '  Graphics saved as "%s"\n', filename );

disp('note that the error has a double zero at 4 and a simple zero at 5')
disp(' and appears to have a triple zero at 2, as expected')

  return
end

