|
|
|
#include "integral.h"
|
|
|
|
static double f(double x) { return 4.0 / (1 + x * x); }
|
|
|
|
double integral_cpu(size_t num_intervals) {
|
|
double dx = (1.0 / (double) num_intervals);
|
|
double sum = 0;
|
|
for (size_t i = 0; i < num_intervals; i++) { sum += f(i * dx) * dx; }
|
|
return sum;
|
|
}
|