function value = r8poly_norm ( d, c, a, b )

%*****************************************************************************80
%
%% r8poly_norm() returns the L2 norm of a polynomial P over [A,B].
%
%  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)
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    20 October 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer D: the degree of the polynomial.
%
%    real C(1:D+1): the coefficients of the polynomial.
%
%    real A, B: the endpoints of the interval.
%
%  Output:
%
%    real VALUE: the norm of the polynomial.
%
  c = c(:);
  c2 = r8poly_square ( d, c );
  d2 = 2 * d;
  c2a = r8poly_ant_value ( d2, c2, a );
  c2b = r8poly_ant_value ( d2, c2, b );
  value = sqrt ( c2b - c2a );

  return
end

