from numpy.linalg import inv a = np.array([[1., 2.], [3., 4.]]) ainv = inv(a) np.allclose(np.dot(a, ainv), np.eye(2)) True np.allclose(np.dot(ainv, a), np.eye(2)) True