Inverse of an Identity Matrix | Linear Algebra using Python

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

Prerequisites:

There are matrices whose inverse is the same as the matrices and one of those matrices is the identity matrix.

    I-.1 = I

Syntax:

    inv_M = numpy.linalg.inv(I)

Here, "M" is the an identity matrix.

Python code to find the inverse of an identity matrix

# Linear Algebra Learning Sequence
# Inverse of a Identity Matrix

import numpy as np

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

ai = np.linalg.inv(I) 
print('\n\nInverse of A as ----\n', ai)

print('\n\nThe Matrices are same')

Output:

---Matrix I---
 [[1. 0. 0. 0. 0. 0.]
 [0. 1. 0. 0. 0. 0.]
 [0. 0. 1. 0. 0. 0.]
 [0. 0. 0. 1. 0. 0.]
 [0. 0. 0. 0. 1. 0.]
 [0. 0. 0. 0. 0. 1.]]


Inverse of A as ----
 [[1. 0. 0. 0. 0. 0.]
 [0. 1. 0. 0. 0. 0.]
 [0. 0. 1. 0. 0. 0.]
 [0. 0. 0. 1. 0. 0.]
 [0. 0. 0. 0. 1. 0.]
 [0. 0. 0. 0. 0. 1.]]


The Matrices are same



Comments and Discussions!

Load comments ↻






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