Template to implement Quasi-Newton algorithm