add a .cached method to DiffFunction, and auto-cache in lbfgs.