Home »
Python »
Linear Algebra using Python
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.]]