#include #include // Parameter constants for the calculation const double A = 0.0; // Lower bound of the integration interval const double B = 1.0; // Upper bound of the integration interval const int N = 10; // Number of rectangles (more = finer steps = higher accuracy) // Function to integrate: f(x) = cos(x) double f(double x) { return cos(x); } int main() { // ---------------------------------------------------------------------- // Numerical integration using the rectangular method (approximation) // ---------------------------------------------------------------------- const double delta = (B - A) / N; // Width of each rectangle (Delta x) double value = 0.0; // Calculated integral value (total area) for(int i=0; i