... // Add the area of the i-th small region value += ( f(x) + f(x+delta) + 4.0 * f(x+delta/2.0) ) * delta / 6.0; ...