I was running the same algorithm using python and Matlab. When they solve the same linear system, the results are slightly different, which will lead to a total different results in the end. I am wondering how to fix python to get the same result as Matlab. Thanks!
Ax=b, python:
A=[[ 1., 0., 0., 0., 1., 1., 1., 2.],
[ 0., 0., 0., 0., -0., -1., -0., -0.],
[ 0., 0., 0., 0., -0., -0., -1., -0.],
[ 0., 0., 0., 0., -0., -0., -0., -1.],
[ 1., -0., -0., -0., -1., -0., -0., -0.],
[ 1., -1., -0., -0., -0., -1., -0., -0.],
[ 1., -0., -1., -0., -0., -0., -1., -0.],
[ 2., -0., -0., -1., -0., -0., -0., -1.]]
b=[[ 1.],[ 0.],[ 0.],[ 0.],[-1.],[ 0.],[ 0.],[ 0.]]
res_py = numpy.linalg.solve(A,b)
and Matlab:
res_m = A\b
The python output:
[[-0.],[ 0.],[ 0.],[-0.],[-1.],[ 0.],[ 0.],[ 0.]]
The Matlab output:
[ 0; -4.163336342344337e-17; -4.163336342344337e-17; 0; -1.000000000000000e+00; 0; 2.775557561562891e-17; 0]