Identity Matrix Property (AI = A) | Linear Algebra using Python

Linear Algebra using Python | Identity Matrix Property (AI = A): Here, we are going to learn about identity matrix property (AI = A) and its implementation in Python.
Submitted by Anuj Singh, on May 28, 2020

Prerequisites:

In linear algebra, the identity matrix, of size n is the n × n square matrix with ones on the main diagonal and zeros elsewhere. It is denoted by I. The identity matrix has the property that: AI = A

Python code for identity matrix property (AI = A)

# Linear Algebra Learning Sequence
# Identity Matrix Property (AI = A) 

import numpy as np

I = np.eye(3)
print("---Matrix I---\n", I)

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

ai = np.matmul(A,I) 
print('\nIdentity Matrix Property I.A----\n', ai)

if ai.all() == I.all():
    print("AI = A")

Output:

---Matrix I---
 [[1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]]
---Matrix A---
 [[ 2  3  4]
 [ 3 45  8]
 [ 4  8 78]]

Identity Matrix Property I.A----
 [[ 2.  3.  4.]
 [ 3. 45.  8.]
 [ 4.  8. 78.]]





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.