Trapezoidal method function, but unusable in this context