double sum = 0;
for (int i = 0; i < n; i++) {
// Integrate over each sub-interval [a, b].
final double a = min + i * step;
final double b = a + step;
final GaussIntegrator g = FACTORY.legendreHighPrecision(numberOfPoints, a, b);
sum += g.integrate(f);
}
return sum;
}