# 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
```

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