Skip to content
Related Articles

Related Articles

Python | sympy.eye() method
  • Last Updated : 29 Jun, 2019

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.

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

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



Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


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]])

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :