AI State of the Art
Math/Linear Algebra/12 min
Section 316

Eigenvalues and Eigenvectors

Listen as a podcast →

Introduction: the privileged directions

When a matrix acts on a vector, it transforms it. In general, the vector changes both its direction and length. But for certain special vectors, the matrix only stretches or compresses them, without changing their direction.

These special vectors are the eigenvectors. The corresponding stretching factor is the eigenvalue. Together, they reveal the deep structure of a transformation.

The intuition: a matrix as a transformation

Imagine a matrix A\mathbf{A} acting on all vectors in the plane. Most vectors are deformed into a new direction. But there exist "natural" directions of the transformation, axes along which the matrix only pushes or pulls.

Concrete analogy: think of a rubber band being stretched. The rubber band deforms in all directions, but there's a principal stretching axis (the direction in which it elongates the most) and a perpendicular axis (in which it contracts). These axes are the eigenvectors of the transformation.

Another analogy: in a movie theater, sound vibrations have natural modes, frequencies at which the room naturally resonates. Eigenvectors are the same thing: the "natural modes" of a matrix transformation.

The Mona Lisa shown twice side by side with a grid overlaid. On the left the original image; on the right the same image sheared, leaning to the right. On each image a red arrow points up and a blue arrow points right. The blue arrow is identical in both images, the red arrow is tilted in the right-hand image.
The same image, before and after a transformation that tilts it (a horizontal shear). Compare the two arrows: the red one has changed direction, the blue one has not, it is strictly identical left and right. The blue arrow is an eigenvector of this transformation, with eigenvalue 1 since its length did not change either. The grid makes clear that everything else in the plane did get deformed.Source : Wikimedia Commons, Eigenvalues and eigenvectors article

Formal definition

For a square matrix A∈Rn×n\mathbf{A} \in \mathbb{R}^{n \times n}, a nonzero vector v\mathbf{v} is an eigenvector if:

Av=λv\mathbf{A}\mathbf{v} = \lambda \mathbf{v}

Where λ\lambda is a scalar called the eigenvalue associated with v\mathbf{v}.

In other words: applying A\mathbf{A} to v\mathbf{v} simply amounts to multiplying v\mathbf{v} by λ\lambda. The direction is preserved, only the magnitude changes.

What the eigenvalue tells you

  • λ>1\lambda > 1: the eigenvector is stretched (the transformation amplifies in this direction)
  • 0<λ<10 < \lambda < 1: the eigenvector is compressed
  • λ=1\lambda = 1: the eigenvector is unchanged
  • λ=0\lambda = 0: the eigenvector is crushed to zero (information in this direction is lost)
  • λ<0\lambda < 0: the eigenvector is reversed (and stretched/compressed according to ∣λ∣|\lambda|)

Concrete example

Take the matrix:

A=(3102)\mathbf{A} = \begin{pmatrix} 3 & 1 \\ 0 & 2 \end{pmatrix}

You can verify that v1=(10)\mathbf{v}_1 = \begin{pmatrix} 1 \\ 0 \end{pmatrix} is an eigenvector with λ1=3\lambda_1 = 3:

(3102)(10)=(30)=3(10)\begin{pmatrix} 3 & 1 \\ 0 & 2 \end{pmatrix} \begin{pmatrix} 1 \\ 0 \end{pmatrix} = \begin{pmatrix} 3 \\ 0 \end{pmatrix} = 3 \begin{pmatrix} 1 \\ 0 \end{pmatrix}

And v2=(1−1)\mathbf{v}_2 = \begin{pmatrix} 1 \\ -1 \end{pmatrix} is an eigenvector with λ2=2\lambda_2 = 2:

(3102)(1−1)=(2−2)=2(1−1)\begin{pmatrix} 3 & 1 \\ 0 & 2 \end{pmatrix} \begin{pmatrix} 1 \\ -1 \end{pmatrix} = \begin{pmatrix} 2 \\ -2 \end{pmatrix} = 2 \begin{pmatrix} 1 \\ -1 \end{pmatrix}

How to find them (the concept)

You start from the equation Av=λv\mathbf{A}\mathbf{v} = \lambda \mathbf{v} and rewrite:

(A−λI)v=0(\mathbf{A} - \lambda \mathbf{I})\mathbf{v} = \mathbf{0}

For a nonzero v\mathbf{v} to exist, the matrix (A−λI)(\mathbf{A} - \lambda \mathbf{I}) must be singular, so:

det⁡(A−λI)=0\det(\mathbf{A} - \lambda \mathbf{I}) = 0

This is the characteristic polynomial. Its roots are the eigenvalues. An n×nn \times n matrix has at most nn eigenvalues (potentially complex).

In practice, you never solve this polynomial by hand for large matrices. You use iterative numerical algorithms (QR, Lanczos, etc.) implemented in NumPy, SciPy, or LAPACK.

The eigendecomposition

If a matrix A\mathbf{A} has nn linearly independent eigenvectors, you can write:

A=VΛV−1\mathbf{A} = \mathbf{V} \mathbf{\Lambda} \mathbf{V}^{-1}

Where:

  • V\mathbf{V} is the matrix whose columns are the eigenvectors
  • Λ\mathbf{\Lambda} is the diagonal matrix of eigenvalues

This decomposition says: the transformation A\mathbf{A} is equivalent to (1) switching to the eigenvector basis, (2) stretching each axis by its eigenvalue, (3) switching back to the original basis.

For symmetric matrices (like covariance matrices), the eigenvectors are orthogonal and the decomposition becomes A=VΛVT\mathbf{A} = \mathbf{V}\mathbf{\Lambda}\mathbf{V}^T. It's cleaner and numerically more stable.

Applications in machine learning

PCA: dimensionality reduction

Principal Component Analysis (PCA) is the most direct application of eigenvalues in ML.

The principle: you have high-dimensional data (say 1,000 features) and you want to project it into low dimensions (say 50) while losing minimal information.

How? You compute the covariance matrix of the data C=1nXTX\mathbf{C} = \frac{1}{n}\mathbf{X}^T\mathbf{X} (after centering), then its eigenvectors. The eigenvectors associated with the largest eigenvalues are the directions of maximum variance, the most "informative" directions.

Projecting onto these few eigenvectors means keeping the essentials while drastically reducing dimensionality. If the first 50 eigenvalues capture 95% of the total variance, the other 950 dimensions are noise.

A cloud of several thousand grey points forming an elongated ellipse running diagonally from bottom left to top right. Two perpendicular black arrows start from the centre of the cloud: a long one along the cloud's main axis, a short one perpendicular to it.
A data cloud and the eigenvectors of its covariance matrix. Both arrows start at the centre of the cloud, are perpendicular to each other, and their lengths are proportional to how much the data spreads along them. The long arrow is the first principal component: the direction in which the data varies most. Keeping that direction and discarding the other is a PCA that takes this cloud from 2 dimensions down to 1 while losing very little information.Source : Wikimedia Commons, Principal component analysis article

Spectral analysis of graphs

Social networks, molecules, and knowledge graphs are represented by adjacency matrices or graph Laplacians. The eigenvectors of these matrices reveal the community structure of the graph.

Graph Neural Networks (GNNs) use this spectral theory. Spectral filters on graphs are defined in terms of eigenvalues of the Laplacian.

Training stability

The eigenvalues of the Hessian matrix (second derivatives of the loss) give information about the loss landscape:

  • Very large eigenvalues in the Hessian indicate directions of strong curvature, the gradient changes rapidly, making optimization unstable.
  • The ratio between the largest and smallest eigenvalue (the condition number) measures how ill-conditioned the optimization problem is. A high condition number means gradient descent converges slowly.

Techniques like normalization (BatchNorm, LayerNorm) improve the conditioning of the Hessian, which stabilizes training.

Markov models and PageRank

Google's PageRank algorithm models the web as a Markov chain. The ranking of pages is given by the dominant eigenvector of the transition matrix, the one associated with the largest eigenvalue.

Spectrum of a matrix

The set of all eigenvalues of a matrix is called its spectrum. Analyzing the spectrum gives a global view of the transformation:

  • Spectral radius: the largest eigenvalue in absolute value, ρ(A)=max⁡∣λi∣\rho(\mathbf{A}) = \max|\lambda_i|. If ρ<1\rho < 1, the transformation contracts, which guarantees convergence of certain iterative algorithms.
  • Trace: the sum of eigenvalues equals the trace of the matrix, tr(A)=∑λi\text{tr}(\mathbf{A}) = \sum \lambda_i.
  • Determinant: the product of eigenvalues equals the determinant, det⁡(A)=∏λi\det(\mathbf{A}) = \prod \lambda_i.

Why this matters for AI

Eigenvalues and eigenvectors are not an abstract concept reserved for mathematicians. They are at the heart of very concrete ML techniques:

  • PCA for dimensionality reduction and visualization
  • Spectral analysis for graphs and GNNs
  • Training diagnostics via the Hessian spectrum
  • Model compression by identifying "useless" directions

When you understand eigenvalues, you understand how a transformation preserves or destroys information. And in ML, everything is a transformation.

Where this is used. The spectrum of a weight matrix decides whether the signal grows or collapses as it crosses layers: see training stability and orthogonality.