function c = r8poly_chebyshev ( d )

%*****************************************************************************80
%
%% r8poly_chebyshev() returns coefficients of the Chebyshev polynomial T(n,x).
%
%  Discussion:
%
%    D/K     0     1      2      3       4     5      6    7      8    9   10
%
%     0      1
%     1      0     1
%     2     -1     0      2
%     3      0    -3      0      4
%     4      1     0     -8      0       8
%     5      0     5      0    -20       0    16
%     6     -1     0     18      0     -48     0     32
%     7      0    -7      0     56       0  -112      0    64
%     8      1     0    -32      0     160     0   -256     0   128
%     9      0     9      0   -120       0   432      0  -576     0  256
%    10     -1     0     50      0    -400     0   1120     0 -1280    0  512
%
%  Recursion:
%
%    T(0,X) = 1,
%    T(1,X) = X,
%    T(N,X) = 2 * X * T(N-1,X) - T(N-2,X)
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    23 July 2004
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Milton Abramowitz, Irene Stegun,
%    Handbook of Mathematical Functions,
%    US Department of Commerce, 1964.
%
%  Input:
%
%    integer D: the degree.
%
%  Output:
%
%    real C(1:D+1): the coefficients.
%
  if ( d < 0 )
    c = [];
    return
  end

  c = [ 1.0 ];
  if ( d == 0 )
    return
  end

  cdm1 = c;
  c = [ 0.0; 1.0 ];

  for i = 2 : d
    cdm2 = cdm1;
    cdm1 = c;
    c = zeros ( i + 1, 1 );
    c(2:i+1) = 2.0 * cdm1(1:i);
    c(1:i-1) = c(1:i-1) - cdm2(1:i-1);
  end

  return
end
