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