0

I have the following code:

A = np.random.randint(-10,10,(4,4))
B = np.random.randint(-10,10,(4,4))
A1, A2, A3, A4 = inv(A@B), inv(A)@inv(B), inv(B@A), inv(B)@inv(A)
print(A1 - A4)

since mathematically A1 = A4, subtracting them should give back zero matrix, but I get

[[-1.73472348e-18  1.73472348e-18  3.46944695e-18  3.46944695e-18]
 [-8.67361738e-19  0.00000000e+00  4.01154804e-18  3.46944695e-18]
 [ 3.46944695e-18  1.73472348e-18  3.46944695e-18 -3.46944695e-18]
 [-1.73472348e-18 -1.73472348e-18 -1.73472348e-18  1.73472348e-18]]

its very close to zero, but not really zero - why is that?

0 Answers0