function x = r8vec_cheby2space ( n, a, b )

%*****************************************************************************80
%
%% r8vec_cheby2space() creates a vector of Type 2 Chebyshev spaced values.
%
%  Discussion:
%
%    A set of points with Chebyshev spacing is generated for the
%    interval [A,B].
%
%    An R8VEC is a vector of R8's.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 July 2017
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of entries in the vector.
%
%    real A, B, the interval endpoints.
%
%  Output:
%
%    real X(N,1), a vector of Type 2 Chebyshev spaced data.
%
  x = zeros ( n, 1 );

  for i = 1 : n

    theta = ( n + 1 - i ) * pi / ( n + 1 );

    c = cos ( theta );

    x(i) = ( ( 1.0 - c ) * a  ...
           + ( 1.0 + c ) * b ) ...
           /   2.0;

  end

  return
end
