# include "quad_serial.hpp" using namespace std; //****************************************************************************80 double quad_serial ( double f ( double x ), double a, double b, int n ) //****************************************************************************80 // // Purpose: // // quad_serial() estimates the integral of a function. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 18 October 2024 // // Author: // // John Burkardt // // Input: // // function f ( x ): the function whose integral is to be estimated. // // real a, b: the limits of integration. // // integer n: the number of // // Output: // // real q: an estimate for the integral of f(x) over the interval. // { int i; double q; double x; q = 0.0; for ( i = 0; i < n; i++ ) { x = ( ( n - i - 1 ) * a + ( i ) * b ) / ( n - 1 ); q = q + f ( x ); } q = ( b - a ) * q / ( double ) n; return q; }