Product of a Matrix and its Inverse Property | Linear Algebra using Python

Linear Algebra using Python | Product of a Matrix and its Inverse Property: Here, we are going to learn about the inverse of a matrix and its implementation in Python.
Submitted by Anuj Singh, on June 04, 2020

Prerequisites:

In linear algebra, an nxn square matrix A can be called as invertible if its inverse exists. Notice that, there cannot be a non-square matrix whose inverse exists. In this tutorial, we are going to check and verify one of the properties of Invertible Matrices.

A.A-.1 = I

Python code to find the product of a matrix and its inverse property

# Linear Algebra Learning Sequence
# Inverse Property A.AI = I  [AI = inverse of A]

import numpy as np

M = np.array([[2,3,4], [4,4,8], [4,8,7]])
print("---Matrix A---\n", M)

MI = np.linalg.inv(M) 
print('\n\nInverse of A (AI) as ----\n', MI)

pro = np.dot(MI,M)
print('\n\nProduct of Matrix A with its Inverse : A * AI = I \n\n', pro)

Output:

---Matrix A---
 [[2 3 4]
 [4 4 8]
 [4 8 7]]


Inverse of A (AI) as ----
 [[-9.    2.75  2.  ]
 [ 1.   -0.5   0.  ]
 [ 4.   -1.   -1.  ]]


Product of Matrix A with its Inverse : A * AI = I 

 [[1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]]


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.