function value = poly_value_termwise ( c, x )

%*****************************************************************************80
%
%% poly_value_termwise evaluates a polynomial in power form termwise.
%
%  Discussion:
%
%    The power sum form of a polynomial is:
%
%      p(x) = c(0) + c(1) * x + ... + c(n-1) * x^(n-1) + c(n) * x^(n)
%
%    Because MATLAB doesn't allow 0 indexing, we use an adjusted formula:
%
%      p(x) = c(1) + c(2) * x + ... + c(n) * x^(n-1) + c(n+1) * x^(n)
%
%  Input:
%
%    real C(n+1): the coefficients of the polynomial.
%
%    real X: the evaluation point.
%
%  Output:
%
%    real VALUE: the value of the polynomial at X.
%
  d = length ( c ) - 1;
  value = 0.0;
  for i = 0 : d
    value = value + c(i+1) * x^i;
  end
  return
end

