Variable step size trapezoidal method