Skip to content
The Lumenary
Advanced undergraduateUndergraduate 130 min

Advanced linear algebra

How simple can a matrix be made? Orthonormal eigenbases for symmetric operators, the Jordan form of every complex matrix, and the dual spaces and tensor products that let linear algebra speak without coordinates.

Formally verified · 18 LeanComputationally tested · 2 PythonAI-drafted · awaiting human reviewMathematically reviewed: Awaiting human review
MotivationH

Three questions a first course leaves open

A structural engineer in Nairobi models the stress at a point of a concrete beam by a symmetric 3×33 \times 3 matrix. She needs the principal stresses — directions in which the material is pulled or pushed straight, with no shear — and she is confident that there are exactly three of them, at right angles to each other. Why should a symmetric matrix always have three mutually perpendicular eigenvector directions, when a general matrix need not have any real eigenvectors at all? The same question, asked by a statistician in São Paulo about a covariance matrix, is the foundation of principal component analysis.

A student in Hanoi solves the differential equation x′′−2x′+x=0x'' - 2x' + x = 0 and finds the solutions ete^t and t ett\,e^t. Where does the factor tt come from? Writing the equation as a system x′=Ax\mathbf x' = A\mathbf x with A=(01−12)A = \begin{pmatrix} 0 & 1 \\ -1 & 2 \end{pmatrix}, the answer is that AA cannot be diagonalised. Something replaces diagonalisation for such matrices, and it is just as computable.

Finally, a physicist writes the state of two entangled photons as 12(∣0⟩⊗∣0⟩+∣1⟩⊗∣1⟩)\tfrac{1}{\sqrt2}(\lvert 0 \rangle \otimes \lvert 0 \rangle + \lvert 1 \rangle \otimes \lvert 1 \rangle), and insists that it cannot be written as (state of photon 1) ⊗\otimes (state of photon 2). What kind of object is ⊗\otimes, and why is that impossible?

The first course in linear algebra stated the spectral theorem and mentioned the Jordan form. This lesson proves them, and builds the coordinate-free tools — dual spaces and tensor products — that answer the third question and underlie most of higher mathematics.

IntuitionH

Choosing coordinates well

A linear operator T:V→VT : V \to V has a different matrix in every basis; changing basis replaces AA by P−1APP^{-1}AP. So the real question about TT is: in which basis does its matrix look simplest? Two answers organise the lesson.

  • If VV has an inner product and TT is self-adjoint (symmetric, in an orthonormal basis), we may insist on an orthonormal basis and still make the matrix diagonal, with real entries. Geometrically: TT maps the unit sphere to an ellipsoid, and the axes of the ellipsoid are perpendicular eigenvector directions. That is the spectral theorem.
  • For an arbitrary operator on a complex vector space we cannot always diagonalise, but we can always reach the Jordan normal form: block diagonal, each block having one eigenvalue on its diagonal and 11s just above it. The 11s record exactly how far TT is from being diagonalisable, and they are what produce the t ett\,e^t.

The second half of the lesson goes the other way and removes coordinates altogether. A linear functional — a linear map V→kV \to k — is the coordinate-free version of a row vector; they form the dual space V∗V^*. A tensor product V⊗WV \otimes W is the space in which bilinear expressions in vv and ww become linear. Both are defined by what they do, not by a choice of basis, and the difference between "natural" and "chosen" identifications turns out to be mathematics in its own right.

DefinitionsH

Definitions

Throughout, kk is a field and vector spaces are finite-dimensional unless said otherwise.

Definition— inner product space

A real inner product space is a real vector space VV with a map ⟨⋅,⋅⟩:V×V→R\langle \cdot, \cdot \rangle : V \times V \to \R that is bilinear, symmetric (⟨v,w⟩=⟨w,v⟩\langle v, w \rangle = \langle w, v \rangle) and positive definite (⟨v,v⟩>0\langle v, v \rangle > 0 for v≠0v \neq 0). A complex inner product is instead sesquilinear: conjugate-linear in the first slot and linear in the second, with ⟨w,v⟩=⟨v,w⟩‾\langle w, v \rangle = \overline{\langle v, w \rangle} and ⟨v,v⟩>0\langle v, v \rangle > 0 for v≠0v \ne 0. (Physicists and Mathlib use this convention; many algebra texts put the conjugate in the second slot. Nothing below depends on the choice.) We write ∥v∥=⟨v,v⟩\|v\| = \sqrt{\langle v, v \rangle}. Vectors are orthogonal if ⟨v,w⟩=0\langle v, w \rangle = 0, and U⊥={v:⟨u,v⟩=0 for all u∈U}U^\perp = \{ v : \langle u, v \rangle = 0 \text{ for all } u \in U \}.

Definition— adjoint, self-adjoint, normal, unitary

The adjoint of T:V→VT : V \to V is the unique operator T∗T^* with ⟨Tv,w⟩=⟨v,T∗w⟩\langle Tv, w \rangle = \langle v, T^* w \rangle for all v,wv, w. (It exists: for fixed ww, the map v↦⟨w,Tv⟩v \mapsto \langle w, Tv \rangle is a linear functional, so by the Riesz representation of Theorem 13 it equals ⟨u,⋅⟩\langle u, \cdot \rangle for a unique uu; conjugating, ⟨Tv,w⟩=⟨v,u⟩\langle Tv, w \rangle = \langle v, u \rangle, and we set T∗w=uT^* w = u.) In an orthonormal basis, the matrix of T∗T^* is the conjugate transpose A‾T\overline{A}^{\mathsf T} of the matrix AA of TT. The operator TT is self-adjoint if T∗=TT^* = T (a symmetric matrix AT=AA^{\mathsf T} = A over R\R, a Hermitian matrix A‾T=A\overline{A}^{\mathsf T} = A over C\C), normal if TT∗=T∗TTT^* = T^*T, and unitary (orthogonal over R\R) if T∗T=IT^*T = I.

Definition— minimal polynomial

The minimal polynomial mTm_T of TT is the monic polynomial of least degree with mT(T)=0m_T(T) = 0. (It exists because I,T,T2,…,Tn2I, T, T^2, \dots, T^{n^2} are n2+1n^2 + 1 vectors in the n2n^2-dimensional space of operators, hence dependent.) The characteristic polynomial is χT(x)=det⁡(xI−T)\chi_T(x) = \det(xI - T).

Definition— generalised eigenspace, Jordan block

For an eigenvalue λ\lambda of TT on an nn-dimensional space, the generalised eigenspace is Gλ=ker⁡(T−λI)nG_\lambda = \ker (T - \lambda I)^n. The Jordan block Jm(λ)J_m(\lambda) is the m×mm \times m matrix with λ\lambda on the diagonal, 11 directly above the diagonal and 00 elsewhere:

J3(λ)=(λ100λ100λ).J_3(\lambda) = \begin{pmatrix} \lambda & 1 & 0 \\ 0 & \lambda & 1 \\ 0 & 0 & \lambda \end{pmatrix}.

A matrix is in Jordan normal form if it is block diagonal with Jordan blocks on the diagonal. An operator NN is nilpotent if Nr=0N^r = 0 for some rr.

Definition— dual space, dual basis, dual map

The dual space of VV is V∗=Hom(V,k)V^* = \Hom(V, k), the space of linear functionals. If e1,…,ene_1, \dots, e_n is a basis of VV, the dual basis e1∗,…,en∗e_1^*, \dots, e_n^* of V∗V^* is defined by ei∗(ej)=1e_i^*(e_j) = 1 if i=ji = j and 00 otherwise. A linear map f:V→Wf : V \to W has a dual map (transpose) f∗:W∗→V∗f^* : W^* \to V^*, f∗(φ)=φ∘ff^*(\varphi) = \varphi \circ f; note that it goes backwards. The evaluation map evV:V→V∗∗\mathrm{ev}_V : V \to V^{**} sends vv to the functional "evaluate at vv": evV(v)(φ)=φ(v)\mathrm{ev}_V(v)(\varphi) = \varphi(v).

Definition— tensor product

A map B:V×W→UB : V \times W \to U is bilinear if it is linear in each variable when the other is fixed. A tensor product of VV and WW is a vector space V⊗WV \otimes W with a bilinear map ⊗:V×W→V⊗W\otimes : V \times W \to V \otimes W, (v,w)↦v⊗w(v, w) \mapsto v \otimes w, such that every bilinear map B:V×W→UB : V \times W \to U factors uniquely as B(v,w)=φ(v⊗w)B(v, w) = \varphi(v \otimes w) for a linear map φ:V⊗W→U\varphi : V \otimes W \to U. Elements of the form v⊗wv \otimes w are called pure (or simple, or rank-one) tensors.

Worked examplesH

Examples and non-examples

Example— Principal axes of a quadratic form

The quadratic form q(x,y)=5x2+4xy+2y2q(x, y) = 5x^2 + 4xy + 2y^2 is q(x)=xTAxq(\mathbf x) = \mathbf x^{\mathsf T} A \mathbf x with the symmetric matrix A=(5222)A = \begin{pmatrix} 5 & 2 \\ 2 & 2 \end{pmatrix}. Its characteristic polynomial is λ2−7λ+6=(λ−6)(λ−1)\lambda^2 - 7\lambda + 6 = (\lambda - 6)(\lambda - 1), with eigenvectors (2,1)(2, 1) for 66 and (1,−2)(1, -2) for 11 — orthogonal, as the spectral theorem promises. With the orthonormal coordinates u=(2x+y)/5u = (2x + y)/\sqrt5 and v=(x−2y)/5v = (x - 2y)/\sqrt5,

5x2+4xy+2y2=6u2+v2,5x^2 + 4xy + 2y^2 = 6u^2 + v^2,

as one checks by expanding: 6(2x+y)2+(x−2y)2=25x2+20xy+10y26(2x + y)^2 + (x - 2y)^2 = 25x^2 + 20xy + 10y^2. So the curve q=6q = 6 is an ellipse with semi-axis 11 along (2,1)(2, 1) and semi-axis 6\sqrt6 along (1,−2)(1, -2). The cross term 4xy4xy only says that we were using the wrong axes.

The ellipse and its principal axes

A point moves along the curve as t changes: x and y are both functions of t.

  • 5x² + 4xy + 2y² = 6
  • semi-axis 1 along (2, 1)
  • semi-axis √6 along (1, −2)
  • (1.407, −1.233)
  • (−0.671, −0.335)
  • (−0.822, 1.643)

Example— Normal but not symmetric; neither normal nor diagonalisable

The rotation R=(0−110)R = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix} is orthogonal, hence normal (RRT=I=RTRRR^{\mathsf T} = I = R^{\mathsf T}R), but not symmetric. It has no real eigenvalues, so it is not diagonalisable over R\R; over C\C it has eigenvalues ±i\pm i with orthogonal eigenvectors (1,∓i)(1, \mp i) and is unitarily diagonalisable, as Theorem 6 predicts. The shear S=(1101)S = \begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix} is not normal (SST≠STSSS^{\mathsf T} \ne S^{\mathsf T}S) and not diagonalisable over any field: it is the Jordan block J2(1)J_2(1). And beware: the complex matrix (1ii−1)\begin{pmatrix} 1 & i \\ i & -1 \end{pmatrix} is symmetric but squares to 00, so it is nilpotent and not diagonalisable. Over C\C the right condition is Hermitian, not symmetric.

Example— A Jordan form, worked

Let A=(110−130002)A = \begin{pmatrix} 1 & 1 & 0 \\ -1 & 3 & 0 \\ 0 & 0 & 2 \end{pmatrix}. Then χA(x)=((x−1)(x−3)+1)(x−2)=(x−2)3\chi_A(x) = \big((x - 1)(x - 3) + 1\big)(x - 2) = (x - 2)^3, so 22 is the only eigenvalue. Put N=A−2I=(−110−110000)N = A - 2I = \begin{pmatrix} -1 & 1 & 0 \\ -1 & 1 & 0 \\ 0 & 0 & 0 \end{pmatrix}: it has rank 11, and N2=0N^2 = 0. By the rank formula of Theorem 12, the number of Jordan blocks of size at least 11 is 3−1=23 - 1 = 2, and of size at least 22 is 1−0=11 - 0 = 1. So the blocks have sizes 22 and 11:

A∼J2(2)⊕J1(2)=(210020002),mA(x)=(x−2)2≠χA(x).A \sim J_2(2) \oplus J_1(2) = \begin{pmatrix} 2 & 1 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 2 \end{pmatrix}, \qquad m_A(x) = (x - 2)^2 \ne \chi_A(x).

To find the basis: pick v=e1v = e_1 with Nv=(−1,−1,0)≠0Nv = (-1, -1, 0) \ne 0; then N(Nv)=0N(Nv) = 0. In the basis (Nv,v,e3)(Nv, v, e_3) we have A(Nv)=2 NvA(Nv) = 2\,Nv, Av=2v+NvAv = 2v + Nv and Ae3=2e3Ae_3 = 2e_3, which is the matrix above.

Example— The ODE with a repeated root

The companion matrix A=(01−12)A = \begin{pmatrix} 0 & 1 \\ -1 & 2 \end{pmatrix} of x′′−2x′+x=0x'' - 2x' + x = 0 has χA(x)=(x−1)2\chi_A(x) = (x - 1)^2 and A−I≠0A - I \neq 0, so A∼J2(1)=I+NA \sim J_2(1) = I + N with N2=0N^2 = 0. Since II and NN commute, etJ2(1)=etetN=et(I+tN)=(ettet0et)e^{tJ_2(1)} = e^t e^{tN} = e^t (I + tN) = \begin{pmatrix} e^t & t e^t \\ 0 & e^t \end{pmatrix}. The 11 above the diagonal is the t ett\,e^t.

Example— A dual basis depends on the whole basis

In V=R2V = \R^2 take the basis b1=(1,0)b_1 = (1, 0), b2=(1,1)b_2 = (1, 1). Its dual basis is b1∗(x,y)=x−yb_1^*(x, y) = x - y and b2∗(x,y)=yb_2^*(x, y) = y: check that b1∗(b1)=1b_1^*(b_1) = 1, b1∗(b2)=0b_1^*(b_2) = 0, b2∗(b1)=0b_2^*(b_1) = 0, b2∗(b2)=1b_2^*(b_2) = 1. Although b1b_1 is the standard vector e1e_1, its dual b1∗b_1^* is not the standard functional e1∗(x,y)=xe_1^*(x, y) = x. There is no such thing as "the dual of a vector" — only the dual of a basis.

Example— Tensors as matrices; a tensor that is not pure

R2⊗R3\R^2 \otimes \R^3 has basis ei⊗fje_i \otimes f_j, so it is 66-dimensional, and sending ei⊗fje_i \otimes f_j to the matrix unit EijE_{ij} identifies it with the 2×32 \times 3 matrices. Under this identification v⊗w↦v wTv \otimes w \mapsto v\,w^{\mathsf T}; for example (1,2)⊗(1,0,1)↦(101202)(1, 2) \otimes (1, 0, 1) \mapsto \begin{pmatrix} 1 & 0 & 1 \\ 2 & 0 & 2 \end{pmatrix}, a matrix of rank 11. Pure tensors are exactly the matrices of rank at most 11. Hence e1⊗e1+e2⊗e2∈R2⊗R2e_1 \otimes e_1 + e_2 \otimes e_2 \in \R^2 \otimes \R^2, which corresponds to the identity matrix of rank 22, is not a pure tensor. In the same way k[x]⊗k[y]≅k[x,y]k[x] \otimes k[y] \cong k[x, y] via xi⊗yj↦xiyjx^i \otimes y^j \mapsto x^i y^j, pure tensors are products f(x)g(y)f(x) g(y), and x+yx + y is not one: if f(x)g(y)=x+yf(x)g(y) = x + y, setting y=0y = 0 gives g(0)≠0g(0) \neq 0 and f(0)=0f(0) = 0, while setting x=0x = 0 gives f(0)≠0f(0) \neq 0.

ProofH

The spectral theorem

Let VV be a finite-dimensional real or complex inner product space and TT a self-adjoint operator on it.

Theorem— Lemma 1 (eigenvalues are real)

Every eigenvalue of a self-adjoint operator is real.

Proof

If Tv=μvTv = \mu v with v≠0v \neq 0, then μ‾⟨v,v⟩=⟨Tv,v⟩=⟨v,Tv⟩=μ⟨v,v⟩\overline{\mu}\langle v, v \rangle = \langle Tv, v \rangle = \langle v, Tv \rangle = \mu \langle v, v \rangle, and ⟨v,v⟩≠0\langle v, v \rangle \neq 0, so μ‾=μ\overline\mu = \mu.

∎

Theorem— Lemma 2 (orthogonality of eigenvectors)

Eigenvectors of a self-adjoint operator for distinct eigenvalues are orthogonal.

Proof

If Tv=avTv = av and Tw=bwTw = bw with a≠ba \neq b (both real by Lemma 1), then a⟨v,w⟩=⟨Tv,w⟩=⟨v,Tw⟩=b⟨v,w⟩a\langle v, w \rangle = \langle Tv, w \rangle = \langle v, Tw \rangle = b\langle v, w \rangle, so (a−b)⟨v,w⟩=0(a - b)\langle v, w \rangle = 0 and ⟨v,w⟩=0\langle v, w \rangle = 0.

∎

Theorem— Lemma 3 (invariant complements)

If TT is self-adjoint and T(U)⊆UT(U) \subseteq U for a subspace UU, then T(U⊥)⊆U⊥T(U^\perp) \subseteq U^\perp.

Proof

Let w∈U⊥w \in U^\perp and u∈Uu \in U. Then ⟨u,Tw⟩=⟨Tu,w⟩=0\langle u, Tw \rangle = \langle Tu, w \rangle = 0 because Tu∈UTu \in U. So Tw∈U⊥Tw \in U^\perp.

∎

Theorem— Lemma 4 (an eigenvector exists)

A self-adjoint operator on a non-zero space has an eigenvector.

Proof

Over C\C this is the fundamental theorem of algebra applied to χT\chi_T. Over R\R we give a proof that uses no complex numbers. The Rayleigh quotient q(v)=⟨Tv,v⟩q(v) = \langle Tv, v \rangle is continuous on the unit sphere S={∥v∥=1}S = \{ \|v\| = 1 \}, which is compact, so qq attains a maximum at some v0∈Sv_0 \in S. Let w⊥v0w \perp v_0 and put f(t)=q((v0+tw)/∥v0+tw∥)f(t) = q\big((v_0 + tw)/\|v_0 + tw\|\big), which has a maximum at t=0t = 0. Using ⟨Tw,v0⟩=⟨w,Tv0⟩\langle Tw, v_0 \rangle = \langle w, Tv_0 \rangle,

f(t)=⟨Tv0,v0⟩+2t⟨Tv0,w⟩+t2⟨Tw,w⟩1+t2∥w∥2,f(t) = \frac{\langle Tv_0, v_0 \rangle + 2t\langle Tv_0, w \rangle + t^2 \langle Tw, w \rangle}{1 + t^2\|w\|^2},

so 0=f′(0)=2⟨Tv0,w⟩0 = f'(0) = 2\langle Tv_0, w \rangle. Thus Tv0Tv_0 is orthogonal to every w⊥v0w \perp v_0, which means Tv0∈(v0⊥)⊥=Rv0Tv_0 \in (v_0^\perp)^\perp = \R v_0: v0v_0 is an eigenvector, with eigenvalue λmax⁡=max⁡Sq\lambda_{\max} = \max_S q.

∎

Theorem— Theorem 5 (spectral theorem)

If TT is a self-adjoint operator on a finite-dimensional real or complex inner product space VV, then VV has an orthonormal basis of eigenvectors of TT, and all eigenvalues are real. Equivalently: every real symmetric matrix is A=QΛQTA = Q\Lambda Q^{\mathsf T} with QQ orthogonal and Λ\Lambda real diagonal, and every Hermitian matrix is A=UΛU∗A = U \Lambda U^* with UU unitary and Λ\Lambda real diagonal. Conversely, a real operator with an orthonormal eigenbasis is symmetric.

Proof

Induction on n=dim⁡Vn = \dim V; the case n=0n = 0 is empty. For n≥1n \geq 1, Lemma 4 gives a unit eigenvector v1v_1, with real eigenvalue by Lemma 1. The line U=kv1U = k v_1 is TT-invariant, so by Lemma 3 so is W=U⊥W = U^\perp, which has dimension n−1n - 1. The restriction T∣WT|_W is still self-adjoint (the defining identity holds for vectors of WW), so by induction WW has an orthonormal basis v2,…,vnv_2, \dots, v_n of eigenvectors. Then v1,…,vnv_1, \dots, v_n is an orthonormal eigenbasis of VV. In matrix terms, the columns of QQ are the viv_i: QQ is orthogonal (or unitary) and Q−1AQ=ΛQ^{-1}AQ = \Lambda. Conversely, if A=QΛQTA = Q\Lambda Q^{\mathsf T} with Λ\Lambda real diagonal, then AT=QΛTQT=AA^{\mathsf T} = Q\Lambda^{\mathsf T}Q^{\mathsf T} = A.

∎

The proof of Lemma 4 gives more: λmax⁡=max⁡∥v∥=1⟨Tv,v⟩\lambda_{\max} = \max_{\|v\| = 1} \langle Tv, v \rangle, and repeating it on v1⊥v_1^\perp yields every eigenvalue as a constrained maximum (the Courant–Fischer minimax principle). For complex operators that are not self-adjoint the best possible statement is this.

Theorem— Theorem 6 (complex spectral theorem)

An operator TT on a finite-dimensional complex inner product space has an orthonormal basis of eigenvectors if and only if TT is normal.

Proof

If TT is diagonal in an orthonormal basis, so is T∗T^* (with conjugated entries), and diagonal matrices commute: TT is normal. Conversely, over C\C every operator has an upper triangular matrix in some basis u1,…,unu_1, \dots, u_n (induct, using an eigenvector and the quotient space), which says the subspaces span⁡(u1,…,uj)\operatorname{span}(u_1, \dots, u_j) are TT-invariant. Gram–Schmidt produces an orthonormal basis with the same spans, so TT is upper triangular in an orthonormal basis — this is Schur's theorem. Now suppose TT is normal with upper triangular matrix (aij)(a_{ij}) in the orthonormal basis e1,…,ene_1, \dots, e_n. For every vv, ∥Tv∥2=⟨v,T∗Tv⟩=⟨v,TT∗v⟩=∥T∗v∥2\|Tv\|^2 = \langle v, T^*Tv \rangle = \langle v, TT^*v \rangle = \|T^*v\|^2. With v=e1v = e_1: ∥Te1∥2=∣a11∣2\|Te_1\|^2 = |a_{11}|^2, while ∥T∗e1∥2=∑j∣a1j∣2\|T^* e_1\|^2 = \sum_j |a_{1j}|^2, since the first row of AA is the conjugated first column of A∗A^*. Hence a12=⋯=a1n=0a_{12} = \dots = a_{1n} = 0. Repeating with e2,e3,…e_2, e_3, \dots shows that every off-diagonal entry vanishes.

∎

ProofH

Cayley–Hamilton, minimal polynomials and the Jordan form

Theorem— Theorem 7 (Cayley–Hamilton)

For every n×nn \times n matrix AA over a commutative ring, χA(A)=0\chi_A(A) = 0.

Proof

The tempting argument "χA(A)=det⁡(AI−A)=det⁡0=0\chi_A(A) = \det(AI - A) = \det 0 = 0" is not valid: inside the determinant, xx multiplies the entries of II, so substituting a matrix for xx is meaningless. Instead, let B(x)=adj⁡(xI−A)B(x) = \operatorname{adj}(xI - A). Its entries are polynomials of degree at most n−1n - 1, so B(x)=∑k=0n−1BkxkB(x) = \sum_{k=0}^{n-1} B_k x^k with matrices BkB_k. The adjugate identity gives (xI−A)B(x)=χA(x)I(xI - A)B(x) = \chi_A(x) I. Write χA(x)=∑k=0nckxk\chi_A(x) = \sum_{k=0}^n c_k x^k and compare coefficients of xkx^k, with B−1=Bn=0B_{-1} = B_n = 0:

Bk−1−ABk=ckI(0≤k≤n).B_{k-1} - AB_k = c_k I \qquad (0 \le k \le n).

Multiply the kk-th equation on the left by AkA^k and add them up. The right-hand side is ∑kckAk=χA(A)\sum_k c_k A^k = \chi_A(A); the left-hand side ∑k(AkBk−1−Ak+1Bk)\sum_k (A^k B_{k-1} - A^{k+1}B_k) telescopes to A0B−1−An+1Bn=0A^0B_{-1} - A^{n+1}B_n = 0.

∎

Theorem— Proposition 8 (minimal polynomial)

If p(T)=0p(T) = 0 then mTm_T divides pp; in particular mT∣χTm_T \mid \chi_T. The roots of mTm_T are exactly the eigenvalues of TT.

Proof

Divide: p=q mT+rp = q\,m_T + r with deg⁡r<deg⁡mT\deg r < \deg m_T. Then r(T)=p(T)−q(T)mT(T)=0r(T) = p(T) - q(T)m_T(T) = 0, so r=0r = 0 by minimality. If Tv=λvTv = \lambda v with v≠0v \ne 0 then 0=mT(T)v=mT(λ)v0 = m_T(T)v = m_T(\lambda)v, so mT(λ)=0m_T(\lambda) = 0. Conversely, if mT(λ)=0m_T(\lambda) = 0 write mT=(x−λ)qm_T = (x - \lambda)q; since deg⁡q<deg⁡mT\deg q < \deg m_T there is ww with v=q(T)w≠0v = q(T)w \ne 0, and (T−λ)v=mT(T)w=0(T - \lambda)v = m_T(T)w = 0.

∎

Theorem— Lemma 9 (kernel lemma)

If p=p1p2p = p_1 p_2 with gcd⁡(p1,p2)=1\gcd(p_1, p_2) = 1 and p(T)=0p(T) = 0, then V=ker⁡p1(T)⊕ker⁡p2(T)V = \ker p_1(T) \oplus \ker p_2(T), and both summands are TT-invariant.

Proof

By Bézout there are polynomials a,ba, b with ap1+bp2=1a p_1 + b p_2 = 1, so v=a(T)p1(T)v+b(T)p2(T)vv = a(T)p_1(T)v + b(T)p_2(T)v for every vv. The first term lies in ker⁡p2(T)\ker p_2(T) because p2(T)a(T)p1(T)v=a(T)p(T)v=0p_2(T)a(T)p_1(T)v = a(T)p(T)v = 0, and likewise the second lies in ker⁡p1(T)\ker p_1(T). If vv is in both kernels, the same identity gives v=0v = 0. Invariance holds because TT commutes with pi(T)p_i(T).

∎

Theorem— Theorem 10 (diagonalisability)

TT is diagonalisable if and only if mTm_T is a product of distinct linear factors.

Proof

If TT is diagonal with distinct eigenvalues λ1,…,λr\lambda_1, \dots, \lambda_r, then ∏(T−λi)\prod (T - \lambda_i) kills every basis vector, so mTm_T divides ∏(x−λi)\prod(x - \lambda_i). Conversely, if mT=∏i=1r(x−λi)m_T = \prod_{i=1}^r (x - \lambda_i) with distinct λi\lambda_i, repeated use of Lemma 9 gives V=⨁iker⁡(T−λi)V = \bigoplus_i \ker(T - \lambda_i), a direct sum of eigenspaces.

∎

Applied to χT=∏λ(x−λ)aλ\chi_T = \prod_\lambda (x - \lambda)^{a_\lambda} over an algebraically closed field, Lemma 9 and Cayley–Hamilton split VV into the generalised eigenspaces, V=⨁λker⁡(T−λ)aλ=⨁λGλV = \bigoplus_\lambda \ker(T - \lambda)^{a_\lambda} = \bigoplus_\lambda G_\lambda, and on GλG_\lambda the operator T−λT - \lambda is nilpotent. So everything reduces to nilpotent operators.

Theorem— Theorem 11 (structure of nilpotent operators)

If NN is nilpotent on VV, there are vectors v1,…,vmv_1, \dots, v_m and integers k1,…,km≥1k_1, \dots, k_m \geq 1 such that the vectors NjviN^j v_i (1≤i≤m1 \le i \le m, 0≤j<ki0 \le j < k_i) form a basis of VV and Nkivi=0N^{k_i} v_i = 0. In this basis (each chain listed as Nki−1vi,…,Nvi,viN^{k_i - 1}v_i, \dots, Nv_i, v_i) the matrix of NN is Jk1(0)⊕⋯⊕Jkm(0)J_{k_1}(0) \oplus \dots \oplus J_{k_m}(0).

Proof

Induction on dim⁡V\dim V. If N=0N = 0, any basis works with all ki=1k_i = 1. Otherwise U=N(V)U = N(V) is a proper subspace (a nilpotent operator is not surjective) that NN maps into itself, so by induction UU has a basis NjuiN^j u_i (0≤j<ki0 \le j < k_i) with Nkiui=0N^{k_i} u_i = 0. Choose viv_i with Nvi=uiNv_i = u_i, and let SS be the list of vectors NjviN^j v_i for 0≤j≤ki0 \le j \le k_i (one longer chain each).

SS is independent. Suppose ∑i,jaijNjvi=0\sum_{i,j} a_{ij} N^j v_i = 0. Applying NN gives ∑i,j<kiaijNjui=0\sum_{i, j < k_i} a_{ij} N^j u_i = 0 (the terms with j=kij = k_i die), so aij=0a_{ij} = 0 for j<kij < k_i. What is left is ∑iaikiNki−1ui=0\sum_i a_{ik_i} N^{k_i - 1} u_i = 0, again a sub-list of a basis, so all aiki=0a_{ik_i} = 0.

Extending. Extend SS to a basis of VV by vectors w1,…,wpw_1, \dots, w_p. Each NwlNw_l lies in UU, which is spanned by NN applied to vectors of SS, so Nwl=NxlNw_l = Nx_l with xl∈span⁡Sx_l \in \operatorname{span} S. Replace wlw_l by wl−xlw_l - x_l: we still have a basis, and now N(wl−xl)=0N(w_l - x_l) = 0, so each wl−xlw_l - x_l is a chain of length 11.

∎

Theorem— Theorem 12 (Jordan normal form)

Let TT be an operator on a finite-dimensional vector space over an algebraically closed field (such as C\C). Then TT has a matrix in Jordan normal form, and this form is unique up to the order of the blocks. Precisely, for each eigenvalue λ\lambda and k≥1k \geq 1,

#{blocks Jm(λ) with m≥k}=rank⁡(T−λ)k−1−rank⁡(T−λ)k.\#\{\text{blocks } J_m(\lambda) \text{ with } m \ge k\} = \operatorname{rank}(T - \lambda)^{k-1} - \operatorname{rank}(T - \lambda)^k.

Proof

Existence. Decompose V=⨁λGλV = \bigoplus_\lambda G_\lambda as above, apply Theorem 11 to the nilpotent operator T−λT - \lambda on each GλG_\lambda, and add λI\lambda I: a nilpotent Jordan block becomes Jm(λ)J_m(\lambda).

Uniqueness. For a single block, rank⁡Jm(0)j=max⁡(m−j,0)\operatorname{rank} J_m(0)^j = \max(m - j, 0): each power shifts the chain by one more step. For μ≠λ\mu \ne \lambda the block Jm(μ)−λIJ_m(\mu) - \lambda I is invertible, so its powers keep full rank mm. Adding over blocks, rank⁡(T−λ)k−1−rank⁡(T−λ)k\operatorname{rank}(T - \lambda)^{k-1} - \operatorname{rank}(T - \lambda)^k counts the blocks for λ\lambda whose rank still drops at step kk, that is, those of size at least kk. These numbers depend only on TT, not on the basis, so they determine the multiset of blocks.

∎

So the minimal polynomial is ∏λ(x−λ)sλ\prod_\lambda (x - \lambda)^{s_\lambda} with sλs_\lambda the size of the largest block for λ\lambda, while the characteristic polynomial records the total size aλa_\lambda, and the number of blocks for λ\lambda is dim⁡ker⁡(T−λ)\dim \ker(T - \lambda), the geometric multiplicity. Over a field that is not algebraically closed (such as Q\Q or R\R) the same theory, phrased with irreducible polynomials, gives the rational canonical form: every operator is similar to a block diagonal matrix of companion matrices of polynomials d1∣d2∣⋯∣drd_1 \mid d_2 \mid \dots \mid d_r (the invariant factors, with dr=mTd_r = m_T and d1⋯dr=χTd_1 \cdots d_r = \chi_T), uniquely. We state it without proof: it is the structure theorem for finitely generated modules over the principal ideal domain k[x]k[x] (see the algebra viewpoint below).

ProofH

Dual spaces: natural and unnatural isomorphisms

Theorem— Theorem 13 (dual basis)

If e1,…,ene_1, \dots, e_n is a basis of VV, then e1∗,…,en∗e_1^*, \dots, e_n^* is a basis of V∗V^*; so dim⁡V∗=dim⁡V\dim V^* = \dim V. Every φ∈V∗\varphi \in V^* is φ=∑iφ(ei) ei∗\varphi = \sum_i \varphi(e_i)\,e_i^*. If VV has an inner product, every φ∈V∗\varphi \in V^* is φ=⟨u,⋅⟩\varphi = \langle u, \cdot \rangle for a unique u∈Vu \in V (the Riesz representation).

Proof

Both sides of φ=∑iφ(ei)ei∗\varphi = \sum_i \varphi(e_i) e_i^* are linear and agree on each eje_j, so they are equal; this shows the ei∗e_i^* span. If ∑iciei∗=0\sum_i c_i e_i^* = 0, evaluating at eje_j gives cj=0c_j = 0. For the Riesz statement, take an orthonormal basis and u=∑iφ(ei)‾ eiu = \sum_i \overline{\varphi(e_i)}\,e_i; then ⟨u,ej⟩=φ(ej)\langle u, e_j \rangle = \varphi(e_j) for all jj. Uniqueness: if ⟨u−u′,⋅⟩=0\langle u - u', \cdot \rangle = 0, take the argument to be u−u′u - u'.

∎

So V≅V∗V \cong V^* for finite-dimensional VV — but every isomorphism we can write down uses a basis or an inner product. The double dual is different.

Theorem— Theorem 14 (the double dual)

The evaluation map evV:V→V∗∗\mathrm{ev}_V : V \to V^{**} is linear and injective, hence an isomorphism when VV is finite-dimensional. It is natural: for every linear map f:V→Wf : V \to W, f∗∗∘evV=evW∘ff^{**} \circ \mathrm{ev}_V = \mathrm{ev}_W \circ f.

Proof

Linearity is clear. If v≠0v \neq 0, extend vv to a basis v=e1,e2,…v = e_1, e_2, \dots; then e1∗(v)=1e_1^*(v) = 1, so evV(v)≠0\mathrm{ev}_V(v) \neq 0. Since dim⁡V∗∗=dim⁡V∗=dim⁡V\dim V^{**} = \dim V^* = \dim V, an injective linear map V→V∗∗V \to V^{**} is bijective. Naturality: for φ∈W∗\varphi \in W^*, (f∗∗(evVv))(φ)=evV(v)(f∗φ)=(φ∘f)(v)=evW(fv)(φ)\big(f^{**}(\mathrm{ev}_V v)\big)(\varphi) = \mathrm{ev}_V(v)(f^* \varphi) = (\varphi \circ f)(v) = \mathrm{ev}_W(f v)(\varphi).

∎

VV
V∗∗V^{**}
WW
W∗∗W^{**}
evV\mathrm{ev}_V
ff
f∗∗f^{**}
evW\mathrm{ev}_W
Naturality of the double dual: the square commutes for every linear map ff, and no basis was chosen.

Theorem— Proposition 15 (no natural isomorphism with the dual)

Let kk be a field with more than three elements. There is no family of isomorphisms ηV:V→V∗\eta_V : V \to V^*, one for each finite-dimensional VV, such that ηV=f∗∘ηW∘f\eta_V = f^* \circ \eta_W \circ f for every isomorphism f:V→Wf : V \to W.

Proof

The condition is the only sensible notion of naturality here: V∗V^* depends contravariantly on VV, so ff must be used on both sides. Take V=W=kV = W = k and f=c⋅idf = c \cdot \mathrm{id} with c2≠1c^2 \neq 1, which exists since x2=1x^2 = 1 has at most two roots and kk has more than three elements. Then f∗=c⋅idf^* = c \cdot \mathrm{id} as well, so the condition reads ηk=c2ηk\eta_k = c^2 \eta_k, forcing ηk=0\eta_k = 0, which is not an isomorphism.

∎

The same conclusion holds over every field, using V=k3V = k^3 instead of kk: the condition says that the bilinear form b(v,w)=η(v)(w)b(v, w) = \eta(v)(w) satisfies b(Av,Aw)=b(v,w)b(Av, Aw) = b(v, w) for all A∈GL3(k)A \in GL_3(k). Since GL3(k)GL_3(k) moves any pair of independent vectors to any other, b(u,v)=cb(u, v) = c for all independent u,vu, v and b(v,v)=db(v, v) = d for all v≠0v \ne 0; then c=b(u,v+w)=2cc = b(u, v + w) = 2c and c=b(v,v+w)=d+cc = b(v, v + w) = d + c (for independent u,v,wu, v, w) force c=d=0c = d = 0, so b=0b = 0. An inner product does give an isomorphism V→V∗V \to V^*, u↦⟨u,⋅⟩u \mapsto \langle u, \cdot \rangle (Theorem 13), natural with respect to the maps that preserve the inner product — this is the physicists' "raising and lowering of indices". In infinite dimensions V≇V∗V \not\cong V^* in general: V=k[x]V = k[x] has countable dimension, V∗V^* can be identified with the power series k[[x]]k[[x]], and when kk is countable V∗V^* has uncountable dimension (a theorem of Erdős and Kaplansky), so evV\mathrm{ev}_V is injective but not surjective.

ProofH

Tensor products and multilinear algebra

Theorem— Theorem 16 (existence, uniqueness and dimension)

The tensor product V⊗WV \otimes W exists and is unique up to a unique isomorphism compatible with ⊗\otimes. If (ei)(e_i) is a basis of VV and (fj)(f_j) a basis of WW, then (ei⊗fj)(e_i \otimes f_j) is a basis of V⊗WV \otimes W; in particular dim⁡(V⊗W)=dim⁡V⋅dim⁡W\dim(V \otimes W) = \dim V \cdot \dim W.

Proof

Existence. Let TT be the vector space with basis symbols tijt_{ij} and define v⊗w=∑i,jaibjtijv \otimes w = \sum_{i,j} a_i b_j t_{ij} for v=∑aieiv = \sum a_i e_i, w=∑bjfjw = \sum b_j f_j; this is bilinear. Given a bilinear BB, a linear φ\varphi with φ(v⊗w)=B(v,w)\varphi(v \otimes w) = B(v, w) must satisfy φ(tij)=φ(ei⊗fj)=B(ei,fj)\varphi(t_{ij}) = \varphi(e_i \otimes f_j) = B(e_i, f_j), which determines φ\varphi on a basis; conversely this φ\varphi works, by bilinearity of BB. So TT is a tensor product and ei⊗fj=tije_i \otimes f_j = t_{ij} is a basis.

Uniqueness. If (P,⊗)(P, \otimes) and (P′,⊗′)(P', \otimes') both have the universal property, the bilinear map ⊗′\otimes' factors as α∘⊗\alpha \circ \otimes and ⊗\otimes as β∘⊗′\beta \circ \otimes'. Then βα∘⊗=⊗=id∘⊗\beta\alpha \circ \otimes = \otimes = \mathrm{id} \circ \otimes, and uniqueness in the universal property gives βα=id\beta \alpha = \mathrm{id}; likewise αβ=id\alpha \beta = \mathrm{id}.

∎

Theorem— Proposition 17 (tensors as linear maps)

For finite-dimensional V,WV, W the linear map V∗⊗W→Hom(V,W)V^* \otimes W \to \Hom(V, W) induced by (φ,w)↦(v↦φ(v) w)(\varphi, w) \mapsto (v \mapsto \varphi(v)\,w) is an isomorphism. A tensor is pure exactly when the corresponding map has rank at most 11, and every tensor tt is a sum of rr pure tensors, where r=rank⁡r = \operatorname{rank} of the corresponding map, and no fewer.

Proof

The map sends the basis ei∗⊗fje_i^* \otimes f_j to the map ei↦fje_i \mapsto f_j, other basis vectors ↦0\mapsto 0 — the matrix unit EjiE_{ji} — so it sends a basis to a basis. A pure tensor φ⊗w\varphi \otimes w goes to v↦φ(v)wv \mapsto \varphi(v)w, whose image lies in the line through ww. A map of rank rr is a sum of rr maps of rank 11 (choose a basis w1,…,wrw_1, \dots, w_r of its image and write it as v↦∑lφl(v)wlv \mapsto \sum_l \varphi_l(v)w_l), and a sum of fewer than rr rank-one maps has rank less than rr.

∎

Multilinear algebra and the determinant. Tensor powers V⊗p⊗(V∗)⊗qV^{\otimes p} \otimes (V^*)^{\otimes q} hold the objects of physics and geometry (vectors, covectors, bilinear forms, stress and curvature tensors), and dividing out by symmetries gives the symmetric powers SpVS^pV (polynomials) and the exterior powers ΛpV\Lambda^p V. Their most famous use is a coordinate-free determinant: if dim⁡V=n\dim V = n, the alternating nn-linear forms on VV form a one-dimensional space (such a form is fixed by its value on a basis, since expanding ω(∑ai1ei,… )\omega(\sum a_{i1}e_i, \dots) by multilinearity kills repeated vectors and turns permutations into signs, and the Leibniz formula gives a non-zero one). So for any non-zero alternating form ω\omega there is a unique scalar det⁡T\det T with ω(Tv1,…,Tvn)=det⁡T⋅ω(v1,…,vn)\omega(Tv_1, \dots, Tv_n) = \det T \cdot \omega(v_1, \dots, v_n), independent of ω\omega. Then det⁡(ST)=det⁡Sdet⁡T\det(ST) = \det S \det T is immediate: apply the definition twice.

Formal mathematicsF

The theorems in Lean and Mathlib

Mathlib's InnerProductSpace 𝕜 E works over 𝕜 = ℝ or ℂ at once (the class RCLike), and T.IsSymmetric means ⟨Tx,y⟩=⟨x,Ty⟩\langle Tx, y \rangle = \langle x, Ty \rangle. As in the lesson, the inner product is conjugate-linear in the first slot. Lemmas 1 and 2, proved here exactly as above:

eigenvalue_realLean 4Proved here from basic factsFormally verified
/-- **Eigenvalues of a self-adjoint operator are real.** If `T v = μ v` with `v ≠ 0`, then
`conj μ ⟪v, v⟫ = ⟪T v, v⟫ = ⟪v, T v⟫ = μ ⟪v, v⟫`, and `⟪v, v⟫ ≠ 0` can be cancelled. (Mathlib's
inner product is conjugate-linear in the *first* slot, hence the `conj` on the left.) This is
Lemma 1 of the lesson; Mathlib's version is `LinearMap.IsSymmetric.conj_eigenvalue_eq_self`. -/
theorem eigenvalue_real {𝕜 E : Type*} [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
    {T : E →ₗ[𝕜] E} (hT : T.IsSymmetric) {μ : 𝕜} {v : E} (hv0 : v ≠ 0) (hv : T v = μ • v) :
    starRingEnd 𝕜 μ = μ := by
  have h : starRingEnd 𝕜 μ * inner 𝕜 v v = μ * inner 𝕜 v v :=
    calc starRingEnd 𝕜 μ * inner 𝕜 v v = inner 𝕜 (T v) v := by rw [hv, inner_smul_left]
      _ = inner 𝕜 v (T v) := hT v v
      _ = μ * inner 𝕜 v v := by rw [hv, inner_smul_right]
  exact mul_right_cancel₀ (inner_self_ne_zero.mpr hv0) h
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor
eigenvectors_orthogonalLean 4Proved here from basic factsFormally verified
/-- **Eigenvectors of a symmetric operator for distinct eigenvalues are orthogonal.** The proof
is Lemma 2 of the lesson: `a ⟪v, w⟫ = ⟪T v, w⟫ = ⟪v, T w⟫ = b ⟪v, w⟫`, so `(a - b) ⟪v, w⟫ = 0`
and `a ≠ b` forces `⟪v, w⟫ = 0`. -/
theorem eigenvectors_orthogonal {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
    {T : E →ₗ[ℝ] E} (hT : T.IsSymmetric) {a b : ℝ} {v w : E}
    (hv : T v = a • v) (hw : T w = b • w) (hab : a ≠ b) : inner ℝ v w = 0 := by
  have h : a * inner ℝ v w = b * inner ℝ v w :=
    calc a * inner ℝ v w = inner ℝ (T v) w := by rw [hv, real_inner_smul_left]
      _ = inner ℝ v (T w) := hT v w
      _ = b * inner ℝ v w := by rw [hw, real_inner_smul_right]
  have h2 : (a - b) * inner ℝ v w = 0 := by rw [sub_mul, h, sub_self]
  exact (mul_eq_zero.mp h2).resolve_left (sub_ne_zero.mpr hab)
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor

The spectral theorem (Theorem 5) and its matrix form are in Mathlib. Its proof shows that the eigenspaces are orthogonal and together span EE — a variant of the induction above:

spectral_theoremLean 4Applies a library theoremFormally verified
/-- **The spectral theorem.** A self-adjoint operator `T` on a finite-dimensional real or complex
inner product space of dimension `n` has an orthonormal basis `b` of eigenvectors, with *real*
eigenvalues `μ i`. This packages Mathlib's `LinearMap.IsSymmetric.eigenvectorBasis`,
`eigenvalues` and `apply_eigenvectorBasis`; Mathlib's proof is the lesson's (eigenspaces are
orthogonal and together span `E`). -/
theorem spectral_theorem {𝕜 E : Type*} [RCLike 𝕜] [NormedAddCommGroup E] [InnerProductSpace 𝕜 E]
    [FiniteDimensional 𝕜 E] {n : ℕ} (hn : finrank 𝕜 E = n) {T : E →ₗ[𝕜] E}
    (hT : T.IsSymmetric) :
    ∃ (b : OrthonormalBasis (Fin n) 𝕜 E) (μ : Fin n → ℝ), ∀ i, T (b i) = (μ i : 𝕜) • b i :=
  ⟨hT.eigenvectorBasis hn, hT.eigenvalues hn, hT.apply_eigenvectorBasis hn⟩
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor
symmetric_matrix_eigenbasisLean 4Applies a library theoremFormally verified
/-- **Real symmetric matrices are orthogonally diagonalisable.** For a real matrix with `Aᵀ = A`
there is an orthonormal basis of `ℝⁿ` (the columns of an orthogonal matrix `Q`) consisting of
eigenvectors of `A`; equivalently `A = Q Λ Qᵀ`. Over `ℝ` the conjugate transpose is the
transpose, so `A` is Hermitian, and Mathlib's `Matrix.IsHermitian.mulVec_eigenvectorBasis`
applies. -/
theorem symmetric_matrix_eigenbasis {n : Type*} [Fintype n] [DecidableEq n]
    (A : Matrix n n ℝ) (hA : Aᵀ = A) :
    ∃ (b : OrthonormalBasis n ℝ (EuclideanSpace ℝ n)) (μ : n → ℝ),
      ∀ j, A.mulVec (b j) = μ j • (b j : n → ℝ) := by
  have hH : A.IsHermitian := by
    rw [Matrix.IsHermitian, Matrix.conjTranspose_eq_transpose_of_trivial]
    exact hA
  exact ⟨hH.eigenvectorBasis, hH.eigenvalues, hH.mulVec_eigenvectorBasis⟩
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor

Why the hypothesis over C\C must be Hermitian, not merely symmetric:

complex_symmetric_nilpotentLean 4Proved here from basic factsFormally verified
/-- **"Symmetric" is not enough over `ℂ`.** The complex symmetric matrix with rows `(1, i)` and
`(i, -1)` is non-zero but squares to zero, so it is nilpotent and not diagonalisable. Over `ℂ` the
spectral theorem needs *Hermitian* (`A* = A`), not symmetric (`Aᵀ = A`). -/
theorem complex_symmetric_nilpotent :
    let A : Matrix (Fin 2) (Fin 2) ℂ := !![1, Complex.I; Complex.I, -1]
    Aᵀ = A ∧ A ≠ 0 ∧ A * A = 0 := by
  intro A
  refine ⟨?_, ?_, ?_⟩
  · ext i j
    fin_cases i <;> fin_cases j <;> simp [A]
  · intro h
    have := congrFun (congrFun h 0) 0
    simp [A] at this
  · ext i j
    fin_cases i <;> fin_cases j <;> simp [A, Matrix.mul_apply, Fin.sum_univ_two]
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor

Cayley–Hamilton: a direct computation for 2×22 \times 2 matrices, and the general theorem from Mathlib, proved there with the adjugate as in Theorem 7.

cayley_hamilton_twoLean 4Proved here from basic factsFormally verified
/-- **Cayley–Hamilton for 2 × 2 matrices**, by direct computation over any commutative ring:
`A² − (tr A) A + (det A) I = 0`. The characteristic polynomial of `A` is
`x² − (tr A) x + det A`, so this says `χ_A(A) = 0`. -/
theorem cayley_hamilton_two {R : Type*} [CommRing R] (A : Matrix (Fin 2) (Fin 2) R) :
    A * A - A.trace • A + A.det • (1 : Matrix (Fin 2) (Fin 2) R) = 0 := by
  ext i j
  fin_cases i <;> fin_cases j <;>
    simp [Matrix.mul_apply, Fin.sum_univ_two, Matrix.trace_fin_two, Matrix.det_fin_two] <;> ring
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor
cayley_hamiltonLean 4Applies a library theoremFormally verified
/-- **The Cayley–Hamilton theorem**: every square matrix over a commutative ring is a root of its
characteristic polynomial, `χ_A(A) = 0`. This is Mathlib's `Matrix.aeval_self_charpoly`, proved
(like the lesson) with the adjugate identity `(x I − A) · adj(x I − A) = χ_A(x) I`. -/
theorem cayley_hamilton {R : Type*} [CommRing R] {n : Type*} [Fintype n] [DecidableEq n]
    (A : Matrix n n R) : Polynomial.aeval A A.charpoly = 0 :=
  Matrix.aeval_self_charpoly A
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor

A Jordan block and its minimal polynomial: N=J3(μ)−μIN = J_3(\mu) - \mu I satisfies N3=0N^3 = 0 but N2≠0N^2 \ne 0, so m=(x−μ)3m = (x - \mu)^3.

jordanBlock3Lean 4Formally verified
/-- The 3 × 3 **Jordan block** `J₃(μ)`: `μ` on the diagonal, `1` just above it. -/
def jordanBlock3 {K : Type*} [Field K] (μ : K) : Matrix (Fin 3) (Fin 3) K :=
  !![μ, 1, 0; 0, μ, 1; 0, 0, μ]
Axioms used: propext, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor
jordan_block3_nilpotentLean 4Proved here from basic factsFormally verified
/-- `N = J₃(μ) − μ I` is nilpotent: `N³ = 0`. So `(x − μ)³` annihilates `J₃(μ)`. -/
theorem jordan_block3_nilpotent {K : Type*} [Field K] (μ : K) :
    (jordanBlock3 μ - μ • (1 : Matrix (Fin 3) (Fin 3) K)) ^ 3 = 0 := by
  ext i j
  fin_cases i <;> fin_cases j <;> simp [jordanBlock3, pow_succ, Matrix.mul_apply, Fin.sum_univ_three]
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor
jordan_block3_sq_ne_zeroLean 4Proved here from basic factsFormally verified
/-- …but `N² ≠ 0` (its top-right entry is `1`). Together with `N³ = 0` this shows that the
minimal polynomial of `J₃(μ)` is `(x − μ)³`, equal to the characteristic polynomial: no
polynomial of smaller degree kills it, so it is not diagonalisable. -/
theorem jordan_block3_sq_ne_zero {K : Type*} [Field K] (μ : K) :
    (jordanBlock3 μ - μ • (1 : Matrix (Fin 3) (Fin 3) K)) ^ 2 ≠ 0 := by
  intro h
  have h02 := congrFun (congrFun h 0) 2
  simp [jordanBlock3, pow_succ, Matrix.mul_apply, Fin.sum_univ_three] at h02
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor

The first half of the Jordan normal form theorem, the decomposition into generalised eigenspaces:

generalized_eigenspace_decompositionLean 4Applies a library theoremFormally verified
/-- **The generalised eigenspace (primary) decomposition**, the first half of the Jordan normal
form theorem: over an algebraically closed field, the generalised eigenspaces
`ker (f − μ)^∞` of an operator on a finite-dimensional space are independent and together span
the space, so `V` is their direct sum. Mathlib: `Module.End.independent_maxGenEigenspace` and
`Module.End.iSup_maxGenEigenspace_eq_top` (the latter following Axler's proof). -/
theorem generalized_eigenspace_decomposition {K V : Type*} [Field K] [IsAlgClosed K]
    [AddCommGroup V] [Module K V] [FiniteDimensional K V] (f : End K V) :
    iSupIndep f.maxGenEigenspace ∧ ⨆ μ : K, f.maxGenEigenspace μ = ⊤ :=
  ⟨f.independent_maxGenEigenspace, f.iSup_maxGenEigenspace_eq_top⟩
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor

Duality. Naturality of V→V∗∗V \to V^{**} is true by definition — Lean accepts rfl — which is a precise sense in which no choice was made. The isomorphism itself, and dim⁡V∗=dim⁡V\dim V^* = \dim V, come from Mathlib:

eval_naturalLean 4Proved here from basic factsFormally verified
/-- **`V → V**` is natural.** For every linear map `f : V → W`, the square
`V → V** → W**` equals `V → W → W**`: evaluating at `v` and then transporting along `f**` is the
same as evaluating at `f v`. No basis appears anywhere — the proof is a definitional unfolding
(`rfl`), which is exactly what "natural" means in practice. -/
theorem eval_natural {K V W : Type*} [Field K] [AddCommGroup V] [Module K V]
    [AddCommGroup W] [Module K W] (f : V →ₗ[K] W) :
    f.dualMap.dualMap ∘ₗ Dual.eval K V = Dual.eval K W ∘ₗ f := by
  ext v φ
  rfl
Axioms used: propext, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor
eval_bijectiveLean 4Applies a library theoremFormally verified
/-- **`V ≅ V**` in finite dimensions**: the evaluation map is bijective (Mathlib's
`Module.bijective_dual_eval`, using that finite-dimensional spaces are reflexive). -/
theorem eval_bijective {K V : Type*} [Field K] [AddCommGroup V] [Module K V]
    [FiniteDimensional K V] : Function.Bijective (Dual.eval K V) :=
  bijective_dual_eval K V
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor
dual_finrankLean 4Applies a library theoremFormally verified
/-- `dim V* = dim V` for finite-dimensional `V` (Mathlib's `Subspace.dual_finrank_eq`, proved
with the dual basis). So `V ≅ V*` — but only through a choice, as the lesson explains. -/
theorem dual_finrank {K V : Type*} [Field K] [AddCommGroup V] [Module K V]
    [FiniteDimensional K V] : finrank K (Dual K V) = finrank K V :=
  Subspace.dual_finrank_eq
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor

Tensor products. Mathlib defines V⊗WV \otimes W by a quotient construction and proves its universal property; existence and uniqueness of the factorisation are TensorProduct.lift and TensorProduct.ext':

tensor_universalLean 4Applies a library theoremFormally verified
/-- **The universal property of `V ⊗ W`.** Every bilinear map `B : V × W → U` factors through
`(v, w) ↦ v ⊗ w` by exactly one linear map `φ : V ⊗ W → U`. Existence is
`TensorProduct.lift`; uniqueness is `TensorProduct.ext'` (linear maps that agree on pure tensors
agree everywhere, because pure tensors span). -/
theorem tensor_universal {K V W U : Type*} [Field K] [AddCommGroup V] [Module K V]
    [AddCommGroup W] [Module K W] [AddCommGroup U] [Module K U] (B : V →ₗ[K] W →ₗ[K] U) :
    ∃! φ : TensorProduct K V W →ₗ[K] U, ∀ v w, φ (v ⊗ₜ w) = B v w := by
  refine ⟨TensorProduct.lift B, fun v w => TensorProduct.lift.tmul v w, ?_⟩
  intro ψ hψ
  exact TensorProduct.ext' fun v w => by rw [hψ, TensorProduct.lift.tmul]
Axioms used: propext, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor
finrank_tensorLean 4Applies a library theoremFormally verified
/-- `dim (V ⊗ W) = dim V · dim W` (Mathlib's `Module.finrank_tensorProduct`, from the basis
`eᵢ ⊗ fⱼ`). Compare `dim (V × W) = dim V + dim W`. -/
theorem finrank_tensor {K V W : Type*} [Field K] [AddCommGroup V] [Module K V]
    [AddCommGroup W] [Module K W] [FiniteDimensional K V] [FiniteDimensional K W] :
    finrank K (TensorProduct K V W) = finrank K V * finrank K W :=
  Module.finrank_tensorProduct
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor

Finally, the misconception "every tensor is pure", refuted with coordinate functionals built from the universal property:

coordLean 4Formally verified
/-- The `(i, j)` **coordinate** of a tensor in `K² ⊗ K²`: the linear map induced, through the
universal property, by the bilinear map `(v, w) ↦ vᵢ wⱼ`. On a pure tensor it gives the entries
of the "outer product" matrix `v wᵀ`. -/
noncomputable def coord {K : Type*} [Field K] (i j : Fin 2) :
    TensorProduct K (Fin 2 → K) (Fin 2 → K) →ₗ[K] K :=
  TensorProduct.lift (LinearMap.mk₂ K (fun v w => v i * w j)
    (fun _ _ _ => by simp [add_mul]) (fun _ _ _ => by simp [mul_assoc])
    (fun _ _ _ => by simp [mul_add]) (fun _ _ _ => by simp [mul_left_comm]))
Axioms used: propext, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor
not_pure_tensorLean 4Proved here from basic factsFormally verified
/-- **Not every tensor is pure.** `e₁ ⊗ e₁ + e₂ ⊗ e₂` is not of the form `v ⊗ w`. Taking
coordinates: a pure tensor has coordinates `vᵢ wⱼ`, so we would need `v₁ w₁ = 1`, `v₂ w₂ = 1`
and `v₁ w₂ = 0` — impossible, since the last forces `v₁ = 0` or `w₂ = 0`. In matrix language:
the identity matrix has rank 2, while `v wᵀ` has rank at most 1. -/
theorem not_pure_tensor {K : Type*} [Field K] :
    ¬ ∃ v w : Fin 2 → K, v ⊗ₜ[K] w =
      (Pi.single 0 1 : Fin 2 → K) ⊗ₜ Pi.single 0 1 + Pi.single 1 1 ⊗ₜ Pi.single 1 1 := by
  rintro ⟨v, w, h⟩
  have c00 := congrArg (coord (K := K) 0 0) h
  have c11 := congrArg (coord (K := K) 1 1) h
  have c01 := congrArg (coord (K := K) 0 1) h
  simp [coord] at c00 c11 c01
  rcases c01 with h0 | h1
  · simp [h0] at c00
  · simp [h1] at c11
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/AdvancedLinearAlgebra.leanTry it in the Lean web editor

What is and is not formalised. Independent: Lemmas 1 and 2, the complex symmetric counterexample, Cayley–Hamilton for 2×22 \times 2 matrices, the minimal polynomial of J3(μ)J_3(\mu), naturality of ev\mathrm{ev}, and the non-pure tensor. From Mathlib: Theorem 5, Theorem 7, the generalised eigenspace decomposition, Theorem 14's isomorphism, dim⁡V∗=dim⁡V\dim V^* = \dim V and Theorem 16. Not formalised: the Jordan normal form as a statement about block matrices (Mathlib has the generalised eigenspace decomposition and the Jordan–Chevalley decomposition T=S+NT = S + N, not yet the block form or Theorem 11), the rational canonical form, Theorem 6 and Proposition 15. The Lean exercises ask you to reprove Lemma 2 and the 2×22 \times 2 Cayley–Hamilton identity.

ComputationC

Jordan forms exactly, spectra numerically

The rank formula of Theorem 12 is an algorithm. The first program builds an integer 5×55 \times 5 matrix, computes the ranks of (A−λI)k(A - \lambda I)^k in exact rational arithmetic, reads off the Jordan blocks, checks them against SymPy's jordan_form, verifies χA(A)=0\chi_A(A) = 0 and the minimal polynomial, and finally shows two 4×44 \times 4 matrices with the same characteristic and minimal polynomials that are nevertheless not similar.

Jordan forms from ranks, and Cayley-Hamilton, exactlyPythonExact computationSymbolic computationComputationally tested
"""Reading off a Jordan normal form from ranks, in exact arithmetic.

The lesson proves that the Jordan form of A is determined by the numbers
rank (A - lambda I)^k: the number of Jordan blocks for lambda of size at least
k is rank (A - lambda I)^(k-1) - rank (A - lambda I)^k. Here a 5 x 5 integer
matrix (built as P J P^-1 and then "forgotten") is analysed with that formula,
compared with SymPy's own jordan_form, and used to check the Cayley-Hamilton
theorem and the minimal polynomial exactly. A last pair of 4 x 4 matrices shows
that the characteristic and minimal polynomials alone do not determine the
Jordan form, while the ranks do.

All arithmetic is exact (rational), so each check is an exact verification for
these particular matrices; the general theorems are proved in the lesson.
"""

import sympy

X = sympy.Symbol("x")

def jordan_block(lam, size):
    """The size x size Jordan block with eigenvalue lam."""
    return sympy.Matrix(size, size, lambda i, j: lam if i == j else
                        (1 if j == i + 1 else 0))

def example_matrix():
    """A = P J P^-1 with J = J3(2) + J1(2) + J1(-1) and det P = 1."""
    p = sympy.Matrix([[1, 1, 0, 0, 0], [0, 1, 1, 0, 0], [1, 0, 1, 1, 0],
                      [0, 0, 0, 1, 1], [0, 1, 0, 0, 1]])
    j = sympy.diag(jordan_block(2, 3), jordan_block(2, 1), jordan_block(-1, 1))
    return p * j * p.inv()

def rank_sequence(a, lam):
    """[rank (A - lam I)^k for k = 0, 1, ...] until the ranks stop falling."""
    n = a.shape[0]
    shifted = a - lam * sympy.eye(n)
    ranks, power = [n], sympy.eye(n)
    while True:
        power = power * shifted
        ranks.append(power.rank())
        if ranks[-1] == ranks[-2]:
            return ranks

def block_sizes(ranks):
    """Jordan block sizes (largest first) from a rank sequence r_0, r_1, ...

    Blocks of size >= k number r_(k-1) - r_k, so blocks of size exactly k
    number r_(k-1) - 2 r_k + r_(k+1).
    """
    r = list(ranks) + [ranks[-1]]
    sizes = []
    for k in range(len(ranks) - 1, 0, -1):
        sizes += [k] * (r[k - 1] - 2 * r[k] + r[k + 1])
    return sizes

def jordan_data(a):
    """{eigenvalue: block sizes} computed with the rank formula."""
    roots = sympy.roots(a.charpoly(X).as_expr(), X)
    return {lam: block_sizes(rank_sequence(a, lam)) for lam in sorted(roots)}

def evaluate(poly_expr, a):
    """The matrix p(A) for a polynomial expression p in X (Horner's rule)."""
    result = sympy.zeros(*a.shape)
    for c in sympy.Poly(poly_expr, X).all_coeffs():
        result = result * a + c * sympy.eye(a.shape[0])
    return result

def blocks_of_jordan_matrix(j):
    """{eigenvalue: block sizes} read off a matrix already in Jordan form."""
    n, blocks, i = j.shape[0], {}, 0
    while i < n:
        k = 1
        while i + k < n and j[i + k - 1, i + k] == 1:
            k += 1
        blocks.setdefault(j[i, i], []).append(k)
        i += k
    return {lam: sorted(s, reverse=True) for lam, s in blocks.items()}

def minimal_polynomial(a):
    """prod (x - lambda)^(largest block for lambda), from the Jordan data."""
    return sympy.Mul(*[(X - lam) ** max(s) for lam, s in jordan_data(a).items()])

def main():
    a = example_matrix()
    print("A (a 5 x 5 integer matrix):")
    for i in range(5):
        print("   " + " ".join(f"{int(v):3d}" for v in a.row(i)))
    print("characteristic polynomial:", sympy.factor(a.charpoly(X).as_expr()))
    data = jordan_data(a)
    for lam, sizes in data.items():
        ranks = rank_sequence(a, lam)
        print(f"lambda = {lam}: ranks of (A - lambda I)^k, k = 0, 1, ...: "
              f"{ranks}")
        print(f"   -> Jordan block sizes {sizes}")
    _, j = a.jordan_form()
    print("SymPy's jordan_form gives the same blocks:",
          blocks_of_jordan_matrix(j) == data)
    m = minimal_polynomial(a)
    print("minimal polynomial:", m)
    chi = a.charpoly(X).as_expr()
    print("chi_A(A) = 0 (Cayley-Hamilton):", evaluate(chi, a).is_zero_matrix)
    print("m(A) = 0:", evaluate(m, a).is_zero_matrix)
    smaller = (X - 2) ** 2 * (X + 1)
    print("(x - 2)^2 (x + 1) kills A:", evaluate(smaller, a).is_zero_matrix)
    print()
    b = sympy.diag(jordan_block(0, 2), jordan_block(0, 2))
    c = sympy.diag(jordan_block(0, 2), jordan_block(0, 1), jordan_block(0, 1))
    print("B = J2(0) + J2(0) and C = J2(0) + J1(0) + J1(0):")
    print("   same characteristic polynomial:",
          b.charpoly(X) == c.charpoly(X), "  same minimal polynomial:",
          minimal_polynomial(b) == minimal_polynomial(c))
    print(f"   but rank B = {b.rank()} and rank C = {c.rank()}: "
          "not similar")
    print()
    print("Epistemic status: exact rational arithmetic on these specific "
          "matrices,\nso every 'True' above is an exact verification for them "
          "(trusting SymPy's\nimplementation). That the ranks determine the "
          "Jordan form of every\nmatrix, and that chi_A(A) = 0 always, are "
          "theorems proved in the lesson.")

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Exact arithmetic is essential here. The second program shows why: in floating point, the spectral theorem is beautifully stable — computed eigenvectors are orthonormal to 10−1510^{-15}, and a perturbation of size ε\varepsilon moves the eigenvalues of a symmetric matrix by at most ε\varepsilon (Weyl's inequality) — but the Jordan form is not. Changing one entry of J8(0)J_8(0) by ε=10−10\varepsilon = 10^{-10} moves its eigenvalues to modulus ε1/8≈0.056\varepsilon^{1/8} \approx 0.056, because the characteristic polynomial becomes x8−εx^8 - \varepsilon.

Spectral theorem in floating point; the fragility of JordanPythonNumerical approximationExperimental evidenceComputationally tested
"""The spectral theorem in floating point, and why numerical analysts fear Jordan.

1. A random real symmetric 6 x 6 matrix is diagonalised by numpy's eigh: the
   computed eigenvectors are orthonormal and A = Q diag(w) Q^T to rounding error.
2. The largest eigenvalue is the maximum of the Rayleigh quotient <Av, v>/<v, v>
   (the variational step in the lesson's proof): random sampling approaches it
   from below and never exceeds it.
3. A non-normal matrix has eigenvectors far from orthogonal.
4. Perturbing a symmetric matrix by size eps moves its eigenvalues by at most
   eps (Weyl's inequality), but perturbing one entry of the 8 x 8 Jordan block
   J8(0) by eps = 1e-10 moves its eigenvalues to modulus eps^(1/8) = 0.056,
   more than five hundred million times further.

All results are floating-point (numerical) evidence about specific matrices.
"""

import numpy as np

def random_symmetric(n, seed):
    """A seeded random real symmetric n x n matrix (M + M^T) / 2."""
    m = np.random.default_rng(seed).standard_normal((n, n))
    return (m + m.T) / 2

def spectral_residuals(a):
    """(max |Q^T Q - I|, max |A - Q diag(w) Q^T|) for numpy's eigh."""
    w, q = np.linalg.eigh(a)
    n = a.shape[0]
    return (np.abs(q.T @ q - np.eye(n)).max(),
            np.abs(a - q @ np.diag(w) @ q.T).max())

def rayleigh_max(a, samples, seed):
    """Largest Rayleigh quotient <Av, v>/<v, v> over random vectors v."""
    v = np.random.default_rng(seed).standard_normal((samples, a.shape[0]))
    return float(np.max(np.einsum("ij,jk,ik->i", v, a, v) /
                        np.einsum("ij,ij->i", v, v)))

def eigenvector_angle_degrees(a):
    """Angle between the two eigenvector lines of a 2 x 2 matrix."""
    _, vecs = np.linalg.eig(a)
    c = abs(vecs[:, 0] @ vecs[:, 1])
    c /= np.linalg.norm(vecs[:, 0]) * np.linalg.norm(vecs[:, 1])
    return float(np.degrees(np.arccos(min(1.0, c))))

def perturbed_jordan(n, eps):
    """The nilpotent Jordan block J_n(0) with eps in the bottom-left corner.

    Its characteristic polynomial is x^n - eps, so its eigenvalues are the
    n complex n-th roots of eps, all of modulus eps^(1/n).
    """
    j = np.diag(np.ones(n - 1), 1)
    j[n - 1, 0] = eps
    return j

def max_eigenvalue_shift_symmetric(a, eps, seed):
    """Largest change in sorted eigenvalues after a symmetric eps-perturbation."""
    e = random_symmetric(a.shape[0], seed)
    e *= eps / np.linalg.norm(e, 2)
    return float(np.abs(np.linalg.eigvalsh(a + e) -
                        np.linalg.eigvalsh(a)).max())

def main():
    a = random_symmetric(6, 2024)
    orth, recon = spectral_residuals(a)
    w = np.linalg.eigvalsh(a)
    print("1. A random symmetric 6 x 6 matrix A (seed 2024)")
    print("   eigenvalues:", " ".join(f"{x:.4f}" for x in w))
    print(f"   max |Q^T Q - I| = {orth:.1e},  max |A - Q D Q^T| = {recon:.1e}")
    print()
    r = rayleigh_max(a, 20000, 1)
    print("2. Rayleigh quotient over 20000 random vectors")
    print(f"   best found {r:.6f} <= largest eigenvalue {w[-1]:.6f}")
    print()
    print("3. Eigenvector angle (90 degrees for symmetric matrices)")
    for name, m in [("[[2, 1], [1, 2]]", [[2, 1], [1, 2]]),
                    ("[[1, 10], [0, 2]]", [[1, 10], [0, 2]])]:
        ang = eigenvector_angle_degrees(np.array(m, dtype=float))
        print(f"   {name:<18} angle = {ang:6.2f} degrees")
    print()
    eps = 1e-10
    print(f"4. Sensitivity to a perturbation of size eps = {eps:.0e}")
    shift = max_eigenvalue_shift_symmetric(a, eps, 5)
    print(f"   symmetric A + E: eigenvalues move by {shift:.1e} <= eps")
    for n in (2, 4, 8):
        mods = np.abs(np.linalg.eigvals(perturbed_jordan(n, eps)))
        print(f"   J{n}(0) + eps corner: |eigenvalues| = {mods.mean():.2e}"
              f"  (eps^(1/{n}) = {eps ** (1 / n):.2e})")
    print()
    print("Epistemic status: floating-point computations on specific matrices.\n"
          "They illustrate, but do not prove, the spectral theorem, the\n"
          "variational principle and Weyl's inequality (all theorems). The\n"
          "eps^(1/n) law for the Jordan block is exact algebra (x^n = eps); the\n"
          "computer only confirms it numerically.")

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

The first program's checks are exact verifications for its matrices (trusting SymPy); the second is floating-point evidence. Neither proves the general theorems, which is what the proofs above are for. The moral, well known to numerical analysts since Golub and Wilkinson's 1976 survey: compute Schur forms and singular value decompositions, which are stable, and treat the Jordan form as a theoretical tool.

Explore

Explore: orthogonal axes, skewed axes, one axis

A symmetric matrix maps the unit circle to an ellipse whose axes are its eigenvector lines, and they are perpendicular. Drag the off-diagonal entries apart (making the matrix non-symmetric) and watch the dashed invariant lines stop being perpendicular. Then pick the shear preset: a Jordan block has a single invariant line.

Symmetric: perpendicular eigenvectors

Make the two off-diagonal entries different. When do the dashed lines stop being perpendicular?

Your own matrix
λ₁ = 3λ₂ = 1Ae₁Ae₂
  • image of the grid
  • image of the unit square
  • image of the flag
  • before the transformation
  • invariant line
Entries of the matrix A
A =

The columns of A are the images of e₁ = (1, 0) and e₂ = (0, 1): Ae₁ = (2, 1), Ae₂ = (1, 2)

det A = ad − bc = 3

The unit square (area 1) becomes a parallelogram of area |det A| = 3. Since det A > 0, orientation is preserved.

Invariant lines (real eigenvectors)

  • λ₁ = 3, v₁ = (1, 1)
  • λ₂ = 1, v₂ = (1, −1)

Vectors on the two dashed lines are only stretched, by the factors λ₁ = 3 and λ₂ = 1; every other direction is turned.

Here the matrix is upper triangular with distinct eigenvalues 11 and 22: diagonalisable, but its eigenvectors meet at about 34°34°. Slide the top-right entry towards 00 (the angle opens to 90°90°) and towards large values (the eigenvectors nearly coincide — the matrix is close to a Jordan block in the numerical sense, and its eigenvectors become ill-conditioned).

Non-normal: skewed eigenvectors

Change the entries or pick a transformation. The columns of A are where e₁ and e₂ land; the gold square shows what happens to area.

Your own matrix
λ₁ = 2λ₂ = 1Ae₁Ae₂
  • image of the grid
  • image of the unit square
  • image of the flag
  • before the transformation
  • invariant line
Entries of the matrix A
A =

The columns of A are the images of e₁ = (1, 0) and e₂ = (0, 1): Ae₁ = (1, 0), Ae₂ = (1.5, 2)

det A = ad − bc = 2

The unit square (area 1) becomes a parallelogram of area |det A| = 2. Since det A > 0, orientation is preserved.

Invariant lines (real eigenvectors)

  • λ₁ = 2, v₁ = (1, 0.667)
  • λ₂ = 1, v₂ = (1, 0)

Vectors on the two dashed lines are only stretched, by the factors λ₁ = 2 and λ₂ = 1; every other direction is turned.

Exercises

Exercises

1. Advanced linear algebra

Warm-upHuman

The symmetric matrix A=(5222)A = \begin{pmatrix} 5 & 2 \\ 2 & 2 \end{pmatrix} is the matrix of q(x,y)=5x2+4xy+2y2q(x, y) = 5x^2 + 4xy + 2y^2. What is the largest eigenvalue of AA, that is, the maximum of qq on the unit circle?

2. Advanced linear algebra

CoreHuman

Which of these matrices are unitarily (or, for real ones, orthogonally) diagonalisable over C\mathbb{C}? (Choose all that apply.)

Choose all that apply

3. Advanced linear algebra

CoreHuman

In the proof of the spectral theorem, v1v_1 is an eigenvector of the self-adjoint operator TT and W=v1⊥W = v_1^{\perp}. Why does TT map WW into WW?

Choose one

4. Advanced linear algebra

CoreHuman

A nilpotent operator NN on a 55-dimensional space has rank⁡N=3\operatorname{rank} N = 3, rank⁡N2=1\operatorname{rank} N^2 = 1 and N3=0N^3 = 0. What is the degree of its minimal polynomial?

5. Advanced linear algebra

CoreHuman

Let VV and WW be finite-dimensional. Which statements about V⊗WV \otimes W are true? (Choose all that apply.)

Choose all that apply

6. Advanced linear algebra

StretchHuman

Let V=W=RV = W = \mathbb{R} and let η:R→R∗\eta : \mathbb{R} \to \mathbb{R}^* be the 'basis' isomorphism sending 11 to the functional 1∗1^* with 1∗(t)=t1^*(t) = t. Let f:R→Rf : \mathbb{R} \to \mathbb{R} be f(t)=2tf(t) = 2t. Compute the number (f∗(η(f(1))))(1)\big(f^*(\eta(f(1)))\big)(1). (Naturality would require it to equal η(1)(1)=1\eta(1)(1) = 1.)

7. Advanced linear algebra

CoreFormal

Which Lean statement correctly formalises Lemma 2 (eigenvectors of a symmetric operator for distinct eigenvalues are orthogonal)? In each, T : E →ₗ[ℝ] E on a real inner product space E.

Choose one

8. Advanced linear algebra

Warm-upHuman

What is dim⁡(R3⊗R4⊗R2)\dim\big(\mathbb{R}^3 \otimes \mathbb{R}^4 \otimes \mathbb{R}^2\big)?

9. Advanced linear algebra

StretchComputational

Implement the uniqueness part of Theorem 12. Write block_sizes(ranks) where ranks = [r0, r1, r2, ...] lists rank⁡(A−λI)k\operatorname{rank}(A - \lambda I)^k for k=0,1,2,…k = 0, 1, 2, \dots, ending once the ranks stop changing. Return the list of Jordan block sizes for λ\lambda, largest first. (Blocks of size ≥k\geq k number rk−1−rkr_{k-1} - r_k.)

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.
Common misconceptionsH

Common misconceptions

Misconception

"VV and V∗V^* are canonically the same." They have the same dimension, so they are isomorphic, but every isomorphism depends on a choice — a basis (sending eie_i to ei∗e_i^*) or an inner product. Proposition 15 makes this precise: no choice-free family of isomorphisms V→V∗V \to V^* is compatible with all isomorphisms. The double dual is different: V→V∗∗V \to V^{**} is natural (Theorem 14). The worked example of a dual basis shows the dependence concretely: b1=e1b_1 = e_1 but b1∗≠e1∗b_1^* \ne e_1^*.

Misconception

"Every element of V⊗WV \otimes W has the form v⊗wv \otimes w." Pure tensors span V⊗WV \otimes W, but most elements are sums of them. e1⊗e1+e2⊗e2e_1 \otimes e_1 + e_2 \otimes e_2 corresponds to the identity matrix of rank 22 and is not pure (Proposition 17, and the Lean theorem not_pure_tensor). In quantum mechanics the non-pure tensors are the entangled states.

Misconception

"Symmetric matrices are diagonalisable over every field." The spectral theorem is about real symmetric matrices, or complex Hermitian ones, and its proof uses positivity of the inner product. The complex symmetric matrix (1ii−1)\begin{pmatrix} 1 & i \\ i & -1 \end{pmatrix} is non-zero with square 00, and over F2\mathbb F_2 the symmetric matrix (1111)\begin{pmatrix} 1 & 1 \\ 1 & 1 \end{pmatrix} also squares to 00.

Misconception

"χA(A)=det⁡(AI−A)=0\chi_A(A) = \det(AI - A) = 0 proves Cayley–Hamilton." Substituting a matrix for xx inside a determinant is not legitimate: in det⁡(xI−A)\det(xI - A), xx multiplies scalar entries, and AI−AAI - A would be a matrix with matrix entries. The theorem is true, but needs an argument such as the adjugate proof of Theorem 7.

Misconception

"The characteristic and minimal polynomials determine the matrix up to similarity." They do for n≤3n \le 3, but not in general: J2(0)⊕J2(0)J_2(0) \oplus J_2(0) and J2(0)⊕J1(0)⊕J1(0)J_2(0) \oplus J_1(0) \oplus J_1(0) both have χ=x4\chi = x^4 and m=x2m = x^2, yet ranks 22 and 11. The complete invariant is the list of ranks of (A−λI)k(A - \lambda I)^k — equivalently the Jordan form.

Misconception

"Eigenvectors are always orthogonal." Only for normal operators (Theorem 6). The eigenvectors (1,0)(1, 0) and (10,1)(10, 1) of (11002)\begin{pmatrix} 1 & 10 \\ 0 & 2 \end{pmatrix} meet at under 6°6°, as the second experiment measures.

ViewpointsH

Many ways of seeing

Geometry— Ellipsoids, quadrics and the singular value decomposition

The spectral theorem is the principal axes theorem: every quadric xTAx=1\mathbf x^{\mathsf T} A \mathbf x = 1 in Rn\R^n becomes ∑λiui2=1\sum \lambda_i u_i^2 = 1 in suitable orthonormal coordinates, so the signs of the eigenvalues classify ellipsoids and hyperboloids (Sylvester's law of inertia says the number of positive and negative λi\lambda_i cannot be changed by any change of basis, orthogonal or not). For an arbitrary real matrix MM, applying the theorem to the symmetric matrix MTMM^{\mathsf T}M gives the singular value decomposition M=UΣVTM = U\Sigma V^{\mathsf T}: every linear map takes the unit sphere to an ellipsoid, rotating the sphere first and the ellipsoid afterwards, with semi-axes the singular values. In mechanics, the same theorem gives a rigid body's principal axes of inertia, about which it can spin without wobbling. See conic sections and matrix groups, where the orthogonal and unitary matrices QQ, UU become groups.

Topology— Similarity classes, closures and generic matrices

Similarity classes of complex n×nn \times n matrices are orbits of the group GLn(C)GL_n(\C) acting on Cn2\C^{n^2} by conjugation, and their topology mirrors the Jordan form. The orbit of J2(0)J_2(0) is not closed: (0t00)\begin{pmatrix} 0 & t \\ 0 & 0 \end{pmatrix} is similar to J2(0)J_2(0) for every t≠0t \ne 0 but tends to 00. In general the closure of the orbit of a nilpotent matrix is a union of orbits of "smaller" Jordan types (ordered by dominance of partitions). Conversely, matrices with distinct eigenvalues form an open dense set, so the map "matrix ↦\mapsto Jordan form" is wildly discontinuous — the topological face of the ε1/n\varepsilon^{1/n} phenomenon in the second experiment. On the other hand, the eigenvalues, as an unordered list, depend continuously on the matrix (roots of a polynomial depend continuously on its coefficients). This also gives an analyst's proof of Cayley–Hamilton over C\C: A↦χA(A)A \mapsto \chi_A(A) is continuous, vanishes on diagonalisable matrices, and these are dense.

Analysis— Infinite dimensions: compact operators, Fourier series and the spectrum

On infinite-dimensional Hilbert spaces the spectral theorem survives for compact self-adjoint operators: there is an orthonormal basis of eigenvectors with real eigenvalues tending to 00 (Hilbert and Schmidt, 1904–1907, in the study of integral equations). Fourier series are an instance: the functions einxe^{inx} are eigenfunctions of −d2/dx2-d^2/dx^2 on the circle, with eigenvalues n2n^2, and expanding a function in Fourier series is diagonalising that operator (whose inverse on functions with mean zero is compact). For general bounded self-adjoint operators eigenvectors may not exist at all — multiplication by xx on L2[0,1]L^2[0, 1] has none — and the theorem becomes a statement about projection-valued measures (von Neumann, 1929). Duality also changes: for normed spaces one uses only continuous functionals, and a space with V→V∗∗V \to V^{**} onto is called reflexive (ℓ2\ell^2 is, ℓ1\ell^1 is not). See functional analysis.

Algebra— Canonical forms are the structure theorem for modules over k[x]

An operator TT on VV makes VV into a module over the polynomial ring k[x]k[x], with xx acting as TT; similar operators give isomorphic modules. Because k[x]k[x] is a principal ideal domain, every finitely generated module is a direct sum of cyclic modules k[x]/(p)k[x]/(p) — the same theorem that classifies finitely generated abelian groups as sums of Z/n\Z/n. Choosing the invariant-factor decomposition ⨁k[x]/(di)\bigoplus k[x]/(d_i) gives the rational canonical form (on k[x]/(d)k[x]/(d), xx acts by the companion matrix of dd); choosing the elementary-divisor decomposition ⨁k[x]/((x−λ)m)\bigoplus k[x]/((x - \lambda)^m) over an algebraically closed field gives the Jordan form (on k[x]/((x−λ)m)k[x]/((x - \lambda)^m) with basis (x−λ)m−1,…,1(x - \lambda)^{m-1}, \dots, 1, xx acts as Jm(λ)J_m(\lambda)). Cayley–Hamilton says χT\chi_T lies in the annihilator ideal (mT)(m_T). See modules and rings.

Probability— Covariance matrices and principal components

The covariance matrix Σ=E[(X−μ)(X−μ)T]\Sigma = \mathbb E[(X - \mu)(X - \mu)^{\mathsf T}] of a random vector XX in Rn\R^n is symmetric and positive semidefinite, since uTΣu=Var⁡(uTX)≥0\mathbf u^{\mathsf T}\Sigma\mathbf u = \operatorname{Var}(\mathbf u^{\mathsf T} X) \ge 0. By the spectral theorem its orthonormal eigenvectors are uncorrelated directions, and by the variational characterisation (Lemma 4) the top eigenvector is the direction of greatest variance. This is principal component analysis. The level sets of a multivariate normal density are the ellipsoids (x−μ)TΣ−1(x−μ)=c(\mathbf x - \mu)^{\mathsf T}\Sigma^{-1}(\mathbf x - \mu) = c, whose axes are those eigenvectors. Random matrix theory studies the eigenvalues of large random symmetric matrices, whose histogram approaches Wigner's semicircle law. See statistics.

Physics— Observables, composite systems and entanglement

In quantum mechanics a measurable quantity is a self-adjoint operator on a complex Hilbert space; the possible outcomes of a measurement are its eigenvalues (real, by Lemma 1) and outcomes for different eigenvalues are perfectly distinguishable because the eigenvectors are orthogonal (Lemma 2). Two observables can be measured simultaneously exactly when the operators commute, which is when they share an orthonormal eigenbasis. The state space of a composite system is the tensor product of the state spaces of its parts, and a state that is not a pure tensor — such as the Bell state 12(∣00⟩+∣11⟩)\tfrac{1}{\sqrt2}(\lvert 00 \rangle + \lvert 11 \rangle) of the motivation, which corresponds to a rank-two matrix — is entangled. The rank in Proposition 17 is the Schmidt rank, a basic measure of entanglement. See quantum mechanics.

Category theory— Naturality, monoidal structure and the tensor–hom adjunction

Eilenberg and Mac Lane introduced categories, functors and natural transformations (1945) to make precise exactly the distinction in Theorem 14 and Proposition 15: V↦V∗∗V \mapsto V^{**} is a covariant functor and ev\mathrm{ev} is a natural isomorphism from the identity functor, while V↦V∗V \mapsto V^* is contravariant, so a natural isomorphism to it cannot even be stated (see natural transformations). The universal property of ⊗\otimes is an adjunction: Hom(V⊗W,U)≅Hom(V,Hom(W,U))\Hom(V \otimes W, U) \cong \Hom(V, \Hom(W, U)), naturally in all three spaces. With ⊗\otimes and unit kk, finite-dimensional vector spaces form a symmetric monoidal category in which every object has a dual, with V∗⊗W≅Hom(V,W)V^* \otimes W \cong \Hom(V, W) (Proposition 17); the trace is then a composite V∗⊗V→kV^* \otimes V \to k of structure maps. See monoidal categories.

History & global context

History and global context

  • Principal axes and secular equations. Euler (1765) found the principal axes of a rotating rigid body, and Lagrange and Laplace studied the "secular equation" det⁡(A−λI)=0\det(A - \lambda I) = 0 for the long-term (secular) perturbations of planetary orbits. Augustin-Louis Cauchy proved in 1829 that the roots of this equation are real for symmetric AA, and that the principal axes are orthogonal, in a paper on exactly that astronomical problem.
  • Inertia and matrices. James Joseph Sylvester proved his law of inertia for quadratic forms (1852) and coined the word matrix (1850). Arthur Cayley's Memoir on the theory of matrices (1858) stated the Cayley–Hamilton theorem, verified it for 2×22 \times 2 matrices and reported checking 3×33 \times 3; William Rowan Hamilton had proved an instance for linear functions of quaternions (1853). Ferdinand Georg Frobenius gave the first general proof (1878) and introduced the minimal polynomial.
  • Canonical forms. Karl Weierstrass (1868) developed elementary divisors for pairs of bilinear forms, and Camille Jordan's Traité des substitutions (1870) gave the canonical form, originally over finite fields, in his study of groups. Henry Smith's normal form for integer matrices (1861) is the Z\Z-analogue.
  • Infinite dimensions. David Hilbert's work on integral equations (1904–1910) introduced the word spectrum into analysis, Erhard Schmidt developed the orthogonalisation now named after him and Gram, and John von Neumann proved the spectral theorem for unbounded self-adjoint operators (1929–1932) to put quantum mechanics on a rigorous footing.
  • Tensors. The tensor calculus of Gregorio Ricci-Curbastro and Tullio Levi-Civita (1900) was the language of Einstein's general relativity; Woldemar Voigt's crystal physics (1898) gave the word tensor its modern meaning. The algebraic tensor product of modules was introduced by Hassler Whitney (1938), and Bourbaki's Algèbre multilinéaire (1948) made the universal-property definition standard.
  • Naturality. Samuel Eilenberg and Saunders Mac Lane's General theory of natural equivalences (1945) began category theory, with the double dual as a guiding example.
Further reading

Further reading

  • Sheldon Axler, Linear Algebra Done Right (1996; 4th ed. 2024) — spectral theorems, generalised eigenspaces and Jordan form; Theorem 11's proof follows Axler.
  • Paul R. Halmos, Finite-Dimensional Vector Spaces (1942; 2nd ed. 1958) — the classic coordinate-free treatment of duality and tensor products, written with Hilbert space in mind.
  • Kenneth Hoffman and Ray Kunze, Linear Algebra (2nd ed. 1971) — rational and Jordan canonical forms via modules over k[x]k[x].
  • Roger A. Horn and Charles R. Johnson, Matrix Analysis (1985; 2nd ed. 2013) — Schur's theorem, the minimax principle, Weyl's inequalities.
  • Steven Roman, Advanced Linear Algebra (1992; 3rd ed. 2008) — modules over a PID, multilinear algebra and tensor products.
  • Lloyd N. Trefethen and David Bau, Numerical Linear Algebra (1997) — why the Schur form and the SVD, not the Jordan form, are computed in practice.