×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

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
Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

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