0

I creat a 8 by 8 matrix and want to calculate its inverse. But the output is strange

import numpy as np
a=np.mat([
 [538084012500000.0, 6832812857142.857, 88573500000.0, 1180980000.0, 16402500.0, 243000.0, 4050.0, 90.0],
 [47829690000000, 531441000000, 5904900000, 65610000, 729000, 8100, 90, 1,],
 [13348388671875, 177978515625, 2373046875, 31640625, 421875, 5625, 75, 1,],
 [2799360000000, 46656000000, 777600000, 12960000, 216000, 3600, 60, 1,],
 [373669453125, 8303765625, 184528125, 4100625, 91125, 2025, 45, 1],
 [21870000000, 729000000, 24300000, 810000, 27000, 900, 30,1 ],
 [170859375, 11390625, 759375, 50625, 3375, 225, 15, 1],
 [0, 0, 0, 0, 0, 0, 0, 1]])
print(np.linalg.det(a))
print(np.linalg.det(a)*np.linalg.det(a.I))
print(a*a.I)

Output:

Output snapshot

Error message:

det(a) is not equal to 0,so a is invertible.\
but det(a)\*det(a.I) is not equal to one.\
and a\*a.I is not identity matrix.
TERMINATOR
  • 1,180
  • 1
  • 11
  • 24
キラル
  • 31
  • 5

1 Answers1

2

numpy uses double, its accuracy is on the order of 16. The difference between the highest and lowest number in your matrix is of the order of 16. An error in the calculation of the order of 1 is pretty reasonable - It is just what the machine accuracy promises.

Maybe try to use another library that promises bigger accuracy, as suggested here for a similar problem

don-joe
  • 600
  • 1
  • 4
  • 12