Thursday, September 4, 2025
HomeLanguagesPython | sympy.eye() method

Python | sympy.eye() method

With the help of sympy.eye() method, we can find the identity matrix by using sympy.eye() method.

Syntax : sympy.eye()
Return : Return an identity matrix.

Example #1 :
In this example, we can see that by using sympy.eye() method, we are able to find identity matrix having dimension nxn, where n will be pass as a parameter.




# import sympy
from sympy import *
  
# Use sympy.eye() method
mat = eye(3)
   
print(mat)


Output :

Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])

Example #2 :




# import sympy
from sympy import *
  
# Use sympy.eye() method
mat = eye(5)
   
print(mat)


Output :

Matrix([
[1, 0, 0, 0, 0],
[0, 1, 0, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 1, 0],
[0, 0, 0, 0, 1]])

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32263 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6627 POSTS0 COMMENTS
Nicole Veronica
11799 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11858 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6696 POSTS0 COMMENTS
Umr Jansen
6716 POSTS0 COMMENTS