Scientia sine finibus

Linear Algebra / Unit 5, Eigenvalues and Eigenvectors / Topic 5.3

Units and Topics

Unit 5. Eigenvalues and Eigenvectors

5.3 Diagonalization

This topic uses a basis of eigenvectors to write a matrix as A = PDP⁻¹, where D is a diagonal matrix. In that basis the map only stretches each coordinate, which makes powers of the matrix and many other calculations easy.

You need Topics 3.3, 4.6, 5.1, and 5.2 for this topic.

1. The Idea

Topic 4.6 showed that the matrix of a map in a new basis is P⁻¹AP, where the columns of P are the new basis vectors. It also showed one example in which the new matrix was diagonal. That happens exactly when the basis vectors are eigenvectors.

Suppose that an n by n matrix A has n independent eigenvectors v₁, …, vₙ, with the eigenvalues λ₁, …, λₙ. Put the eigenvectors in the columns of a matrix P, and put the eigenvalues, in the same order, on the diagonal of a matrix D. The product AP has the columns Av₁, …, Avₙ, which are λ₁v₁, …, λₙvₙ. The product PD has the same columns, because multiplying P by a diagonal matrix on the right multiplies its columns by the diagonal entries.

AP = PD

The columns of P are independent, so P has an inverse. Multiplying by P⁻¹ on the right, or on the left, gives the two forms of the result.

A = PDP⁻¹ and D = P⁻¹AP

Writing A in this way is called diagonalizing A. A matrix that can be written in this way is called diagonalizable.

2. An Example

Topic 5.1 found the eigenvalues 2 and 5 for the matrix below, with the eigenvectors (1, −2) and (1, 1).

A = 4123 P = 11−21 D = 2005

Check the equation AP = PD.

AP = 4123 11−21 = 25−45A times the eigenvectorsPD = 11−21 2005 = 25−45each column of P times its eigenvalue

The determinant of P is 3, and its inverse is

P⁻¹ = 1/3 1−121

The steps

  1. Find the eigenvalues from the characteristic equation.
  2. Find an eigenvector for each eigenvalue. For a repeated eigenvalue, find a basis of its eigenspace.
  3. If there are n independent eigenvectors, put them in the columns of P.
  4. Put the eigenvalues on the diagonal of D, in the same order as the columns of P.

The matrices P and D are not unique. The eigenvectors can be scaled, and the columns can be put in a different order, as long as D follows the same order.

3. What the Three Factors Do

Read A = PDP⁻¹ from right to left, as in Topic 4.6. To apply A to a vector:

  1. P⁻¹ finds the coordinates of the vector in the basis of eigenvectors.
  2. D multiplies each coordinate by its eigenvalue.
  3. P changes the result back into standard coordinates.

Step by step: the three factors of A

The matrix is A = PDP⁻¹ with the rows 2, 1 and 1, 2. Its eigenvectors are along the two dashed lines. Press Next to apply the three factors to the blue shape, one at a time. The gray outline is the original shape, and the green outline is the result of applying A directly.

The same statement can be made without matrices. Write a vector as a combination of the eigenvectors, x = c₁v₁ + c₂v₂. Then the map multiplies each term by its eigenvalue.

Ax = c₁λ₁v₁ + c₂λ₂v₂

Writing a vector as a combination of eigenvectors, and then treating each term separately, is the central method of quantum mechanics. A state is written as a combination of the eigenvectors of the energy, and each term then changes in time in a simple way.

4. Powers of a Matrix

In the product A² = (PDP⁻¹)(PDP⁻¹), the factors P⁻¹P in the middle cancel. The same happens for any power.

Ak = PDkP⁻¹

A power of a diagonal matrix is found by taking the same power of each diagonal entry. For the example, D³ has the entries 8 and 125.

A³ = PD³P⁻¹the power of a diagonalized matrixA³ = 11−21 800125 1/3 1−121D³ has the entries 2³ and 5³A³ = 1/3 8125−16125 1−121multiply P by D³A³ = 86397847multiply by P⁻¹

The work is the same for A³ and for A¹⁰⁰. Topic 5.4 uses this to study what happens when a map is applied many times.

5. When a Matrix Is Diagonalizable

An n by n matrix is diagonalizable exactly when it has n independent eigenvectors.

  • A matrix with n different eigenvalues is always diagonalizable, because eigenvectors of different eigenvalues are independent.
  • A matrix with a repeated eigenvalue is diagonalizable only if, for each eigenvalue, the geometric multiplicity is equal to the algebraic multiplicity.
  • A symmetric matrix is always diagonalizable, and its eigenvectors can be chosen perpendicular to each other. Unit 7 proves this.
MatrixEigenvaluesIndependent eigenvectorsDiagonalizable
41232 and 52Yes
30033, repeated2Yes. It is already diagonal
11011, repeated1No
0−110i and −iNone that are realNot with real numbers

The rotation in the last row is diagonalizable when complex numbers are allowed. The shear in the third row is not diagonalizable with any numbers.

Being diagonalizable and having an inverse are different properties. The matrix with the rows 1, 2 and 2, 4 has the eigenvalues 0 and 5. It is diagonalizable, and it has no inverse. The shear has an inverse, and it is not diagonalizable.

6. What the Diagonal Form Shows

  • The determinant of A is the product of the diagonal entries of D, and the trace of A is their sum, because A and D are similar.
  • The rank of A is the number of eigenvalues that are not 0.
  • If no eigenvalue is 0, then A⁻¹ = PD⁻¹P⁻¹, and D⁻¹ has the entries 1/λ₁, …, 1/λₙ.

Common Mistakes

  • Putting the eigenvalues in D in a different order from the eigenvectors in P.
  • Writing the eigenvectors as the rows of P. They are the columns.
  • Exchanging P and P⁻¹. With the eigenvectors in the columns of P, the correct forms are A = PDP⁻¹ and D = P⁻¹AP.
  • Assuming that a matrix with a repeated eigenvalue cannot be diagonalized. Count the independent eigenvectors.
  • Assuming that a matrix that has no inverse cannot be diagonalized. An eigenvalue of 0 is allowed.
  • Calculating Ak by taking the power of each entry of A. That works only for a diagonal matrix.

Summary

FactStatement
DiagonalizationA = PDP⁻¹, with eigenvectors in the columns of P and eigenvalues on the diagonal of D
ConditionA has n independent eigenvectors
Enough, but not necessaryn different eigenvalues
PowersAk = PDkP⁻¹
In the eigenvector basisThe map multiplies each coordinate by its eigenvalue

Practice

Work each problem on paper first. Then open the answer to check your work.

1. Diagonalize 1221. Its eigenvalues are 3 and −1, with the eigenvectors (1, 1) and (1, −1).

P = 111−1 and D = 300−1.

Check: AP = 3−131 and PD = 3−131.

2. A matrix has P = 1101 and D = 2003. Find A.

P⁻¹ = 1−101.

PD = 2303, and A = PDP⁻¹ = 2103.

3. Is 2102 diagonalizable?

The eigenvalue 2 is repeated. A − 2I = 0100, which gives y = 0.

The eigenvectors are only the multiples of (1, 0). There is 1 independent eigenvector, so the matrix is not diagonalizable.

4. Use A = PDP⁻¹ from Part 2 to calculate A² for A = 4123, and check the result by multiplying A by itself.

D² = 40025square each diagonal entryPD² = 425−825multiply P by D²A² = 1/3 425−825 1−121multiply by P⁻¹A² = 1/3 54214233 = 1871411divide each entry by 3A² = 16 + 24 + 38 + 62 + 9 = 1871411the direct product, as a check

5. A 3 by 3 matrix has the eigenvalues 1, 2, and 2. What must be checked to decide whether it is diagonalizable?

The eigenvalue 2 has the algebraic multiplicity 2. The matrix is diagonalizable exactly when the eigenspace of 2 has the dimension 2, which means that A − 2I has the rank 1.

6. Write x = (3, 0) as a combination of the eigenvectors (1, −2) and (1, 1) of A = 4123, and use it to find Ax.

c₁ + c₂ = 3the first components−2c₁ + c₂ = 0the second componentsc₁ = 1subtract the second equation from the first, then divide by 3c₂ = 2substitute c₁ = 1Ax = (1)(2)(1, −2) + (2)(5)(1, 1)each part is multiplied by its eigenvalueAx = (2, −4) + (10, 10) = (12, 6)

Check: the direct product is (12, 6).

Python Practice

Step 1. Check a diagonalization

The code below stores the matrices P and D from Part 2 of this topic and multiplies the three factors. The instruction np.linalg.inv calculates an inverse, np.diag builds a diagonal matrix from a list of its diagonal entries, and the @ sign multiplies matrices.

Python

The result is the matrix A with the rows 4, 1 and 2, 3. Python prints the entries as decimal numbers, and a very small rounding error in the last digits is normal.

Step 2. Keep the same order in P and D

In the next box, the columns of P are the eigenvectors (1, 1) and (1, −2), in that order. The eigenvalues in D are in the wrong order for this P, so the product is not A. Correct the second line.

Python

Step 3. Calculate a power

Python writes a power with two stars, so 2**3 is 2³ = 8. The code below calculates A³ in two ways: with the diagonal form, and with the instruction np.linalg.matrix_power, which multiplies a matrix by itself the given number of times.

Python

Both results have the rows 86, 39 and 78, 47, as in Part 4.

In the next box, change the code so that R is A¹⁰, calculated with the diagonal form. The last line prints the same power calculated directly, for comparison.

Python

Step 4. Let Python find P and D

From Topic 5.1, the instruction np.linalg.eig gives the eigenvalues and a matrix whose columns are eigenvectors. These are the diagonal of D and the matrix P.

Python

The first result is the diagonal matrix with the entries 5 and 2. The second result is A again.

Now diagonalize the matrix of Practice Problem 1, which has the rows 1, 2 and 2, 1.

Python

Step 5. A matrix that is not diagonalizable

The shear from Part 5 has only one line of eigenvectors. The code below asks Python for its eigenvectors, and then prints the determinant of the matrix V.

Python

Both eigenvalues are 1. The two columns of V are on the same line, apart from a very small rounding error, and the determinant of V is a number such as 2.2e-16, which should be read as 0. So V has no inverse, and the shear cannot be written as PDP⁻¹. Python does not give a warning in this case. Check the determinant of V when a matrix has a repeated eigenvalue.

Quiz

This quiz has 5 questions on this topic. A question asks you either to choose one answer or to type numbers. The page grades your answers and explains each one. A number can be typed as a whole number, a decimal, a fraction such as 1/3, or a calculation such as sqrt(18)/2 or arccos(1/2). The page shows the value of a calculation next to the box. Angles in a calculation are in degrees. The Calculator button under each question opens a calculator. Your answers are saved in your browser, so they are still on the page when you come back to it.

Choose how your answers are checked

1. In the factorization A = PDP⁻¹, what are the columns of P?

2. Let P = 1101 and D = 1004. Calculate A = PDP⁻¹.

3. Which of these matrices is not diagonalizable?

4. Let D = 200−1. Find the two diagonal entries of D⁵.

5. A 3 by 3 matrix has the eigenvalues 1, 4, and 7. Is the matrix diagonalizable?

Next: Topic 5.4, Powers of a Matrix and Markov Chains