top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

Writer's pictureArpan Sapkota

Inverse of a Matrix using Numpy


The inverse of a matrix is just a reciprocal of the matrix as we do in normal arithmetic for a single number which is used to solve the equations to find the value of unknown variables.


The inverse of a matrix is that matrix which when multiplied with the original matrix will give an identity matrix. The inverse of a matrix exists only if the matrix is non-singular i.e., determinant should not be 0. Using determinant and adjoint, we can easily find the inverse of a square matrix using below formula,


if det(A) != 0
    A-1 = adj(A)/det(A)
else
    "Inverse doesn't exist" 


Inverse of a Matrix using NumPy

Python provides a very easy method to calculate the inverse of a matrix. The function numpy.linalg.inv() which is available in the python NumPy module is used to compute the inverse of a matrix.


First we Import numpy package

import numpy as np

Taking a 3 * 3 matrix as

A = np.array([[4, 3, 6],[2, 5, 9],[8, 6, 3]]) 

Now, calculating the inverse of the matrix as

print(np.linalg.inv(A))
1 comment

Recent Posts

See All

1 comentario


Data Insight
Data Insight
21 sept 2021

You should find a different way of writing mathematical equations and then inserting it into your article. See for example https://www.datainsightonline.com/post/quadratic-equation-root-calculator

Me gusta
bottom of page