Linear Algebra · Diagonalization

Diagonalization

Writing the same linear transformation in another basis changes its matrix from A to B = P⁻¹AP, where the columns of P are the new basis vectors. Diagonalizing A means finding a basis in which B is diagonal; that happens exactly when the basis vectors are eigenvectors.

Diagonalization in this visualization

A linear transformation of the plane has the matrix AA in the standard basis. In another basis b1,b2b_1, b_2, the columns of PP, the same transformation has the matrix B=P−1APB = P^{-1}AP: to transform a vector given by its coordinates cc in the new basis, turn them into standard coordinates PcPc, apply AA, and turn the result back with P−1P^{-1}. The jj-th column of BB holds the coordinates of AbjAb_j in the new basis: Abj=B1jb1+B2jb2Ab_j = B_{1j}b_1 + B_{2j}b_2. Diagonalizing AA means finding a basis in which BB is diagonal. In the picture the basis is blue, the images Ab1,Ab2Ab_1, Ab_2 are ink, and the picked image is split in yellow into its two parts.

What a change of basis keeps

Every entry of BB can change with the basis, but AA and BB describe one transformation, so whatever belongs to the transformation itself stays: the trace (tr⁡(P−1AP)=tr⁡A\operatorname{tr}(P^{-1}AP) = \operatorname{tr} A), the determinant, and the eigenvalues. For the default matrix the trace stays 5 and the determinant 4 in every basis.

Why eigenvectors make B diagonal

The first column of BB is (λ,0)(\lambda, 0) exactly when Ab1=λb1Ab_1 = \lambda b_1, that is, when b1b_1 is an eigenvector; the same goes for the second column. So BB is diagonal exactly when both basis vectors are eigenvectors, and then A=PDP−1A = PDP^{-1} with DD the diagonal matrix of eigenvalues. This makes powers easy: An=PDnP−1A^n = PD^nP^{-1}, and DnD^n only raises each diagonal entry to the nn-th power. For the default matrix, D=diag⁡(4,1)D = \operatorname{diag}(4, 1) gives A10=(699051349525699050349526)A^{10} = \begin{pmatrix} 699051 & 349525 \\ 699050 & 349526 \end{pmatrix} without multiplying AA ten times. A real symmetric matrix can always be given an eigenbasis of perpendicular vectors.

When it cannot be done

A real 2 × 2 matrix can be diagonalized with a real basis exactly when it has two real eigenvectors pointing in different directions. Two different real eigenvalues guarantee that, but they are not needed: λI\lambda I has one eigenvalue twice and is already diagonal. A shear has only one eigenline; with b1b_1 on it the first column becomes (1,0)(1, 0), but the upper-right entry stays nonzero for every b2b_2 independent of b1b_1, and an upper triangular matrix is the best a basis can do. A quarter turn moves every real direction, so no real basis works; with complex numbers it can be diagonalized.

Things to notice

  • The diagonal entries come in the order of the basis vectors: swapping b₁ and b₂ swaps them.
  • Stretching either eigenvector of an eigenbasis changes P but not B.

Controls

  • Drag the tips of the blue basis vectors; near an eigenline a tip snaps onto it. Arrow keys move a focused tip by 0.1.

Related