Calculates the area underneath a specified curve using the trapezoidal rule.