How to find inverse of a matrix in Python using NumPy

You can find the inverse of a matrix in Python using NumPy with the following code. If you want to learn Python then I will highly recommend you to read This Book.

How to find inverse of a matrix in Python using NumPy
How to find inverse of a matrix in Python using NumPy

Step 1

Import the required libraries.

import numpy as np
import numpy.linalg as la

Step 2

Now make a matrix and find the inverse using la.inv(). Matrix should be non-singular.

a = np.array([[1,2],[3,4]])
print(la.inv(a))

#output [[-2.   1. ]
#output [ 1.5 -0.5]]

People are also reading:

Best Python Books

What is Computer Vision? Examples, Applications, Techniques

Top 10 Computer Vision Books with Python

Books for Machine Learning (ML)

Free Learning Resources

Leave a Comment

Your email address will not be published.