optimisation with bfgs, implemented using numericjs