function result = summit ( func, n, x, w )

%*****************************************************************************80
%
%% summit() carries out a quadrature rule over a single interval.
%
%  Discussion:
%
%    result = sum ( 1 <= i <= n ) w(i) * func ( x(i) )
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    15 October 2005
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    external FUNC, the name of the function which
%    evaluates the integrand.  The function must have the form
%      function func ( x ).
%
%    integer N, the order.
%
%    real X(N), the abscissas.
%
%    real W(N), the weights.
%
%  Output:
%
%    real RESULT, the approximate integral.
%
  if ( n < 1 )
    fprintf ( 1, '\n' );
    fprintf ( 1, 'summit - Fatal error!\n' );
    fprintf ( 1, '  N must be at least 1.\n' );
    fprintf ( 1, '  The input value was N = %d\n', n );
    error ( 'summit - Fatal error!' );
  end

  result = 0.0;
  for i = 1 : n
    result = result + w(i) * func ( x(i) );
  end

  return
end
