0

I'm trying to solve a matrix equation Ax=b with numpy.linarg.solve()

A = np.array([[1, 1], [15,10]])
b = np.array([12,170])
sol = np.linalg.solve(A,b)
print(sol)

the result is

[10.  2.]

this is right answer but, when I run the code below,

print(sol[0], sol[1])

I get

10.000000000000002 1.999999999999998

why are they different?

k0909
  • 1
  • They are the same values, printing the array in your first line just rounds the values to make them prettier during printing – jkr Sep 11 '20 at 14:59

1 Answers1

0

Numpy truncates the values for print expected to be integers (i.e 1.99999999997 = 2)

L F
  • 548
  • 1
  • 7
  • 22