I am trying to solve a linear system on Python for a problem which I ported from Octave. I have the following code for Octave
A=[ -1 -2 -4 -2 -3 -4;
-2 -4 -4 -3 -4 -5;
-1 -1 -1 -5 -5 -3;
-2 -3 -5 100 -0 -0;
-3 -4 -5 -0 100 -0;
-4 -5 -3 -0 -0 100];
b = [3.9000;
4.2000;
4.3000;
-9.0000;
-9.0000;
-9.0000];
A \ b
This gives
ans =
-3.51998
1.83663
-0.66828
-0.13871
-0.15555
-0.15902
On Python I have
import numpy as np
import numpy.linalg as lin
A = [[ -1., -2., -4., -2., -3., -4.],
[ -2., -3., -4., -3., -4., -5.],
[ -1., -1., -1., -5., -5., -3.],
[ -2., -3., -5., 100., -0., -0.],
[ -3., -4., -5., -0., 100., -0.],
[ -4., -5., -3., -0., -0., 100.]]
b = [[ 3.9],
[ 4.2],
[ 4.3],
[-9. ],
[-9. ],
[-9. ]]
A = np.array(A)
b = np.array(b)
print (lin.solve(A,b))
which gives
[[-7.70634652]
[ 7.78318125]
[-2.67111771]
[-0.14418738]
[-0.14341903]
[-0.08922833]]
I am seeing different results.. I wonder why they are different?
Thanks,
The $(2,2)$ entries of $A$ disagree.