# include "quad_serial.h" /******************************************************************************/ double quad_serial ( double f ( double x ), double a, double b, int n ) /******************************************************************************/ /* Purpose: quad_serial() estimates an integral. 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; }