A faster version for computing bfgs derivatives.