Simple version of Newton Method in python