matlab and python codes with no iteration are identical now