Let’s see how to inverse matrix in Numpy Python library.
Using linalg.inv
Numpy does have dedicated function which inverses matrices. This is linalg.inv Numpy method. This linear algebra inv function is responsible for computing the inverse of a given identity matrix.
import numpy as np my_array = np.array([[11, 2, 3], [3, 6, 7], [6, 7, 22]]) inverted_array = np.linalg.inv(my_array) print(my_array) print(inverted_array)
As you can see it is just one line of code to inverse matrix with Numpy.
You can use inversed matrix to multiply matrices. Thanks to this you will in fact divide matrices. This is a workaround for dividing problem. It is not possible to divide matrices in Numpy but you can multiply by inversed matrix.