Quasi newton method python. Just translate all the code into python.