#include #include #include #include using namespace std; #include "simpson.h" double func( double x ) { return( x * sin( 5.0 * x ) + sqrt( x * x + 1.0 ) ); } int main() { double a = 0.0, b = 10.0; double approx; cout.setf( ios::scientific); // Decimal numbers displayed in scientific cout.precision( 5 ); // notation with 5 digits to the right of the // decimal point for ( int i = 10; i <= 200; i += 10 ) { approx = simpson( func, a, b, i ); // Passing the name of the function // essentially passes the address. cout << "Simpson's rule with n = " << setw(3) << i << ": " << approx << endl; } cout << "\n\n"; system( "PAUSE" ); return( EXIT_SUCCESS ); }