gauss newton algorithm in python