Diagonalisation and where linear algebra is used
Use eigenvectors to compute powers of a matrix, follow a Markov chain to its steady state, and see how the same ideas drive graphics and machine learning.
28 min
Diagonalisation
If A has n independent eigenvectors, put them as the columns of P and the eigenvalues on the diagonal of D. Then
A = P D P⁻¹, and so Aᵏ = P Dᵏ P⁻¹.
Raising a diagonal matrix to a power just raises each entry to that power, so a heavy computation becomes simple. In the eigenvector basis the matrix is only a set of stretches.
Not every matrix can be diagonalised (for example [1 1; 0 1], which has only one independent eigenvector). A symmetric matrix always can, with perpendicular eigenvectors.
Compute A³ for A = [4 1; 2 3], using P = [1 1; 1 −2] and D = diag(5, 2).
- 1
D³ = diag(125, 8)
Cube each eigenvalue.
Markov chains: where it all settles
A Markov chain describes a population moving between states with fixed probabilities each step. Suppose each day 10% of people who are well fall ill, and 50% of those ill recover. Written as a matrix whose columns sum to 1:
M = [0.9 0.5; 0.1 0.5], state s = (share well, share ill).
After one step s becomes Ms. The steady state satisfies Ms = s: an eigenvector with eigenvalue 1. Solving (M − I)s = 0: −0.1w + 0.5i = 0, so i = 0.2w; with w + i = 1 you get s = (5/6, 1/6). The other eigenvalue is 0.4, and 0.4ᵏ → 0, which is why every start ends at the same steady state.
Where eigenvectors and matrices show up.
Rotation, scaling and projection matrices (graphics)
- The matrix
- Each vertex of a 3D model is multiplied by a transformation matrix
- What the eigen-idea gives
- Composition of moves is matrix multiplication; |det| tells you scaling
Covariance matrix of a data set (machine learning)
- The matrix
- Its eigenvectors are the directions of greatest variation
- What the eigen-idea gives
- Principal component analysis keeps the top few to compress data
Web link matrix (search ranking)
- The matrix
- Importance scores are the steady-state eigenvector
- What the eigen-idea gives
- Same idea as the Markov chain above
Stiffness or vibration matrices (engineering)
- The matrix
- Eigenvalues give natural frequencies
- What the eigen-idea gives
- Eigenvectors give the mode shapes
Write fib(n) that returns the n-th Fibonacci number (fib(0) = 0, fib(1) = 1) by raising the matrix [[1, 1], [1, 0]] to the power n with repeated multiplication. The top-right entry of M^n is fib(n).
Your code must satisfy
- fib(0)→0zero
- fib(1)→1one
- fib(10)→55ten
- fib(30)→832040thirty
def fib(n):
M = [[1, 1], [1, 0]]
R = [[1, 0], [0, 1]]
# multiply R by M, n times
return R[0][1]- A = PDP⁻¹ gives Aᵏ = PDᵏP⁻¹: power the eigenvalues, not the matrix.
- A steady state is an eigenvector with eigenvalue 1.
- In a Markov chain the other eigenvalues have size below 1 and fade away.
- Graphics, PCA and ranking all rest on matrices and eigenvectors.
- Symmetric matrices always diagonalise, with perpendicular eigenvectors.
Practice.
A has eigenvalues 5 and 2. What is the larger eigenvalue of A⁴?
In the Markov chain M = [0.9 0.5; 0.1 0.5], what share is well in the steady state? Give a decimal to 3 places.
Which matrix is NOT diagonalisable?
- A[2 0; 0 3]
- B[1 1; 0 1]
- C[1 2; 2 1]
- D[3 0; 0 3]
In PCA, the first principal component is:
- Athe smallest eigenvector of the covariance matrix
- Bthe eigenvector of the covariance matrix with the largest eigenvalue
- Cthe mean of the data
- Dthe determinant
A has eigenvalues 2, 3 and −1. Find det A.
Think of something in your own field that changes in repeated steps (money, a population, a recommendation, a game). What would its long-run steady state tell you?
Practise this lesson, not just read it
In BiliMind the questions above are marked when you answer, the flashcards come back on a schedule, and the rest of Linear Algebra is planned around your week. Free.