i am converting a matlab code to python. i found a strange difference of sum of matlab and python. i want to have same output in python like i am getting in matlab. is it possible ? in matlab
x = [-200:200]/200; % 401 values from -200 to 200 y =sum(x) y = 9.9920e-16
but in python using different modules i get answer
x = np.arange(-200,201)/200 # 401 values from -200 to 200 y = np.sum(x) y = 1.4210854715202004e-14 z = sum(x) z = -8.43769498715119e-15 zmath = math.fsum(x) zmath = 0.0