How to Get the Eigenvalues of a Matrix in Python using Numpy



Python


In this article, we show how to get the eigenvalues of a matrix in Python using the numpy module.

In linear algebra, an eigenvector or characteristic vector of a linear transformation is a nonzero vector that changes at most by a scalar factor when that linear transformation is applied to it. The corresponding eigenvalue is the factor by which the eigenvector is scaled. Geometrically, an eigenvector, corresponding to a real nonzero eigenvalue, points in a direction in which it is stretched by the transformation and the eigenvalue is the factor by which it is stretched. If the eigenvalue is negative, the direction is reversed.

This is shown in the following code below.



For a 2x2 matrix, there will only be 2 eigenvalues, corresponding to the 2 matrices.

For the matrix above, the eigenvalues are 10 and 1.

These values represent the factor by which the eigenvectors are scaled.

Just to show you a 3x3 matrix example, we have another example below.



For a 3x3 matrix, there will be 3 eignvalues, representing the eigenvalue for each matrix.

And this is how to get the eigenvalues of a matrix in Python using the numpy module.


Related Resources

How to Randomly Select From or Shuffle a List in Python



HTML Comment Box is loading comments...