Algorithm for numerically computing integrals using combination of the trapezoidal rule and the backward differentiation formula