Reputation: 84
I actually work on some matrices and when I inverse it, the inverse is wrong. I use np.linalg.inv() to inverse my square matrix.
My example his:
import numpy as np
M = np.array([[9.0, 5.329070518200756e-17, -7.199999999999999, -5.3999999999999995, 0.0, 0.0], [5.329070518200756e-17, 9.0, 5.3999999999999995, -7.199999999999999, 0.0, 0.0], [-7.199999999999999, 5.3999999999999995, 11.422222222222222, 1.6653345369377363e-17, -2.4222222222222225, -7.266666666666667], [-5.3999999999999995, -7.199999999999999, 1.6653345369377363e-17, 11.422222222222222, 7.266666666666667, -2.4222222222222225], [0.0, 0.0, -2.4222222222222225, 7.266666666666667, 24.22222222222222, 0.0], [0.0, 0.0, -7.266666666666667, -2.4222222222222225, 0.0, 24.22222222222222]])
M_inv = np.linalg.inv(M)
# It's not the Identity!
print( M_inv @ M)
Do you have clues ? Thank you for your answers!
Upvotes: 0
Views: 896
Reputation: 1602
Check numpy.linalg.inv because Rank defective matrices cannot be inverted, need to supply a square or it can also be a valid numpy.matrix
instance, the linalg.inv
method processes M = np.array([...]) numpy.linalg.inv(M)
incorrectly.
Upvotes: 1