Linear Algebra for Machine Learning

Eigenvectors and Eigenvalues

Eigenvectors and eigenvalues as invariant directions for linear maps.

Lesson
6

Goal

Understand the special directions in which a linear map acts like scalar multiplication, and learn how to recognize them from the equation Av=λvAv = λv.

By the end of the lesson, you should be able to say, in plain language, what an eigenvector is, what an eigenvalue is, and why the determinant condition det(AλI)=0det(A - λI) = 0 appears.

Motivation

Most vectors change direction when a matrix acts on them.

That is the ordinary case.

The interesting case is when a matrix has a direction it does not twist at all. It may stretch that direction, shrink it, or flip it, but it does not send it somewhere else.

That is the feature behind eigenvectors.

The idea matters because repeated application of a matrix becomes easy along those directions. It also matters because covariance matrices, stability analyses, and dimensionality-reduction methods all lean on the same geometry.

Prerequisites

Notation / Symbol Table

SymbolPlain-English nameMeaning
AAmatrixA square matrix or linear transformation acting on vectors.
vvvectorA candidate eigenvector; it must be nonzero.
λ\lambdaeigenvalueThe scalar factor by which AA stretches or flips vv.
IIidentity matrixThe matrix that leaves vectors unchanged.
Av=λvAv = λveigenvector equationThe defining relationship for an eigenpair.
det(AλI)\det(A - λI)characteristic determinantThe polynomial condition used to find eigenvalues.

Core Ideas

The invariant-direction idea

If a matrix sends a vector back onto the same line, that vector is special.

Formally, a nonzero vector vv is an eigenvector of AA if

Av=λvAv = λv

for some scalar λλ.

Read this as:

Applying the matrix has the same effect as multiplying by a number, but only in that direction.

That is the whole idea. The matrix may still do other complicated things to other vectors.

Why this is not just a definition trick

The equation is not saying that every vector behaves this way.

It is saying there may be a few preferred directions where the matrix becomes simple.

That is the same pattern we have seen elsewhere in the course:

Eigenvectors are one of the cleanest examples of that pattern.

Repeated application becomes easy

If Av=λvAv = λv, then applying AA again gives

A(Av)=A(λv)=λAv=λ2v.A(Av) = A(λv) = λAv = λ^2v.

By induction,

Akv=λkv.A^kv = λ^kv.

So on an eigenvector, repeated application of the matrix is just repeated multiplication by a scalar.

That is why eigenvectors are so useful for matrix powers, discrete dynamical systems, and stability questions.

How to find eigenvalues

Start from

Av=λv.Av = λv.

Move everything to one side:

Avλv=0.Av - λv = 0.

Factor out vv by writing λvλv as λIvλIv:

(AλI)v=0.(A - λI)v = 0.

A nonzero solution exists only when AλIA - λI is singular. Therefore:

det(AλI)=0.det(A - λI) = 0.

That is the characteristic equation.

Why the determinant appears

The determinant detects when a square matrix fails to be invertible.

If AλIA - λI has a nonzero vector in its kernel, then it cannot be invertible, so its determinant must be zero.

This is the algebraic bridge from the eigenvector equation to a polynomial equation in λλ.

Worked Example

Let

A=[4123].A = \begin{bmatrix} 4 & 1 \\ 2 & 3 \end{bmatrix}.

We look for λλ such that

det(AλI)=0.det(A - λI) = 0.

Compute:

AλI=[4λ123λ].A - λI = \begin{bmatrix} 4 - λ & 1 \\ 2 & 3 - λ \end{bmatrix}.

Then

det(AλI)=(4λ)(3λ)2.det(A - λI) = (4 - λ)(3 - λ) - 2.

Expand:

(4λ)(3λ)2=127λ+λ22=λ27λ+10.(4 - λ)(3 - λ) - 2 = 12 - 7λ + λ^2 - 2 = λ^2 - 7λ + 10.

Factor:

λ27λ+10=(λ5)(λ2).λ^2 - 7λ + 10 = (λ - 5)(λ - 2).

So the eigenvalues are 55 and 22.

Now find an eigenvector for λ=5λ = 5:

(A5I)v=0(A - 5I)v = 0

gives

[1122][xy]=0.\begin{bmatrix} -1 & 1 \\ 2 & -2 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = 0.

The first row says x+y=0-x + y = 0, so x=yx = y.

One eigenvector is

v=[11].v = \begin{bmatrix} 1 \\ 1 \end{bmatrix}.

Check:

A[11]=[55]=5[11].A \begin{bmatrix} 1 \\ 1 \end{bmatrix} = \begin{bmatrix} 5 \\ 5 \end{bmatrix} = 5 \begin{bmatrix} 1 \\ 1 \end{bmatrix}.

The same direction comes out, scaled by 55.

For λ=2λ = 2, the equation becomes 2x+y=02x + y = 0, so one eigenvector is

[12].\begin{bmatrix} 1 \\ -2 \end{bmatrix}.

Why This Shows Up In ML

Eigenvectors and eigenvalues show up whenever a linear structure has preferred directions.

A covariance matrix is the classic example.

Its eigenvectors tell you which directions in the data vary independently.

Its eigenvalues tell you how much variation lives in each of those directions.

That is the geometry behind principal component analysis, but it also appears in:

The lesson to keep is simple:

Eigenvectors are the directions a transformation respects.

Common Confusions

Exercises

Work through these without rushing.

  1. For

    A=[6004],A = \begin{bmatrix} 6 & 0 \\ 0 & 4 \end{bmatrix},

    what are the eigenvalues?

  2. Give one eigenvector for each eigenvalue above.

  3. If Av=7vAv = 7v, what is A5vA^5v?

  4. Explain why det(AλI)=0det(A - λI) = 0 must hold if λλ is an eigenvalue.

  5. Suppose a covariance matrix has eigenvalues 100100, 1212, 33, and 0.40.4. What does that suggest about the data, and what would PCA do with it?

Implementation Exercise

Write a TypeScript helper that checks whether a candidate vector is an eigenvector of a 2x2 matrix within a small tolerance.

A useful starting point is:

type Matrix2x2 = [[number, number], [number, number]];
type Vector2 = [number, number];

type EigencheckResult = {
  isEigenvector: boolean;
  eigenvalue: number | null;
  residual: Vector2;
};

The helper should:

That keeps the exercise close to the lesson: test the defining equation directly.

Reflection Questions

Next Lesson

Next: Change of Basis.

The bridge is direct: once you know a matrix has preferred directions, the next question is how to re-express a vector in a different basis so those directions become easier to work with.