pub fn trapezoid(f: impl Fn(f64) -> f64, a: f64, b: f64, n: usize) -> f64
Trapezoidal rule with n sub-intervals (n must be >= 1).