function v = t_polynomial_antiderivative ( m, n, x )

%*****************************************************************************80
%
%% t_polynomial_antiderivative() evaluates the antiderivative of T(N,X).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    31 January 2016
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer M, the number of evaluation points.
%
%    integer N, the highest polynomial to compute.
%
%    real X(M,1), the evaluation points.
%
%  Output:
%
%    real V(1:M,1:N+1), the values of the antiderivatives of Chebyshev 
%    polynomials 0 through N at X(1:M).
%
  if ( n < 0 )
    v = [];
    return
  end

  x = x(:);

  v = zeros ( m, n + 1 );

  v(1:m,1) = x(1:m,1)

  if ( n < 1 )
    return
  end

  v(1:m,2) = 0.5 * x(1:m,1) .^2;

  if ( n < 2 )
    return
  end if

  tnm1 = t_polynomial ( m, n - 1, x );
  tnp1 = t_polynomial ( m, n + 1, x );
 
  for i = 2 : n
    v(1:m,i+1) = 0.5 * ( tnp1(1:m,i) / ( i + 1 ) - tnm1(1:m,i) / ( i - 1 ) );
  end
 
  return
end
