function ortpol_test ( )

%*****************************************************************************80
%
%% ortpol_test tests ortpol.
%
%  Reference:
%
%    Samuel Conte, Carl de Boor,
%    Elementary Numerical Analysis,
%    Third Edition,
%    SIAM, 2017,
%    ISBN: 978-1-611975-19-2.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ortpol_test\n' );
  fprintf ( 1, '  Test ortpol()\n' );

  n = 21;
  x = linspace ( -1.0, 1.0, n );
  y = f(x);
  w = ones ( n, 1 );

  nterms = 4;
  [ po, error ] = ortpol ( x, y, w, nterms );

  fprintf ( 1, '\n' );
  fprintf ( 1, '     X      P(X)-F(X)\n' );
  fprintf ( 1, '\n' );
  for i = 1 : n
    fprintf ( 1, '  %8.4f, %e\n', x(i), error(i) );
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, '     Orthogonal polynomial coefficients:\n' );
  fprintf ( 1, '\n' );
  for i = 1 : nterms
    fprintf ( 1, '  %8.4f\n', po.D(i) );
  end

  return
end
function value = f ( x )

  value = exp ( x );

  return
end

