function chebyshev_polynomial_test01 ( )

%*****************************************************************************80
%
%% chebyshev_polynomial_test01() tests t_project_coefficients_data().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    25 June 2016
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'chebyshev_polynomial_test01():\n' );
  fprintf ( 1, '  t_project_coefficients_data() estimates the Chebyshev polynomial\n' );
  fprintf ( 1, '  coefficients for a function given as data (x,fx).\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Here, we use fx = f(x) = x^2 for the data.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Since T(0,x) = 1 and T(2,x) = 2*x^2 - 1, the correct expansion is\n' );
  fprintf ( 1, '  f(x) = 1/2 T(0,x) + 0 T(1,x) + 1/2 T(2,x) + 0 * all other polys,\n' );
  fprintf ( 1, '  if Chebyshev polynomials are based in [-1,+1].\n' );
%
%  Data in [0,1];
%
  a = 0.0;
  b = 1.0;
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Chebyshev polynomials will be based in [%g,%g]\n', a, b );
%
%  Compute data.
%
  m = 20;
  x = rand ( m, 1 );
  d = x.^2;

  r8vec2_print ( m, x, d, '  Data ( X, D ):' );

  n = 4;
  c = t_project_coefficients_data ( a, b, m, n, x, d );
  
  r8vec_print ( n, c, '  Coefficients of Chebyshev expansion of degree 4.' );
%
%  Compare Chebyshev expansion and original function.
%
  d2 = t_project_value_ab ( m, n, x, c, a, b );

  fprintf ( 1, '\n' );
  fprintf ( 1, '   I      X(I)     Data(I)      Chebyshev(X(I))\n' );
  fprintf ( 1, '\n' );
  for i = 1 : m
    fprintf ( 1, '  %2d  %12g  %12g  %12g\n', i, x(i), d(i), d2(i) );
  end

  return
end
