function chebyshev1_test ( n )

%*****************************************************************************80
%
%% CHEBYSHEV1_TEST seeks equidistribution results for Chebyshev points.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    09 August 2016
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'CHEBYSHEV1_TEST\n' );
  fprintf ( 1, '  Examine the equidistribution property of the Chebyshev1\n' );
  fprintf ( 1, '  points X.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  The points X are defined on [-1,+1]\n' );
  fprintf ( 1, '  They have density 1/pi * 1/sqrt(1-x^2)\n' );
  fprintf ( 1, '  They can be bracketed by points X2\n' );
  fprintf ( 1, '  Let H(I) be the width of the interval containing X(I).\n' );
  fprintf ( 1, '  Let R(I) be the density function at X(I).\n' );
  fprintf ( 1, '  We seek an equidistribution property that relates\n' );
  fprintf ( 1, '  H and R, probably of the form:\n' );
  fprintf ( 1, '    H proportional to 1 / R^J, with J = 1, 2 or 3.\n' );
  fprintf ( 1, '  So compute S(J) = H * R^J for each point.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  T = ( 2.0 * n + 1 - 2 * ( 1 : n ) ) * pi / ( 2 * n ) \n' );
  fprintf ( 1, '  X = cos ( T )\n' );
  fprintf ( 1, '  T2 = ( 2.0 * n - 2 * ( 0 : n ) ) * pi / ( 2 * n )\n' );
  fprintf ( 1, '  X2 = cos ( T2 )\n' );
  fprintf ( 1, '  H = X2(2:n+1) - X2(1:n)\n' );
  fprintf ( 1, '  R = 1/sqrt(1-x^2)\n' );
  fprintf ( 1, '  S(J) = H / R^J, J = 1, 2, 3\n' );
%
%  X = N Chebyshev1 points.
%
  t = ( 2.0 * n + 1 - 2 * ( 1 : n ) ) * pi / ( 2 * n );
  x = cos ( t );
%
%  X2 = N+1 interleaved Chebyshev points
%
  t2 = ( 2.0 * n - 2 * ( 0 : n ) ) * pi / ( 2 * n );
  x2 = cos ( t2 );
%
%  H = size of a disjoint interval containing X.
%
  h = x2(2:n+1) - x2(1:n);
%
%  R = rho at X.
%
  r = 1.0 ./ sqrt ( 1.0 - x.^2 );
%
%  S = H / R^(power)
%
  s1 = h .* r.^1;
  s2 = h .* r.^2;
  s3 = h .* r.^3;

  fprintf ( 1, '\n' );
  fprintf ( 1, '   I           X           H         Rho     H*Rho^1     H*Rho^2     H*Rho^3\n' );
  fprintf ( 1, '\n' );
  for i = 1 : n
    fprintf ( 1, '  %2d  %10.4g  %10.4g  %10.4g  %10.4g  %10.4g  %10.4g\n', i, x(i), h(i), r(i), s1(i), s2(i), s3(i) );
  end

  fprintf ( 1, '\n' );
  fprintf ( 1, 'CHEBYSHEV1_TEST\n' );
  fprintf ( 1, '  Normal end of execution.\n' );

  return
end

