Python | The numpy np.eigvals () method



Using the np.eigvals() method we can get the eigenvalues ​​of the matrix using np.eigvals () .

Syntax: np.eigvals (matrix)
Return: Return the eigen values ​​of a matrix.

Example # 1:
In this example we see that with np.eigvals () we can get our own matrix values ​​using this method.

# NumPy import

from numpy import linalg as LA

 
# using the np.eigvals () method

gfg = LA.eigva ls ([[ 1 , 2 ], [ 3 , 4 ]])

 

print (gfg)

Output:

[-0.37228132 5.37228132]

Example # 2:

# NumPy import

from numpy import linalg as LA

 
# using the np.eigvals () method

gfg = LA.eigvals ([[ 1 , 2 , 3 ], [ 4 , 5 , 6 ], [ 7 , 8 , 9 ]])

 

print (gfg)

Output:

[1.61168440e + 01 -1.11684397e + 00 -1.30367773e-15]