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 2 of 5

ConceptLesson 3.6.2 in Level 3, Linear algebra. About 30 minutes.

Diagonalisation and matrix powers

Working along the eigenvectors

Lesson 3.6.1 found the eigenvectors of

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

They are v1=(2,3)\mathbf{v}_1 = (2, 3) with λ1=4\lambda_1 = 4, and v2=(1,−1)\mathbf{v}_2 = (1, -1) with λ2=−1\lambda_2 = -1. The two do not lie on one line, so they form a basis of the plane (lesson 3.5.1): every vector is a combination c1v1+c2v2c_1\mathbf{v}_1 + c_2\mathbf{v}_2. The numbers c1c_1 and c2c_2 are its coordinates in the eigenvector basis.

Take x=(4,1)\mathbf{x} = (4, 1). The two equations 2c1+c2=42c_1 + c_2 = 4 and 3c1−c2=13c_1 - c_2 = 1 add up to 5c1=55c_1 = 5. So c1=1c_1 = 1, c2=2c_2 = 2, and x=v1+2v2\mathbf{x} = \mathbf{v}_1 + 2\mathbf{v}_2.

A linear map keeps combinations (lesson 3.2.2), and it multiplies each eigenvector by its eigenvalue:

Ax=Av1+2Av2=4v1−2v2=(8,12)+(−2,2)=(6,14)\begin{aligned} A\mathbf{x} &= A\mathbf{v}_1 + 2A\mathbf{v}_2 = 4\mathbf{v}_1 - 2\mathbf{v}_2 \\ &= (8, 12) + (-2, 2) = (6, 14) \end{aligned}

Multiplying directly agrees: A(4,1)=(4+2, 12+2)=(6,14)A(4, 1) = (4 + 2,\ 12 + 2) = (6, 14). In eigenvector coordinates, AA turned (1,2)(1, 2) into (4,−2)(4, -2): it multiplied each coordinate by its own eigenvalue.

Each further multiplication does the same again, so Akx=4kv1+2 (−1)k v2A^k\mathbf{x} = 4^k\mathbf{v}_1 + 2\,(-1)^k\,\mathbf{v}_2. Here AkA^k means AA times itself kk times, and A0=IA^0 = I.

kk012345
AkxA^k\mathbf{x}(4,1)(4, 1)(6,14)(6, 14)(34,46)(34, 46)(126,194)(126, 194)(514,766)(514, 766)(2046,3074)(2046, 3074)

For k=3k = 3 the formula gives 64 (2,3)−2 (1,−1)=(126,194)64\,(2, 3) - 2\,(1, -1) = (126, 194), without multiplying by AA three times.

Rule: Powers along the eigenvectors

x=c1v1+c2v2Akx=c1λ1k v1+c2λ2k v2\begin{gathered} \mathbf{x} = c_1\mathbf{v}_1 + c_2\mathbf{v}_2 \\[4pt] A^k\mathbf{x} = c_1\lambda_1^k\,\mathbf{v}_1 + c_2\lambda_2^k\,\mathbf{v}_2 \end{gathered}

Split x\mathbf{x} along the eigenvectors, raise each eigenvalue to the power kk, and add the parts back up. The same holds with nn terms for an n×nn \times n matrix with nn independent eigenvectors.

Try it

np.linalg.solve finds the coordinates (c1,c2)=(1,2)(c_1, c_2) = (1, 2): it solves c1v1+c2v2=xc_1\mathbf{v}_1 + c_2\mathbf{v}_2 = \mathbf{x}, a system whose columns are the eigenvectors.

np.linalg.matrix_power(A, k) multiplies AA by itself kk times. Each line shows the direct answer and the formula.

⌘/Ctrl + Enter runs the cell

Diagonalisation

Put the eigenvectors side by side as the columns of a matrix PP. Put the eigenvalues, in the same order, on the diagonal of Λ\Lambda (capital lambda):

P=(213−1)Λ=(400−1)\begin{gathered} P = \begin{pmatrix} 2 & 1 \\ 3 & -1 \end{pmatrix} \\[6pt] \Lambda = \begin{pmatrix} 4 & 0 \\ 0 & -1 \end{pmatrix} \end{gathered}

Column jj of APAP is Avj=λjvjA\mathbf{v}_j = \lambda_j\mathbf{v}_j, and so is column jj of PΛP\Lambda. So AP=PΛAP = P\Lambda. When PP has an inverse, multiplying both sides by P−1P^{-1} on the right gives the factorisation.

Rule: Diagonalisation

A=PΛP−1A = P\Lambda P^{-1}

PP holds the eigenvectors as columns and Λ\Lambda the eigenvalues on its diagonal, in the same order. It works exactly when AA has nn independent eigenvectors, so that PP has an inverse; AA is then called diagonalisable. A matrix with nn different eigenvalues always is.

Read the product from right to left, as in lesson 3.2.2. P−1P^{-1} finds the coordinates of x\mathbf{x} along the eigenvectors, Λ\Lambda multiplies each coordinate by its eigenvalue, and PP builds the vector back.

PP has ad−bc=−2−3=−5ad - bc = -2 - 3 = -5, so the formula of lesson 3.2.3 gives

P−1=1−5(−1−1−32)=(0.20.20.6−0.4)\begin{aligned} P^{-1} &= \frac{1}{-5}\begin{pmatrix} -1 & -1 \\ -3 & 2 \end{pmatrix} \\[4pt] &= \begin{pmatrix} 0.2 & 0.2 \\ 0.6 & -0.4 \end{pmatrix} \end{aligned}

and P−1(4,1)=(1,2)P^{-1}(4, 1) = (1, 2): the coordinates found above.

PP is not the only choice. Any nonzero multiples of the eigenvectors work, such as (1,1.5)(1, 1.5) for (2,3)(2, 3), and so does another order, as long as Λ\Lambda follows it.

Try it

The cell checks AP=PΛAP = P\Lambda exactly, then PΛP−1=AP\Lambda P^{-1} = A with np.allclose, because P−1P^{-1} is computed in decimals.

The last line uses P−1P^{-1} to find the coordinates of (4,1)(4, 1).

⌘/Ctrl + Enter runs the cell

Matrix powers

Squaring the factorisation, the P−1PP^{-1}P in the middle is II and drops out:

A2=PΛP−1 PΛP−1=PΛ2P−1\begin{aligned} A^2 &= P\Lambda P^{-1}\,P\Lambda P^{-1} \\ &= P\Lambda^2 P^{-1} \end{aligned}

Every further factor does the same, so only Λ\Lambda is raised to the power. A power of a diagonal matrix is just the powers of its diagonal entries.

Rule: Powers of a diagonalisable matrix

Ak=PΛkP−1Λk=(λ1k00λ2k)\begin{gathered} A^k = P\Lambda^k P^{-1} \\[4pt] \Lambda^k = \begin{pmatrix} \lambda_1^k & 0 \\ 0 & \lambda_2^k \end{pmatrix} \end{gathered}

AkA^k has the same eigenvectors as AA, and eigenvalues λ1k\lambda_1^k and λ2k\lambda_2^k. If no eigenvalue is 0, the inverse works the same way: A−1=PΛ−1P−1A^{-1} = P\Lambda^{-1}P^{-1}.

For k=5k = 5, Λ5\Lambda^5 has the diagonal 45=10244^5 = 1024 and (−1)5=−1(-1)^5 = -1:

PΛ5=(2048−130721)A5=PΛ5P−1=(409410615614)\begin{gathered} P\Lambda^5 = \begin{pmatrix} 2048 & -1 \\ 3072 & 1 \end{pmatrix} \\[6pt] A^5 = P\Lambda^5 P^{-1} = \begin{pmatrix} 409 & 410 \\ 615 & 614 \end{pmatrix} \end{gathered}

For k=10k = 10 the work is the same: two numbers to raise, two products to form. The answer is (419431419430629145629146)\begin{pmatrix} 419431 & 419430 \\ 629145 & 629146 \end{pmatrix}, which nine multiplications by AA confirm.

The inverse has eigenvalues 14\frac{1}{4} and −1-1, and PΛ−1P−1=(−0.50.50.75−0.25)P\Lambda^{-1}P^{-1} = \begin{pmatrix} -0.5 & 0.5 \\ 0.75 & -0.25 \end{pmatrix}, the same as np.linalg.inv(A).

Try it

For k=5k = 5 and k=10k = 10, the cell builds Λk\Lambda^k from the two powers with np.diag, prints PΛkP−1P\Lambda^kP^{-1}, then matrix_power for comparison.

The last line compares PΛ−1P−1P\Lambda^{-1}P^{-1} with np.linalg.inv(A).

⌘/Ctrl + Enter runs the cell

The largest eigenvalue takes over

In Akx=4kv1+2 (−1)k v2A^k\mathbf{x} = 4^k\mathbf{v}_1 + 2\,(-1)^k\,\mathbf{v}_2, the first part grows four times at each step while the second keeps its size. Divide by 4k4^k:

kk012345
Akx/4kA^k\mathbf{x} / 4^k(4,1)(4, 1)(1.5,3.5)(1.5, 3.5)(2.125,2.875)(2.125, 2.875)(1.9688,3.0312)(1.9688, 3.0312)(2.0078,2.9922)(2.0078, 2.9922)(1.998,3.002)(1.998, 3.002)

The rows close in on v1=(2,3)\mathbf{v}_1 = (2, 3), from alternate sides because λ2\lambda_2 is negative. What is left of v2\mathbf{v}_2 is 2(−14)kv22\left(-\frac{1}{4}\right)^k\mathbf{v}_2, a quarter of its size at each step.

Rule: The dominant eigenvalue

Akx≈c1λ1k v1when ∣λ1∣>∣λ2∣\begin{gathered} A^k\mathbf{x} \approx c_1\lambda_1^k\,\mathbf{v}_1 \\[4pt] \text{when } \lvert\lambda_1\rvert > \lvert\lambda_2\rvert \end{gathered}

For large kk, the eigenvalue of largest size wins, as long as c1≠0c_1 \neq 0. The rest shrinks like ∣λ2/λ1∣k\lvert \lambda_2 / \lambda_1 \rvert^k. In the long run AkxA^k\mathbf{x} grows if ∣λ1∣>1\lvert\lambda_1\rvert > 1, settles if λ1=1\lambda_1 = 1, and dies away if ∣λ1∣<1\lvert\lambda_1\rvert < 1.

Try it

Each line divides AkxA^k\mathbf{x} by 4k4^k, rounded to 4 places, then prints the part left over from v2\mathbf{v}_2, which is 2(−14)kv22\left(-\frac{1}{4}\right)^k\mathbf{v}_2.

⌘/Ctrl + Enter runs the cell

Two towns that swap people

Each year 10% of the people in town A move to town B, and 20% of those in town B move to town A. Write s=(sA,sB)\mathbf{s} = (s_A, s_B) for the shares of the people living in each town, so sA+sB=1s_A + s_B = 1.

Next year A keeps 90% of its own and gains 20% of B's: 0.9sA+0.2sB0.9s_A + 0.2s_B. B gets the rest: 0.1sA+0.8sB0.1s_A + 0.8s_B. So each year multiplies s\mathbf{s} by

M=(0.90.20.10.8)M = \begin{pmatrix} 0.9 & 0.2 \\ 0.1 & 0.8 \end{pmatrix}

Column jj says where the people of town jj go. Each column adds up to 1, so nobody is lost and the shares still add up to 1.

MM has trace 1.7 and determinant 0.72−0.02=0.70.72 - 0.02 = 0.7. Its polynomial is λ2−1.7λ+0.7=(λ−1)(λ−0.7)\lambda^2 - 1.7\lambda + 0.7 = (\lambda - 1)(\lambda - 0.7), so the eigenvalues are 1 and 0.7.

  • λ1=1\lambda_1 = 1: the shortcut of lesson 3.6.1 gives (0.2,0.1)(0.2, 0.1), or as shares, (23,13)\left(\frac{2}{3}, \frac{1}{3}\right). Here Ms=sM\mathbf{s} = \mathbf{s}: a steady state that stays put year after year.
  • λ2=0.7\lambda_2 = 0.7: the eigenvector (1,−1)(1, -1) moves people from one town to the other. It shrinks by 0.7 each year.

Start from s0=(0.5,0.5)\mathbf{s}_0 = (0.5, 0.5), which is (23,13)−16(1,−1)\left(\frac{2}{3}, \frac{1}{3}\right) - \frac{1}{6}(1, -1). After kk years the shares are

sk=(23,13)−16 (0.7)k (1,−1)\mathbf{s}_k = \left(\tfrac{2}{3}, \tfrac{1}{3}\right) - \tfrac{1}{6}\,(0.7)^k\,(1, -1)

After 10 years, 0.710≈0.02820.7^{10} \approx 0.0282 and s10≈(0.662,0.338)\mathbf{s}_{10} \approx (0.662, 0.338). The gap to the steady state is multiplied by 0.7 each year, so it halves about every two years, since 0.72=0.490.7^2 = 0.49.

From any start, the share in town A settles on 23\frac{2}{3}, the eigenvector of λ=1\lambda = 1. On a log scale the gaps are straight lines: each year multiplies them by the other eigenvalue, 0.7.

Lesson 5.11.2 reads such shares as probabilities: MM becomes a Markov chain, and the eigenvector of λ=1\lambda = 1 its long-run distribution.

Try it

The loop moves the shares forward one year at a time and prints some years. V[:, 0] / V[:, 0].sum() scales the eigenvector of λ=1\lambda = 1 so its entries add up to 1, which also fixes its sign.

The last line is the formula for s10\mathbf{s}_{10}.

⌘/Ctrl + Enter runs the cell

When a matrix cannot be diagonalised

The shear H=(1101)H = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix} has the eigenvalue 1 twice, and only one eigenvector line, the x1x_1-axis (lesson 3.6.1). Any two of its eigenvectors lie on that line, so a matrix PP built from them is singular. HH is not diagonalisable.

Its powers show it. Three shears make a shear by 3 (lesson 3.2.2), and in general Hk=(1k01)H^k = \begin{pmatrix} 1 & k \\ 0 & 1 \end{pmatrix}. The corner grows by 1 at every step, which no power of the eigenvalue 1 can produce.

A repeated eigenvalue alone is not the problem. 2I2I also has one eigenvalue twice, and it is already diagonal. What matters is whether there are nn independent eigenvectors.

Complex eigenvalues are another matter. The quarter turn RR has eigenvalues ii and −i-i, and it can be diagonalised with complex numbers, which is what eig does. For example R4=IR^4 = I, matching i4=1i^4 = 1 (lesson 1.7.2).

Try it

eig returns two eigenvector columns for HH, but with signs fixed both are (1,0)(1, 0). The determinant of that PP is 0 up to rounding, so the cell compares it with 10−1210^{-12} rather than printing it.

Then come H2H^2, H3H^3 and H10H^{10}, and R4=IR^4 = I.

⌘/Ctrl + Enter runs the cell

The power method

The dominant eigenvalue gives a way to find it without the characteristic polynomial. Multiply a starting vector by AA again and again: its direction settles on v1\mathbf{v}_1. Rescale it to length 1 at every step, so the numbers neither explode nor vanish.

To read off λ1\lambda_1, use the dot product x⋅(Ax)\mathbf{x} \cdot (A\mathbf{x}) for the current unit vector x\mathbf{x}. If x\mathbf{x} were exactly a unit eigenvector, this would be x⋅λ1x=λ1\mathbf{x} \cdot \lambda_1\mathbf{x} = \lambda_1.

Rule: The power method

x←Ax∥Ax∥λ1≈x⋅(Ax)\begin{gathered} \mathbf{x} \leftarrow \frac{A\mathbf{x}}{\lVert A\mathbf{x} \rVert} \\[4pt] \lambda_1 \approx \mathbf{x} \cdot (A\mathbf{x}) \end{gathered}

Repeat until the estimate stops changing. The error shrinks like ∣λ2/λ1∣k\lvert \lambda_2 / \lambda_1 \rvert^k, so it is fast when λ1\lambda_1 is far ahead and slow when λ2\lambda_2 is close behind.

From (1,0)(1, 0), the estimates for AA run 3.4, 4.0462, 3.9804, 4.0044, 3.9989, … The error falls about four times at each step, since ∣λ2/λ1∣=14\lvert \lambda_2/\lambda_1 \rvert = \frac{1}{4}. After 8 steps x≈(0.5547,0.832)\mathbf{x} \approx (0.5547, 0.832), which is (2,3)(2, 3) scaled to length 1.

The method fails in two cases:

  • No single winner. If ∣λ1∣=∣λ2∣\lvert\lambda_1\rvert = \lvert\lambda_2\rvert, as for the reflection (100−1)\begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix} or any turn, the direction never settles.
  • A start with c1=0c_1 = 0. From (1,−1)(1, -1), AA only flips the vector, and the method finds λ2=−1\lambda_2 = -1. A random start almost never has c1=0c_1 = 0 exactly.

NumPy's eig uses a refined descendant of this idea, the QR algorithm. The power method itself is used for very large matrices when only the top eigenvalue is needed. Practice set 3.6.4 asks you to write it.

Try it

Each step multiplies by AA and rescales. The line prints the step, x\mathbf{x}, the estimate of λ1\lambda_1, and its distance from 4.

⌘/Ctrl + Enter runs the cell

Common mistakes

  1. Match the order. Column jj of PP must be the eigenvector of the jj-th diagonal entry of Λ\Lambda.
  2. PΛP−1P\Lambda P^{-1}, not P−1ΛPP^{-1}\Lambda P. Reading right to left, P−1P^{-1} acts first and finds the eigenvector coordinates.
  3. A matrix power is not a power of each entry. A**3 in NumPy cubes every entry. Use np.linalg.matrix_power(A, 3) or A @ A @ A.
  4. Size decides who wins. With eigenvalues −5-5 and 3, the −5-5 takes over, and AkxA^k\mathbf{x} flips direction at every step.
  5. A repeated eigenvalue does not settle the question. 2I2I is diagonalisable and the shear is not: count the independent eigenvectors.
  6. The power method needs a clear winner and a start with some part along v1\mathbf{v}_1.

Diagonalisation and matrix powers

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

  • Write x=c1v1+c2v2\mathbf{x} = c_1\mathbf{v}_1 + c_2\mathbf{v}_2 in the eigenvector basis; then Akx=c1λ1kv1+c2λ2kv2A^k\mathbf{x} = c_1\lambda_1^k\mathbf{v}_1 + c_2\lambda_2^k\mathbf{v}_2.
  • A=PΛP−1A = P\Lambda P^{-1}, with the eigenvectors as the columns of PP and the eigenvalues on the diagonal of Λ\Lambda, in the same order. It needs nn independent eigenvectors; nn different eigenvalues guarantee them.
  • Ak=PΛkP−1A^k = P\Lambda^kP^{-1}: raise only the eigenvalues. AkA^k has eigenvalues λk\lambda^k, so tr⁡Ak=λ1k+λ2k\operatorname{tr} A^k = \lambda_1^k + \lambda_2^k.
  • The eigenvalue of largest size takes over, and the rest shrinks like ∣λ2/λ1∣k\lvert\lambda_2/\lambda_1\rvert^k. With λ1=1\lambda_1 = 1, the shares settle on its eigenvector, the steady state.
  • The shear has one eigenvector line and is not diagonalisable: Hk=(1k01)H^k = \begin{pmatrix} 1 & k \\ 0 & 1 \end{pmatrix}.
  • The power method: x←Ax/∥Ax∥\mathbf{x} \leftarrow A\mathbf{x} / \lVert A\mathbf{x} \rVert, λ1≈x⋅(Ax)\lambda_1 \approx \mathbf{x} \cdot (A\mathbf{x}). It needs ∣λ1∣>∣λ2∣\lvert\lambda_1\rvert > \lvert\lambda_2\rvert.

Free further reading

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