function q = quad_serial ( f, a, b, n )

%*****************************************************************************80
%
%% quad_serial() estimates an integral using a quadrature rule.
%
%  Discussion:
%
%    Note that MATLAB supplies a different function called quad().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    18 October 2024
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    function f ( x ):
%
%    real a, b: the limits of integration.
%
%    integer n: the number of sample points.
%
%  Output:
%
%    real q: an estimate for the integral of f(x) over the interval.
%
  q = 0.0;
  for i = 1 : n
    x = ( ( n - i ) * a + ( i - 1 ) * b ) / ( n - 1 );
    q = q + f ( x );
  end

  q = ( b - a ) * q / n;
 
  return
end

