coding UTF-8; // Specify character encoding (to avoid text corruption) import Math; // Import math function library import tool.Graph2D; // Import graphing library // Parameter constants for integration const double A = 0.0; // Lower bound of integration interval const double B = 1.0; // Upper bound of integration interval const int N = 10; // Number of small intervals (larger = finer = more accurate) // The function to be integrated: f(x) = cos(x) double f(double x) { return cos(x); } // --------------------------------------------- // Numerical integration using Simpson's Rule // --------------------------------------------- double delta = (B - A) / N; // Width of a small interval (Delta x) double value = 0.0; // Result of integration (total area) for(int i=0; i