#include #include // Parameter constants #define A 0.0 // Lower bound of the integration interval #define B 1.0 // Upper bound of the integration interval #define N 10 // Number of subdivisions (higher = more accurate) // Function to integrate: f(x) = cos(x) double f(double x) { return cos(x); } int main(void) { // -------------------------------------------------- // Numerical integration using the trapezoidal method // -------------------------------------------------- double delta = (B - A) / N; // Width of each trapezoid: Delta x double value = 0.0; // Final result (total area) int i; for(i=0; i