1import numpy as np
2
3# X is the matrix to invert
4X_inverted = numpy.linalg.inv(X)
1>>> import numpy as np
2>>> A = np.array(([1,3,3],[1,4,3],[1,3,4]))
3>>> A
4array([[1, 3, 3],
5 [1, 4, 3],
6 [1, 3, 4]])
7>>> A_inv = np.linalg.inv(A)
8>>> A_inv
9array([[ 7., -3., -3.],
10 [-1., 1., 0.],
11 [-1., 0., 1.]])
12