Same Problem as in Example 2. The function always changed the initial y-array instead of just changing y_new. Error solved by using deepcopy.