In reply to Karrar.

Theoretically, each method is based on evenly dividing an interval into subintervals. The trapezoidal rule uses a linear approximation to the function on each interval, whereas Simpson's rule uses a quadratic approximation. The area under the (approximate) curve is computed for each subinterval, and the areas are summed to approximate the integral on the full interval. Because Simpson's rule uses a quadratic approximation on each subinterval, Simpson's rule is more accurate when each method uses the same number of subintervals. The advantage of the trapezoidal rule is that it is very fast and it is exact for piecewise linear functions.