SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons
      1. 3.6.1 Eigenvalues and eigenvectorsConcept · 35 min
      2. 3.6.2 Diagonalisation and matrix powersConcept · 30 min
      3. 3.6.3 Symmetric matrices and the spectral theoremConcept · 30 min
      4. 3.6.4 Practice set: eigenvaluesPractice set · 20 min
      5. 3.6.5 Case study: principal components of the yield curveCase study · 35 min

Level 3, Linear algebra 3.6 Eigenvalues and eigenvectors Lesson 1 of 5

ConceptLesson 3.6.1 in Level 3, Linear algebra. About 35 minutes.

Eigenvalues and eigenvectors

Directions a matrix only stretches

Lesson 3.2.2 showed that a matrix moves almost every vector to a new direction. A few directions are special: the matrix only stretches them. This lesson finds them.

Take the symmetric matrix of lesson 3.2.3,

S=(2112)S = \begin{pmatrix} 2 & 1 \\ 1 & 2 \end{pmatrix}

and see where it sends a few vectors:

x\mathbf{x}(1,0)(1, 0)(1,2)(1, 2)(1,1)(1, 1)(2,2)(2, 2)(−1,−1)(-1, -1)(1,−1)(1, -1)(−2,2)(-2, 2)
SxS\mathbf{x}(2,1)(2, 1)(4,5)(4, 5)(3,3)(3, 3)(6,6)(6, 6)(−3,−3)(-3, -3)(1,−1)(1, -1)(−2,2)(-2, 2)

The vector (1,0)(1, 0) lands on (2,1)(2, 1), a new direction. But (1,1)(1, 1) lands on (3,3)=3 (1,1)(3, 3) = 3\,(1, 1): the same direction, three times as long. Every point of that line does the same, such as (2,2)(2, 2) and (−1,−1)(-1, -1).

On the line through (1,−1)(1, -1), SS changes nothing at all: (1,−1)(1, -1) lands on itself, and so does (−2,2)(-2, 2).

Rule: Eigenvector and eigenvalue

Av=λv,v≠0A\mathbf{v} = \lambda\mathbf{v}, \quad \mathbf{v} \neq \mathbf{0}

A nonzero vector v\mathbf{v} with Av=λvA\mathbf{v} = \lambda\mathbf{v} is an eigenvector of the square matrix AA, and the number λ\lambda (lambda) is its eigenvalue. AA keeps the line through v\mathbf{v} and multiplies every vector on it by λ\lambda.

So SS has the eigenvector (1,1)(1, 1) with eigenvalue 3, and (1,−1)(1, -1) with eigenvalue 1. "Eigen" is German for "own": these are the matrix's own directions.

The eigenvalue says what happens along the line:

  • λ>1\lambda > 1 stretches it, 0<λ<10 < \lambda < 1 shrinks it, and λ=1\lambda = 1 leaves it alone.
  • λ<0\lambda < 0 reverses it, and stretches or shrinks by ∣λ∣\lvert \lambda \rvert.
  • λ=0\lambda = 0 squashes the whole line onto 0\mathbf{0}.

The zero vector never counts, because A0=0=λ0A\mathbf{0} = \mathbf{0} = \lambda\mathbf{0} for every λ\lambda. Any nonzero multiple of an eigenvector is an eigenvector with the same λ\lambda, so an eigenvector is really a whole line, an eigenvector line.

An eigenvalue is a scale factor, so it has the units of the entries of AA. Here those are plain numbers; in case study 3.6.5 the entries are variances, and so are the eigenvalues.

SS turns (1,0)(1, 0) through 26.6°, but it keeps the two dashed lines. Along one it stretches by 3, along the other by 1.

The explorer starts on SS, with its two eigenvector lines dashed, and the last line of its readout lists the eigenvalues, 3 and 1. Drag the probe x\mathbf{x} from (1,2)(1, 2) onto (1,1)(1, 1): the readout says x\mathbf{x} is an eigenvector, stretched by 3.

Try (−1,1)(-1, 1), then press Shear and Rotate 90°. Count the dashed lines that remain, and read the eigenvalues each time.

Explore

Pick a matrix or set its entries. Its first column is where e₁ lands and its second where e₂ lands; the whole grid follows. Then drag the probe x and look for directions that A only stretches.

−4−4−2−22244Ae₁Ae₂xAx
Probe x = (1, 2) (drag its tip)
Matrix
A=(2112)A = \begin{pmatrix} 2 & 1 \\ 1 & 2 \end{pmatrix}
Columns
Ae₁ = (2, 1), Ae₂ = (1, 2)
det A
2 × 2 − 1 × 1 = 3: every area is multiplied by 3.
Probe
Ax = (4, 5): a different direction.
Eigenvalues
λ = 3 and 1

Try it

The loop rebuilds the table. The last column tests whether SxS\mathbf{x} lies on the line through x\mathbf{x}.

The test is x1y2−x2y1=0x_1y_2 - x_2y_1 = 0, where y=Sx\mathbf{y} = S\mathbf{x}. That is the determinant of the matrix with columns x\mathbf{x} and y\mathbf{y} (lesson 3.4.1): 0 exactly when the parallelogram they span is flat.

⌘/Ctrl + Enter runs the cell

Finding the eigenvalues

Start from Av=λvA\mathbf{v} = \lambda\mathbf{v}. Write λv\lambda\mathbf{v} as λIv\lambda I\mathbf{v}, since Iv=vI\mathbf{v} = \mathbf{v} (lesson 3.2.3), and move it to the left: (A−λI)v=0(A - \lambda I)\mathbf{v} = \mathbf{0}.

So A−λIA - \lambda I must send a nonzero vector to 0\mathbf{0}. A matrix that does that flattens the plane, so its determinant is 0 (lesson 3.4.1). That gives an equation for λ\lambda alone.

Rule: The eigenvalue equation

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

λ\lambda is an eigenvalue of AA exactly when A−λIA - \lambda I is singular. A−λIA - \lambda I subtracts λ\lambda from the diagonal entries only.

For a 2×22 \times 2 matrix with entries aa, bb, cc, dd, multiply out the determinant:

det⁡(A−λI)=(a−λ)(d−λ)−bc=λ2−(a+d)λ+(ad−bc)\begin{aligned} &\det(A - \lambda I) \\ &= (a - \lambda)(d - \lambda) - bc \\ &= \lambda^2 - (a + d)\lambda + (ad - bc) \end{aligned}

This quadratic in λ\lambda is the characteristic polynomial of AA. Its roots are the eigenvalues: factorise it, or use the quadratic formula of lesson 1.2.2.

Example 1. For SS, the polynomial is (2−λ)2−1=λ2−4λ+3=(λ−1)(λ−3)(2 - \lambda)^2 - 1 = \lambda^2 - 4\lambda + 3 = (\lambda - 1)(\lambda - 3). So the eigenvalues are 3 and 1, the stretch factors of the table.

A table of det⁡(S−λI)\det(S - \lambda I) shows the same roots:

λ\lambda01234
det⁡(S−λI)\det(S - \lambda I)30−1-103

At λ=2\lambda = 2, S−2I=(0110)S - 2I = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} has determinant −1-1, not 0. So no vector is doubled by SS.

Example 2. Take

A=(1232)A = \begin{pmatrix} 1 & 2 \\ 3 & 2 \end{pmatrix}

Its polynomial is (1−λ)(2−λ)−6=λ2−3λ−4=(λ−4)(λ+1)(1 - \lambda)(2 - \lambda) - 6 = \lambda^2 - 3\lambda - 4 = (\lambda - 4)(\lambda + 1). The eigenvalues are 4 and −1-1.

Try it

The loop prints det⁡(S−λI)\det(S - \lambda I) for the table. Then each polynomial is built from the coefficients 11, −(a+d)-(a + d) and ad−bcad - bc.

np.roots (lesson 1.3.1) finds the roots of a polynomial from its coefficients. They are sorted, largest first.

⌘/Ctrl + Enter runs the cell

Finding the eigenvectors

With an eigenvalue λ\lambda in hand, solve (A−λI)v=0(A - \lambda I)\mathbf{v} = \mathbf{0}. Because A−λIA - \lambda I is singular, its two rows are multiples of each other, and only one equation is left.

One equation in two unknowns has one free variable, so its solutions form a line through 0\mathbf{0} (lesson 3.3.2). That line is the null space of A−λIA - \lambda I (lesson 3.5.1), and every nonzero point on it is an eigenvector.

matrixλ\lambdaA−λIA - \lambda Iequationeigenvector
SS3(−111−1)\begin{pmatrix} -1 & 1 \\ 1 & -1 \end{pmatrix}v2=v1v_2 = v_1(1,1)(1, 1)
SS1(1111)\begin{pmatrix} 1 & 1 \\ 1 & 1 \end{pmatrix}v2=−v1v_2 = -v_1(1,−1)(1, -1)
AA4(−323−2)\begin{pmatrix} -3 & 2 \\ 3 & -2 \end{pmatrix}3v1=2v23v_1 = 2v_2(2,3)(2, 3)
AA−1-1(2233)\begin{pmatrix} 2 & 2 \\ 3 & 3 \end{pmatrix}v2=−v1v_2 = -v_1(1,−1)(1, -1)

Check by multiplying: A(2,3)=(8,12)=4 (2,3)A(2, 3) = (8, 12) = 4\,(2, 3). And A(1,−1)=(−1,1)A(1, -1) = (-1, 1): the line through (1,−1)(1, -1) is reversed, as an eigenvalue of −1-1 says.

Rule: Eigenvectors of a 2 × 2 matrix

(A−λI) v=0v=(b, λ−a)\begin{gathered} (A - \lambda I)\,\mathbf{v} = \mathbf{0} \\[4pt] \mathbf{v} = (b,\ \lambda - a) \end{gathered}

Row 1 of A−λIA - \lambda I is (a−λ, b)(a - \lambda,\ b), and v=(b,λ−a)\mathbf{v} = (b, \lambda - a) solves it. If that gives 0\mathbf{0}, use row 2, (c, d−λ)(c,\ d - \lambda), the same way: v=(λ−d, c)\mathbf{v} = (\lambda - d,\ c).

For AA with λ=4\lambda = 4 the shortcut gives (2,3)(2, 3); with λ=−1\lambda = -1 it gives (2,−2)(2, -2), a multiple of (1,−1)(1, -1).

The two eigenvectors of AA are not perpendicular: (2,3)⋅(1,−1)=−1(2, 3) \cdot (1, -1) = -1 (lesson 3.1.2). Those of SS are, since (1,1)⋅(1,−1)=0(1, 1) \cdot (1, -1) = 0. Lesson 3.6.3 shows that every symmetric matrix has perpendicular eigenvectors.

Try it

eigenvector_2x2 is the shortcut. Each line prints λ\lambda, v\mathbf{v}, MvM\mathbf{v} and λv\lambda\mathbf{v}; the last two always match.

The last line prints the two dot products.

⌘/Ctrl + Enter runs the cell

Trace and determinant

The trace of a square matrix, tr⁡A\operatorname{tr} A, is the sum of its diagonal entries: a+da + d for a 2×22 \times 2 matrix. So the characteristic polynomial is λ2−(tr⁡A)λ+det⁡A\lambda^2 - (\operatorname{tr} A)\lambda + \det A.

If its roots are λ1\lambda_1 and λ2\lambda_2, it also equals (λ−λ1)(λ−λ2)=λ2−(λ1+λ2)λ+λ1λ2(\lambda - \lambda_1)(\lambda - \lambda_2) = \lambda^2 - (\lambda_1 + \lambda_2)\lambda + \lambda_1\lambda_2. Matching the two forms gives a check on any answer.

Rule: Trace and determinant

tr⁡A=λ1+λ2det⁡A=λ1λ2\begin{gathered} \operatorname{tr} A = \lambda_1 + \lambda_2 \\[4pt] \det A = \lambda_1 \lambda_2 \end{gathered}

The eigenvalues add up to the trace and multiply to the determinant. The same holds for an n×nn \times n matrix, with all nn eigenvalues and a repeated one counted twice; lesson 3.6.3 checks a 3×33 \times 3 one.

matrixtr⁡\operatorname{tr}det⁡\deteigenvaluessumproduct
SS433 and 143
AA3−4-44 and −1-13−4-4
Z=(120.51)Z = \begin{pmatrix} 1 & 2 \\ 0.5 & 1 \end{pmatrix}202 and 020

The product is the area factor of lesson 3.4.1. SS stretches by 3 along one eigenvector line and by 1 along the other, so it multiplies every area by 3. A negative product, as for AA, means one line is reversed: the plane is flipped.

A zero eigenvalue. det⁡Z=0\det Z = 0, so one eigenvalue of the singular matrix ZZ (lesson 3.2.3) is 0, and the other is the trace, 2. Its eigenvectors are (2,1)(2, 1), sent to (4,2)(4, 2), and (2,−1)(2, -1), sent to 0\mathbf{0}: the direction that ZZ flattens.

Try it

np.linalg.eig(M).eigenvalues lists the eigenvalues; the last section of this lesson explains eig. .real drops a zero imaginary part that some NumPy versions add, and the values are sorted and rounded.

Each line prints the trace, the determinant, the eigenvalues, their sum and their product. The last line maps (2,1)(2, 1) and (2,−1)(2, -1) by ZZ.

⌘/Ctrl + Enter runs the cell

Repeated and complex eigenvalues

The characteristic polynomial is a quadratic, so its discriminant (lesson 1.2.2) sorts the cases. Here it is (tr⁡A)2−4det⁡A(\operatorname{tr} A)^2 - 4\det A.

Rule: Three cases for a 2 × 2 matrix

(tr⁡A)2−4det⁡A>0:two real=0:one, repeated<0:a complex pair\begin{gathered} (\operatorname{tr} A)^2 - 4\det A > 0: \text{two real} \\ = 0: \text{one, repeated} \\ < 0: \text{a complex pair} \end{gathered}

For SS the discriminant is 16−12=416 - 12 = 4: two real eigenvalues. A repeated eigenvalue can come with one eigenvector line or with every line; a complex pair comes with no real line at all.

One eigenvalue, twice

The shear of lesson 3.2.2, H=(1101)H = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}, has polynomial (1−λ)2(1 - \lambda)^2, so λ=1\lambda = 1 twice. Then H−I=(0100)H - I = \begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix} says only v2=0v_2 = 0: the x1x_1-axis. The shear has one eigenvector line, and every other direction leans over.

HH is triangular: every entry on one side of its diagonal, here below it, is 0. The determinant of a triangular matrix is the product of its diagonal (lesson 3.4.1), so its eigenvalues are its diagonal entries.

A repeated eigenvalue can also keep every direction. 2I2I has polynomial (2−λ)2(2 - \lambda)^2 too, but 2I−2I2I - 2I is the zero matrix, so every nonzero vector is an eigenvector: 2I2I stretches the whole plane evenly.

No real direction: rotations

The quarter turn R=(0−110)R = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix} has trace 0 and determinant 1, so its polynomial is λ2+1\lambda^2 + 1. That has no real root: every vector turns through 90°, so no line is kept.

With complex numbers (lesson 1.7.2), λ2=−1\lambda^2 = -1 has the roots ii and −i-i. Multiplying by ii is a quarter turn, which is exactly what RR does.

A turn through any angle θ\theta has trace 2cos⁡θ2\cos\theta and determinant cos⁡2θ+sin⁡2θ=1\cos^2\theta + \sin^2\theta = 1. Its eigenvalues are cos⁡θ±isin⁡θ=e±iθ\cos\theta \pm i\sin\theta = e^{\pm i\theta} (lesson 1.7.3): the angle of the turn is the angle of the eigenvalues. For 30° they are 0.866±0.5i0.866 \pm 0.5i.

Complex eigenvalues of a real matrix always come as a conjugate pair, like the roots of a real quadratic (lesson 1.7.2). A turn has real eigenvalues only at 0°, where it is II, and at 180°, where it is −I-I.

Try it

The eigenvalues print as complex numbers for every matrix here, so the real ones show +0.j. The discriminant is 0 for the shear and for 2I2I, and negative for both turns.

The shear's two eigenvector columns, with signs fixed, are both (1,0)(1, 0): one line only. The last line is eiπ/6e^{i\pi/6}, the turn through 30°.

⌘/Ctrl + Enter runs the cell

Eigenvalues in NumPy

np.linalg.eig(A) returns the eigenvalues of AA, and a matrix whose columns are eigenvectors: column jj goes with eigenvalue jj. Each column has length 1.

Three habits make its answers safe to print and compare:

  • Fix the order. eig lists the eigenvalues in no particular order, so sort them, largest first, and reorder the columns to match.
  • Fix the sign. An eigenvector line has two directions of length 1, and another computer may return −v-\mathbf{v}. Flip each column so that, say, its first entry is positive.
  • Real or complex. Depending on the NumPy version, real eigenvalues may come back as complex numbers such as 3+0j. When you know they are real, .real gives plain numbers.

For SS the columns are (0.7071,0.7071)(0.7071, 0.7071) and (0.7071,−0.7071)(0.7071, -0.7071): the eigenvectors (1,1)(1, 1) and (1,−1)(1, -1), scaled to length 1, since 12≈0.7071\frac{1}{\sqrt{2}} \approx 0.7071. For AA they are (0.5547,0.8321)(0.5547, 0.8321), which is (2,3)(2, 3) scaled, and (0.7071,−0.7071)(0.7071, -0.7071).

Dividing each column by its first entry gives (1,1.5)(1, 1.5) for AA, half of (2,3)(2, 3). Lesson 3.6.2 puts these columns side by side to compute powers of AA, and case study 3.6.5 finds them for a covariance matrix.

Try it

The cell fixes the order and the signs, then checks Av=λvA\mathbf{v} = \lambda\mathbf{v} for every column at once. V * values multiplies column jj by eigenvalue jj.

The last array divides each column by its first entry.

⌘/Ctrl + Enter runs the cell

Common mistakes

  1. The zero vector is never an eigenvector, but 0 can be an eigenvalue: ZZ sends (2,−1)(2, -1) to 0\mathbf{0}.
  2. Subtract λ\lambda on the diagonal only. A−λIA - \lambda I changes aa and dd, not bb and cc.
  3. An eigenvector is a line. (1,1)(1, 1), (2,2)(2, 2) and (−0.7071,−0.7071)(-0.7071, -0.7071) are the same answer for SS; check by multiplying, not by matching numbers.
  4. The diagonal entries are the eigenvalues only for a triangular matrix. SS has 2 and 2 on its diagonal, but eigenvalues 3 and 1.
  5. A repeated eigenvalue may have only one line. The shear keeps just the x1x_1-axis.
  6. No real root does not mean no eigenvalues. A turn has a complex pair, e±iθe^{\pm i\theta}, and no real eigenvector line.
  7. eig returns eigenvectors as columns, in no fixed order and with either sign. Sort, fix the signs, and use .real when the values are real.

Eigenvalues and eigenvectors

0 of 12 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
  8. 8.
  9. 9.
  10. 10.
  11. 11.
  12. 12.
How to type answers
  • Powers with ^: x^7, 2^(1/3), a^-2.
  • Multiply with * or by writing side by side: 3x^2, 2(x+1).
  • ln(x) is the natural log, log(x, 2) is log base 2, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for sin²x.
  • Your first answer to each question is saved: it counts towards your score and brings the question back for review.
  • Exact answers like ln(20)/ln(3) are best. Decimals need about 4 significant figures.

Summary card

  • An eigenvector of AA is a nonzero v\mathbf{v} with Av=λvA\mathbf{v} = \lambda\mathbf{v}: a line that AA keeps, stretched by the eigenvalue λ\lambda. A negative λ\lambda reverses the line, and λ=0\lambda = 0 squashes it to 0\mathbf{0}.
  • The eigenvalues solve det⁡(A−λI)=0\det(A - \lambda I) = 0. For 2×22 \times 2 this is λ2−(tr⁡A)λ+det⁡A=0\lambda^2 - (\operatorname{tr} A)\lambda + \det A = 0, the characteristic polynomial.
  • The eigenvectors of λ\lambda solve (A−λI)v=0(A - \lambda I)\mathbf{v} = \mathbf{0}: a line through 0\mathbf{0}. For 2×22 \times 2, v=(b,λ−a)\mathbf{v} = (b, \lambda - a) unless that is 0\mathbf{0}.
  • tr⁡A=λ1+λ2\operatorname{tr} A = \lambda_1 + \lambda_2 and det⁡A=λ1λ2\det A = \lambda_1\lambda_2; a zero eigenvalue means AA is singular.
  • A repeated eigenvalue may keep one line (the shear) or every line (2I2I). A turn through θ\theta has the complex pair e±iθe^{\pm i\theta} and keeps no real line.
  • np.linalg.eig returns eigenvectors as columns of length 1, in no fixed order and with either sign. Sort them, fix the signs, and use .real for real values.

Free further reading

Optional. This lesson covers what you need; these add more examples and practice. All are free to read.