Skip to content
The Lumenary
Early undergraduateUndergraduate (first year) 120 min

Linear algebra

Solving many equations at once, measuring what a map forgets, and finding the directions a matrix only stretches — the most widely used theory in mathematics.

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

Two puzzles with one theory behind them

Balancing a reaction. In photosynthesis, a leaf turns carbon dioxide and water into glucose and oxygen:

a CO2+b H2O⟶c C6H12O6+d O2.a\,\mathrm{CO_2} + b\,\mathrm{H_2O} \longrightarrow c\,\mathrm{C_6H_{12}O_6} + d\,\mathrm{O_2}.

Counting atoms of carbon, hydrogen and oxygen on both sides gives three equations in four unknowns:

a−6c=0,2b−12c=0,2a+b−6c−2d=0.a - 6c = 0, \qquad 2b - 12c = 0, \qquad 2a + b - 6c - 2d = 0.

Must there be a solution other than a=b=c=d=0a = b = c = d = 0? Is it unique up to scaling? (Chemists find 6,6,1,66, 6, 1, 6.) The answers — yes, and yes — come from a single theorem about dimensions, the rank–nullity theorem, which says that three equations can "use up" at most three of the four degrees of freedom.

Growth. The Fibonacci numbers 0,1,1,2,3,5,8,13,…0, 1, 1, 2, 3, 5, 8, 13, \dots satisfy Fn+1=Fn+Fn−1F_{n+1} = F_n + F_{n-1}. In matrix form,

(Fn+1Fn)=(1110)(FnFn−1),\begin{pmatrix} F_{n+1} \\ F_n \end{pmatrix} = \begin{pmatrix} 1 & 1 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} F_n \\ F_{n-1} \end{pmatrix},

so computing FnF_n means computing powers of a matrix. The ratios Fn+1/FnF_{n+1}/F_n approach the golden ratio φ=(1+5)/2≈1.618\varphi = (1 + \sqrt5)/2 \approx 1.618. Why that number? Because φ\varphi is an eigenvalue of the matrix: there is a direction that the matrix only stretches, by the factor φ\varphi, and after many steps that direction wins.

The same two questions — solve a linear system, understand repeated application of a linear map — appear in circuit analysis, economics, computer graphics, statistics, quantum mechanics, search engines and machine learning. Linear algebra is the theory that answers both. It starts where school algebra stops: from simultaneous linear equations in two or three unknowns, with scalars from the real numbers (or any other field).

IntuitionH

Linear maps as transformations of space

A 2×22 \times 2 matrix AA moves every point xx of the plane to AxAx. Because A(x+y)=Ax+AyA(x + y) = Ax + Ay and A(cx)=c AxA(cx) = c\,Ax, the whole picture is determined by where the two basis vectors e1=(1,0)e_1 = (1, 0) and e2=(0,1)e_2 = (0, 1) go: they go to the columns of AA. The square grid becomes a grid of parallelograms, the origin stays put, and straight lines stay straight (or collapse).

Three numbers measure what happens:

  • the determinant is the factor by which areas are multiplied, with a minus sign if the map flips the plane over;
  • the rank is the dimension of the image: 22 if the plane goes onto the plane, 11 if it is squashed onto a line, 00 if everything goes to the origin;
  • the eigenvectors are the directions that are not turned at all, only stretched (by the eigenvalue).

A linear map of the plane

Drag the entries or pick a preset. Watch the columns, the area of the unit square, the flag and the dashed invariant lines.

Your own matrix
λ₁ = 2λ₂ = 0.5Ae₁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.5), Ae₂ = (1, 1.5)

det A = ad − bc = 1

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

Invariant lines (real eigenvectors)

  • λ₁ = 2, v₁ = (1, 1)
  • λ₂ = 0.5, v₂ = (1, −0.5)

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

Try the "singular" preset: the whole plane collapses onto a line, the determinant is 00, and some non-zero vectors are sent to 00. That collapse is exactly what makes a system of equations fail to have a unique solution. Try "rotation": no real direction survives unturned, so there are no real eigenvectors.

DefinitionsH

Definitions

Throughout, kk is a field: Q\Q, R\R, C\C, or the two-element field F2={0,1}\mathbb F_2 = \{0, 1\} with 1+1=01 + 1 = 0 (see algebraic structures). Elements of kk are called scalars.

Definition— vector space

A vector space over kk is a set VV with an addition V×V→VV \times V \to V and a scalar multiplication k×V→Vk \times V \to V such that (V,+)(V, +) is an abelian group (with zero vector 00) and, for all a,b∈ka, b \in k and u,v∈Vu, v \in V,

a(u+v)=au+av,(a+b)v=av+bv,(ab)v=a(bv),1v=v.a(u + v) = au + av, \qquad (a + b)v = av + bv, \qquad (ab)v = a(bv), \qquad 1v = v.

A subspace is a subset U⊆VU \subseteq V containing 00 and closed under addition and scalar multiplication; it is a vector space in its own right.

Definition— span, linear independence, basis, dimension

A linear combination of v1,…,vn∈Vv_1, \dots, v_n \in V is a vector a1v1+⋯+anvna_1 v_1 + \cdots + a_n v_n with ai∈ka_i \in k. Their span is the set of all linear combinations, the smallest subspace containing them. The list is linearly independent if

a1v1+⋯+anvn=0  ⟹  a1=⋯=an=0,a_1 v_1 + \cdots + a_n v_n = 0 \implies a_1 = \cdots = a_n = 0,

and dependent otherwise. A basis of VV is a linearly independent list that spans VV; then every v∈Vv \in V is a1v1+⋯+anvna_1 v_1 + \cdots + a_n v_n for unique scalars aia_i, its coordinates. VV is finite-dimensional if some finite list spans it, and then dim⁡V\dim V is the number of vectors in a basis — a definition that only makes sense once we prove that all bases have the same size (the exchange lemma, below).

Definition— linear map, kernel, image, rank

A map T:V→WT : V \to W between vector spaces over kk is linear if

T(u+v)=T(u)+T(v)andT(cv)=c T(v)for all u,v∈V, c∈k.T(u + v) = T(u) + T(v) \quad\text{and}\quad T(cv) = c\,T(v) \qquad \text{for all } u, v \in V,\ c \in k.

Then T(0)=0T(0) = 0. Its kernel ker⁡T={v∈V:Tv=0}\ker T = \{v \in V : Tv = 0\} and image im⁡T={Tv:v∈V}\operatorname{im} T = \{Tv : v \in V\} are subspaces of VV and WW. The rank of TT is dim⁡im⁡T\dim \operatorname{im} T and its nullity is dim⁡ker⁡T\dim \ker T. A linear map is injective if and only if ker⁡T={0}\ker T = \{0\}, because Tu=Tv  ⟺  T(u−v)=0Tu = Tv \iff T(u - v) = 0.

Definition— matrix of a linear map

Let B=(v1,…,vn)B = (v_1, \dots, v_n) be a basis of VV and C=(w1,…,wm)C = (w_1, \dots, w_m) a basis of WW. The matrix of TT with respect to BB and CC is the m×nm \times n matrix [T][T] whose jj-th column holds the coordinates of TvjT v_j:

Tvj=∑i=1mtij wi.T v_j = \sum_{i=1}^m t_{ij}\, w_i .

For V=knV = k^n and W=kmW = k^m with their standard bases, [T][T] is the matrix AA with Tx=AxTx = Ax. The product of an ℓ×m\ell \times m matrix SS and an m×nm \times n matrix TT is the ℓ×n\ell \times n matrix with entries (ST)ij=∑rsirtrj(ST)_{ij} = \sum_{r} s_{ir} t_{rj}.

Definition— determinant

The determinant of an n×nn \times n matrix A=(aij)A = (a_{ij}) is

det⁡A=∑σ∈Snsgn⁡(σ) aσ(1)1 aσ(2)2⋯aσ(n)n,\det A = \sum_{\sigma \in S_n} \operatorname{sgn}(\sigma)\, a_{\sigma(1)1}\, a_{\sigma(2)2} \cdots a_{\sigma(n)n},

the sum over all permutations σ\sigma of {1,…,n}\{1, \dots, n\}, where sgn⁡(σ)=±1\operatorname{sgn}(\sigma) = \pm 1 according as σ\sigma is a product of an even or odd number of swaps. For n=2n = 2: det⁡(abcd)=ad−bc\det \begin{pmatrix} a & b \\ c & d \end{pmatrix} = ad - bc.

Definition— eigenvalue, eigenvector, diagonalisable

Let T:V→VT : V \to V be linear. A scalar λ∈k\lambda \in k is an eigenvalue of TT if Tv=λvTv = \lambda v for some non-zero vector vv, called an eigenvector. The eigenspace Eλ=ker⁡(T−λI)E_\lambda = \ker(T - \lambda I) consists of the eigenvectors for λ\lambda together with 00; its dimension is the geometric multiplicity of λ\lambda. For a square matrix AA, the characteristic polynomial is pA(t)=det⁡(tI−A)p_A(t) = \det(tI - A), and the multiplicity of λ\lambda as a root of pAp_A is its algebraic multiplicity. AA is diagonalisable (over kk) if P−1APP^{-1} A P is diagonal for some invertible matrix PP with entries in kk.

Worked examplesH

Examples and non-examples

Example— Vector spaces you already know (and some you may not)

  • knk^n, lists of nn scalars; dim⁡kn=n\dim k^n = n, with the standard basis e1,…,ene_1, \dots, e_n.
  • The polynomials of degree at most dd, with basis 1,x,…,xd1, x, \dots, x^d: dimension d+1d + 1.
  • The solutions of the differential equation y′′+y=0y'' + y = 0 on R\R: a vector space of dimension 22, with basis cos⁡,sin⁡\cos, \sin.
  • F27\mathbb F_2^7: the seven-bit words used in error-correcting codes. Over F2\mathbb F_2 we have v+v=0v + v = 0 for every vv.
  • All functions R→R\R \to \R: a vector space that is not finite-dimensional (the functions 1,x,x2,…1, x, x^2, \dots are independent).

Not subspaces of R3\R^3: the plane z=1z = 1 (it does not contain 00); the octant x,y,z≥0x, y, z \ge 0 (not closed under multiplication by −1-1); the union of the xx- and yy-axes in R2\R^2 (closed under scaling, but (1,0)+(0,1)(1, 0) + (0, 1) is on neither axis).

Example— Gaussian elimination, worked

Solve x+2y+z=4x + 2y + z = 4 and 2x+4y+3z=92x + 4y + 3z = 9. Row-reduce the augmented matrix: subtract twice row 1 from row 2, then subtract the new row 2 from row 1:

(12142439)→(12140011)→(12030011).\left(\begin{array}{ccc|c} 1 & 2 & 1 & 4 \\ 2 & 4 & 3 & 9 \end{array}\right) \to \left(\begin{array}{ccc|c} 1 & 2 & 1 & 4 \\ 0 & 0 & 1 & 1 \end{array}\right) \to \left(\begin{array}{ccc|c} 1 & 2 & 0 & 3 \\ 0 & 0 & 1 & 1 \end{array}\right).

This is the reduced row echelon form: each non-zero row starts with a pivot 11, which is the only non-zero entry in its column. The pivot columns belong to xx and zz; the column of yy has no pivot, so y=ty = t is free. Reading off, z=1z = 1 and x=3−2tx = 3 - 2t:

(x,y,z)=(3,0,1)+t (−2,1,0),t∈R.(x, y, z) = (3, 0, 1) + t\,(-2, 1, 0), \qquad t \in \R.

The solution set is a line: one particular solution (3,0,1)(3, 0, 1) plus every multiple of (−2,1,0)(-2, 1, 0), which spans the null space of the coefficient matrix. A system is inconsistent exactly when elimination produces a row (0 ⋯ 0∣c)(0 \ \cdots\ 0 \mid c) with c≠0c \neq 0, that is, the equation 0=c0 = c.

Example— Differentiation as a matrix

Let VV be the polynomials of degree at most 33 with basis 1,x,x2,x31, x, x^2, x^3, and D=d/dx:V→VD = d/dx : V \to V. Since D(1)=0D(1) = 0, D(x)=1D(x) = 1, D(x2)=2xD(x^2) = 2x and D(x3)=3x2D(x^3) = 3x^2, the columns of [D][D] are these coordinates:

[D]=(0100002000030000).[D] = \begin{pmatrix} 0 & 1 & 0 & 0 \\ 0 & 0 & 2 & 0 \\ 0 & 0 & 0 & 3 \\ 0 & 0 & 0 & 0 \end{pmatrix}.

ker⁡D\ker D is the constants (dimension 11) and im⁡D\operatorname{im} D is the polynomials of degree at most 22 (dimension 33); indeed 1+3=4=dim⁡V1 + 3 = 4 = \dim V. Since D4=0D^4 = 0, any eigenvalue λ\lambda satisfies λ4v=D4v=0\lambda^4 v = D^4 v = 0, so λ=0\lambda = 0, and E0=ker⁡DE_0 = \ker D has dimension 11: DD has too few eigenvectors to be diagonalisable.

Example— Maps that are not linear

x↦x+1x \mapsto x + 1 on R\R is not linear: it moves 00. (It is affine: linear followed by a translation; see transformation geometry.) x↦x2x \mapsto x^2 is not linear: (1+1)2≠12+12(1 + 1)^2 \neq 1^2 + 1^2. A linear map need not be injective: the projection (x,y)↦(x,0)(x, y) \mapsto (x, 0) sends the whole yy-axis — a line through the origin — to the single point 00.

ProofH

Linear systems

A system of mm linear equations in nn unknowns is Ax=bAx = b with AA an m×nm \times n matrix. The elementary row operations are: swap two rows; multiply a row by a non-zero scalar; add a multiple of one row to another.

Theorem— Proposition (row operations do not change the solutions)

If an augmented matrix (A∣b)(A \mid b) is turned into (A′∣b′)(A' \mid b') by elementary row operations, then Ax=bAx = b and A′x=b′A'x = b' have exactly the same solutions.

Proof

Each new equation is a linear combination of the old ones, so every solution of the old system solves the new one. Each operation can be undone by an operation of the same kind (swap back; multiply by c−1c^{-1}; subtract the multiple again), so by the same argument every solution of the new system solves the old one.

∎

By repeatedly choosing a pivot, scaling it to 11 and clearing its column, any matrix can be brought to reduced row echelon form; this is Gaussian elimination. Its output is read off as in the worked example: the system is consistent if and only if no pivot lies in the last column, and then the free variables can be chosen arbitrarily and determine the pivot variables uniquely.

Theorem— Theorem (structure of the solution set)

Let T:V→WT : V \to W be linear and b∈Wb \in W. If x0x_0 is one solution of Tx=bTx = b, then the set of all solutions is the translate

{x∈V:Tx=b}=x0+ker⁡T={x0+z:z∈ker⁡T}.\{x \in V : Tx = b\} = x_0 + \ker T = \{x_0 + z : z \in \ker T\}.

In particular, a consistent system has a unique solution exactly when ker⁡T={0}\ker T = \{0\}.

Proof

By linearity Tx−Tx0=T(x−x0)Tx - Tx_0 = T(x - x_0), so Tx=b=Tx0Tx = b = Tx_0 holds if and only if T(x−x0)=0T(x - x_0) = 0, that is, x−x0∈ker⁡Tx - x_0 \in \ker T, that is, x∈x0+ker⁡Tx \in x_0 + \ker T.

∎

So the solution set of a linear system is empty, or a point, or a line, plane, … that need not pass through the origin, parallel to the null space. This is the shape of the solutions of linear differential equations too: general solution = particular solution + general solution of the homogeneous equation.

ProofH

Bases and dimension

Theorem— Lemma (adding a vector outside the span)

If u1,…,umu_1, \dots, u_m are linearly independent and v∉span⁡(u1,…,um)v \notin \operatorname{span}(u_1, \dots, u_m), then u1,…,um,vu_1, \dots, u_m, v are linearly independent.

Proof

Suppose a1u1+⋯+amum+cv=0a_1 u_1 + \cdots + a_m u_m + cv = 0. If c≠0c \neq 0 then v=−c−1(a1u1+⋯+amum)v = -c^{-1}(a_1 u_1 + \cdots + a_m u_m) lies in the span, which is false; so c=0c = 0, and then independence of the uiu_i gives a1=⋯=am=0a_1 = \cdots = a_m = 0.

∎

Theorem— Theorem (Steinitz exchange lemma)

If u1,…,umu_1, \dots, u_m are linearly independent in VV and w1,…,wnw_1, \dots, w_n span VV, then m≤nm \le n.

Proof

We replace the ww's by uu's one at a time, keeping a spanning list. We claim that for each j=0,1,…,mj = 0, 1, \dots, m, after renumbering the ww's, j≤nj \le n and the list u1,…,uj,wj+1,…,wnu_1, \dots, u_j, w_{j+1}, \dots, w_n spans VV. For j=0j = 0 this is the hypothesis.

Suppose it holds for some j<mj < m. Since the list spans, uj+1=b1u1+⋯+bjuj+cj+1wj+1+⋯+cnwnu_{j+1} = b_1 u_1 + \cdots + b_j u_j + c_{j+1} w_{j+1} + \cdots + c_n w_n for some scalars. If every cic_i were 00 — in particular, if no ww's were left, j=nj = n — then uj+1u_{j+1} would be a combination of u1,…,uju_1, \dots, u_j, contradicting independence. So j<nj < n, and after renumbering cj+1≠0c_{j+1} \neq 0. Solving for wj+1w_{j+1},

wj+1=cj+1−1(uj+1−∑i≤jbiui−∑i>j+1ciwi)∈span⁡(u1,…,uj+1,wj+2,…,wn),w_{j+1} = c_{j+1}^{-1}\Big(u_{j+1} - \sum_{i \le j} b_i u_i - \sum_{i > j+1} c_i w_i\Big) \in \operatorname{span}(u_1, \dots, u_{j+1}, w_{j+2}, \dots, w_n),

so this new list still spans everything the old one did, namely VV. This proves the claim for j+1j + 1, and with j=mj = m it gives m≤nm \le n.

∎

Theorem— Corollary (invariance of dimension)

Any two bases of a finite-dimensional vector space have the same number of elements.

Proof

If (u1,…,um)(u_1, \dots, u_m) and (w1,…,wn)(w_1, \dots, w_n) are bases, each is independent and each spans, so the exchange lemma gives m≤nm \le n and n≤mn \le m.

∎

Theorem— Corollary (extending to a basis)

In a vector space of dimension nn, every linearly independent list has at most nn vectors and can be extended to a basis; every subspace UU is finite-dimensional with dim⁡U≤n\dim U \le n.

Proof

An independent list has at most nn elements by the exchange lemma (a basis spans). If an independent list does not span, add a vector outside its span; by the lemma it stays independent. This must stop after at most nn additions, and it stops only at a spanning list, i.e. a basis. For a subspace UU, start from the empty list and add vectors of UU outside the current span: the lists stay independent in VV, so the process stops after at most nn steps, at a basis of UU.

∎

ProofH

The rank–nullity theorem

Theorem— Theorem (rank–nullity)

Let T:V→WT : V \to W be linear with VV finite-dimensional. Then im⁡T\operatorname{im} T is finite-dimensional and

dim⁡V=dim⁡ker⁡T+dim⁡im⁡T.\dim V = \dim \ker T + \dim \operatorname{im} T.

Proof

Choose a basis u1,…,usu_1, \dots, u_s of ker⁡T\ker T and extend it to a basis u1,…,us,v1,…,vru_1, \dots, u_s, v_1, \dots, v_r of VV, so dim⁡V=s+r\dim V = s + r. We show that Tv1,…,TvrTv_1, \dots, Tv_r is a basis of im⁡T\operatorname{im} T.

Spanning. Any x∈Vx \in V is ∑aiui+∑bjvj\sum a_i u_i + \sum b_j v_j, and Tui=0Tu_i = 0, so Tx=∑bj TvjTx = \sum b_j\, Tv_j.

Independence. If ∑bj Tvj=0\sum b_j\, Tv_j = 0 then T(∑bjvj)=0T(\sum b_j v_j) = 0, so ∑bjvj∈ker⁡T\sum b_j v_j \in \ker T and ∑bjvj=∑aiui\sum b_j v_j = \sum a_i u_i for some aia_i. Then ∑aiui−∑bjvj=0\sum a_i u_i - \sum b_j v_j = 0 is a relation among the vectors of a basis of VV, so all bjb_j (and aia_i) are 00.

Hence dim⁡im⁡T=r\dim \operatorname{im} T = r and dim⁡V=s+r=dim⁡ker⁡T+dim⁡im⁡T\dim V = s + r = \dim\ker T + \dim\operatorname{im} T.

∎

For a matrix AA, Gaussian elimination makes this concrete: rank⁡A\operatorname{rank} A is the number of pivots (the pivot columns of AA form a basis of its column space, because row operations preserve the linear relations between columns), and the nullity is the number of free variables (each free variable gives one basis vector of the null space, as in the worked example). Every column is either a pivot column or a free one.

Theorem— Corollary (more unknowns than equations)

A homogeneous system Ax=0Ax = 0 of mm equations in n>mn > m unknowns has a non-zero solution.

Proof

The image of x↦Axx \mapsto Ax lies in kmk^m, so has dimension at most mm. By rank–nullity dim⁡ker⁡A=n−dim⁡im⁡A≥n−m>0\dim \ker A = n - \dim \operatorname{im} A \ge n - m > 0, so ker⁡A\ker A contains a non-zero vector.

∎

For photosynthesis, n=4>3=mn = 4 > 3 = m, so a non-zero balancing exists. Elimination shows the rank is exactly 33, so the null space is a line: the balancing (6,6,1,6)(6, 6, 1, 6) is unique up to scaling.

Theorem— Corollary (injective, surjective, bijective)

If T:V→VT : V \to V is linear and VV is finite-dimensional, then TT is injective   ⟺  \iff TT is surjective   ⟺  \iff TT is bijective.

Proof

TT is injective iff dim⁡ker⁡T=0\dim \ker T = 0, iff (by rank–nullity) dim⁡im⁡T=dim⁡V\dim \operatorname{im} T = \dim V, iff im⁡T=V\operatorname{im} T = V (a subspace of full dimension is the whole space: a basis of it is an independent list of dim⁡V\dim V vectors, which cannot be extended, so it already spans VV).

∎

This fails in infinite dimensions: on sequences, the shift (a0,a1,… )↦(0,a0,a1,… )(a_0, a_1, \dots) \mapsto (0, a_0, a_1, \dots) is injective but not surjective.

ProofH

Matrices, composition and change of basis

Theorem— Theorem (composition is matrix multiplication)

Let T:U→VT : U \to V and S:V→WS : V \to W be linear, and fix bases (uj)(u_j), (vr)(v_r), (wi)(w_i). Then S∘TS \circ T is linear, and [S∘T]=[S] [T][S \circ T] = [S]\,[T].

Proof

Linearity: S(T(x+y))=S(Tx+Ty)=S(Tx)+S(Ty)S(T(x + y)) = S(Tx + Ty) = S(Tx) + S(Ty), and similarly for scalars. For the matrix, with [T]=(trj)[T] = (t_{rj}) and [S]=(sir)[S] = (s_{ir}),

(S∘T)(uj)=S(∑rtrjvr)=∑rtrj Svr=∑rtrj∑isirwi=∑i(∑rsirtrj)wi,(S \circ T)(u_j) = S\Big(\sum_r t_{rj} v_r\Big) = \sum_r t_{rj}\, S v_r = \sum_r t_{rj} \sum_i s_{ir} w_i = \sum_i \Big(\sum_r s_{ir} t_{rj}\Big) w_i,

so the (i,j)(i, j) entry of [S∘T][S \circ T] is ∑rsirtrj=([S][T])ij\sum_r s_{ir} t_{rj} = ([S][T])_{ij}.

∎

This is why matrices are multiplied rows-into-columns. It also proves for free that matrix multiplication is associative, because composition of functions is. It is not commutative, because composition is not: with A=(0100)A = \begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix} and B=(0010)B = \begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix}, AB=(1000)AB = \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix} but BA=(0001)BA = \begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix}. Rotations of the plane do commute: multiplying the rotation matrices RαRβR_\alpha R_\beta produces the addition formulas for sine and cosine and gives Rα+βR_{\alpha + \beta}.

Theorem— Proposition (change of basis)

Let BB and B′B' be bases of VV, and let PP be the matrix whose jj-th column holds the BB-coordinates of the jj-th vector of B′B'. Then PP is invertible, [x]B=P [x]B′[x]_B = P\,[x]_{B'} for every xx, and for every linear T:V→VT : V \to V,

[T]B′=P−1 [T]B P.[T]_{B'} = P^{-1}\, [T]_B\, P .

Proof

PP is the matrix of the identity map of VV from B′B'-coordinates to BB-coordinates, so [x]B=P[x]B′[x]_B = P[x]_{B'}; the matrix the other way is an inverse. Then [Tx]B′=P−1[Tx]B=P−1[T]B[x]B=P−1[T]BP [x]B′[Tx]_{B'} = P^{-1}[Tx]_B = P^{-1}[T]_B[x]_B = P^{-1}[T]_B P\,[x]_{B'} for all xx, and a matrix is determined by what it does to all coordinate vectors.

∎

Matrices AA and P−1APP^{-1}AP are called similar: they describe the same linear map in two coordinate systems. Everything intrinsic to the map — rank, determinant, trace, eigenvalues, characteristic polynomial — is the same for similar matrices.

ProofH

Determinants and invertibility

We use the following properties of the determinant, all derived from the permutation formula (see Axler, ch. 9, or Strang, ch. 5):

  1. det⁡\det is linear in each column when the other columns are fixed;
  2. it is alternating: if two columns are equal, det⁡A=0\det A = 0 (so swapping two columns changes the sign);
  3. det⁡I=1\det I = 1;
  4. it is multiplicative: det⁡(AB)=det⁡Adet⁡B\det(AB) = \det A \det B.

Properties 1 and 2 almost characterise the determinant. Let DD be any function of n×nn \times n matrices that is linear in each column and alternating. Expanding each column bj=∑ibijeib_j = \sum_i b_{ij} e_i of BB by multilinearity writes D(B)D(B) as a sum, over all functions ff from {1,…,n}\{1, \dots, n\} to itself, of bf(1)1⋯bf(n)n D(ef(1),…,ef(n))b_{f(1)1} \cdots b_{f(n)n}\, D(e_{f(1)}, \dots, e_{f(n)}). Alternation kills every term with ff not injective, and for a permutation σ\sigma the swaps that sort (eσ(1),…,eσ(n))(e_{\sigma(1)}, \dots, e_{\sigma(n)}) into (e1,…,en)(e_1, \dots, e_n) give D(eσ(1),…,eσ(n))=sgn⁡(σ) D(I)D(e_{\sigma(1)}, \dots, e_{\sigma(n)}) = \operatorname{sgn}(\sigma)\, D(I). Comparing with the permutation formula: D(B)=D(I)det⁡BD(B) = D(I) \det B. Property 4 follows: for fixed AA, the function D(B)=det⁡(AB)D(B) = \det(AB) is linear in each column of BB (the jj-th column of ABAB is AbjAb_j) and alternating (equal columns of BB give equal columns of ABAB), so det⁡(AB)=D(I)det⁡B=det⁡Adet⁡B\det(AB) = D(I)\det B = \det A \det B. Geometrically, ∣det⁡A∣|\det A| is the factor by which AA multiplies areas (n=2n = 2) or volumes (n=3n = 3), and the sign records orientation.

Theorem— Theorem (invertibility)

For an n×nn \times n matrix AA over a field, the following are equivalent:

  1. AA is invertible;
  2. Ax=0Ax = 0 only for x=0x = 0;
  3. the columns of AA are linearly independent;
  4. rank⁡A=n\operatorname{rank} A = n;
  5. det⁡A≠0\det A \neq 0.

Proof

(2 ⇔ 3) Ax=x1a1+⋯+xnanAx = x_1 a_1 + \cdots + x_n a_n where aja_j are the columns, so a non-zero solution of Ax=0Ax = 0 is exactly a dependence relation among the columns.

(2 ⇔ 4 ⇔ 1) By rank–nullity, dim⁡ker⁡A=0\dim\ker A = 0 iff rank⁡A=n\operatorname{rank} A = n; and by the corollary on injective maps, this holds iff x↦Axx \mapsto Ax is bijective. The inverse of a linear bijection is linear (apply the bijection to T−1u+T−1vT^{-1}u + T^{-1}v), and its matrix is an inverse of AA. Conversely an invertible AA is injective.

(1 ⇒ 5) det⁡A⋅det⁡A−1=det⁡(AA−1)=det⁡I=1\det A \cdot \det A^{-1} = \det(AA^{-1}) = \det I = 1, so det⁡A≠0\det A \ne 0.

(5 ⇒ 3) Contrapositive. If the columns are dependent, some column is a combination of the others: aq=∑j≠qcjaja_q = \sum_{j \ne q} c_j a_j. By linearity in column qq, det⁡A=∑j≠qcjdet⁡Aj\det A = \sum_{j \neq q} c_j \det A_j, where AjA_j is AA with column qq replaced by aja_j. Each AjA_j has two equal columns, so det⁡Aj=0\det A_j = 0 and det⁡A=0\det A = 0.

∎

For 2×22 \times 2 matrices, A−1=1ad−bc(d−b−ca)A^{-1} = \dfrac{1}{ad - bc}\begin{pmatrix} d & -b \\ -c & a \end{pmatrix}, which visibly needs ad−bc≠0ad - bc \ne 0.

ProofH

Eigenvalues and diagonalisation

Theorem— Proposition (eigenvalues are roots of the characteristic polynomial)

λ\lambda is an eigenvalue of the square matrix AA if and only if det⁡(λI−A)=0\det(\lambda I - A) = 0. Hence an n×nn \times n matrix has at most nn eigenvalues.

Proof

Av=λvAv = \lambda v for some v≠0v \ne 0 iff (λI−A)v=0(\lambda I - A)v = 0 has a non-zero solution, iff (invertibility theorem) det⁡(λI−A)=0\det(\lambda I - A) = 0. By the permutation formula, det⁡(tI−A)\det(tI - A) is a monic polynomial of degree nn in tt, so it has at most nn roots.

∎

The rotation (0−110)\begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix} has p(t)=t2+1p(t) = t^2 + 1: no real eigenvalues, but eigenvalues ±i\pm i over C\C. Over C\C every square matrix has an eigenvalue, by the fundamental theorem of algebra; this is one reason complex scalars are so useful.

Theorem— Theorem (eigenvectors for distinct eigenvalues are independent)

If v1,…,vmv_1, \dots, v_m are eigenvectors of T:V→VT : V \to V with pairwise distinct eigenvalues λ1,…,λm\lambda_1, \dots, \lambda_m, then v1,…,vmv_1, \dots, v_m are linearly independent.

Proof

Induction on mm. For m=1m = 1, v1≠0v_1 \ne 0 is independent. Let m≥2m \ge 2, assume the result for m−1m - 1, and suppose c1v1+⋯+cmvm=0c_1 v_1 + \cdots + c_m v_m = 0. Applying TT gives c1λ1v1+⋯+cmλmvm=0c_1 \lambda_1 v_1 + \cdots + c_m \lambda_m v_m = 0. Subtracting λm\lambda_m times the first relation,

c1(λ1−λm)v1+⋯+cm−1(λm−1−λm)vm−1=0.c_1(\lambda_1 - \lambda_m) v_1 + \cdots + c_{m-1}(\lambda_{m-1} - \lambda_m) v_{m-1} = 0 .

By the induction hypothesis every ci(λi−λm)=0c_i(\lambda_i - \lambda_m) = 0, and λi≠λm\lambda_i \neq \lambda_m, so c1=⋯=cm−1=0c_1 = \cdots = c_{m-1} = 0. Then cmvm=0c_m v_m = 0 with vm≠0v_m \neq 0, so cm=0c_m = 0.

∎

Theorem— Theorem (diagonalisability)

An n×nn \times n matrix AA over kk is diagonalisable if and only if knk^n has a basis of eigenvectors of AA; then P−1AP=DP^{-1}AP = D where the columns of PP are the eigenvectors and the diagonal of DD lists their eigenvalues. In particular, if AA has nn distinct eigenvalues in kk, it is diagonalisable.

Proof

Write p1,…,pnp_1, \dots, p_n for the columns of PP and D=diag⁡(d1,…,dn)D = \operatorname{diag}(d_1, \dots, d_n). The jj-th column of APAP is ApjAp_j and that of PDPD is djpjd_j p_j, so AP=PDAP = PD says exactly that Apj=djpjAp_j = d_j p_j for each jj. PP is invertible iff its columns form a basis (invertibility theorem), so "P−1AP=DP^{-1}AP = D with PP invertible" says exactly "the pjp_j are a basis of eigenvectors". With nn distinct eigenvalues, choose one eigenvector for each; they are independent by the previous theorem, and nn independent vectors in knk^n form a basis.

∎

More generally — by the same independence argument applied to eigenspaces — AA is diagonalisable if and only if the geometric multiplicities of its eigenvalues add up to nn.

Theorem— Proposition (a matrix that cannot be diagonalised)

N=(0100)N = \begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix} is not diagonalisable over any field.

Proof

pN(t)=t2p_N(t) = t^2, so 00 is the only eigenvalue, and E0=ker⁡N=span⁡(e1)E_0 = \ker N = \operatorname{span}(e_1) is one-dimensional: there is no basis of eigenvectors. Here is a second proof, the one formalised in Lean, that avoids eigenvectors. Suppose NP=PDNP = PD with PP invertible and DD diagonal. Since N2=0N^2 = 0,

PD2=(PD)D=NPD=N(PD)=N2P=0,PD^2 = (PD)D = NPD = N(PD) = N^2 P = 0,

so D2=0D^2 = 0 (multiply by P−1P^{-1}), so each diagonal entry did_i satisfies di2=0d_i^2 = 0, i.e. D=0D = 0. Then NP=0NP = 0, so N=0N = 0 — false.

∎

Example— Fibonacci numbers by diagonalisation

A=(1110)A = \begin{pmatrix} 1 & 1 \\ 1 & 0 \end{pmatrix} has pA(t)=t2−t−1p_A(t) = t^2 - t - 1, with distinct roots φ=1+52\varphi = \frac{1 + \sqrt5}{2} and ψ=1−52\psi = \frac{1 - \sqrt5}{2}, so it is diagonalisable over R\R. Since λ2=λ+1\lambda^2 = \lambda + 1 for both roots, A(λ1)=(λ+1λ)=λ(λ1)A\begin{pmatrix} \lambda \\ 1 \end{pmatrix} = \begin{pmatrix} \lambda + 1 \\ \lambda \end{pmatrix} = \lambda \begin{pmatrix} \lambda \\ 1 \end{pmatrix}. Write e1=15((φ1)−(ψ1))e_1 = \frac{1}{\sqrt5}\left(\begin{pmatrix} \varphi \\ 1 \end{pmatrix} - \begin{pmatrix} \psi \\ 1 \end{pmatrix}\right) (using φ−ψ=5\varphi - \psi = \sqrt5). Then

(Fn+1Fn)=Ane1=15(φn(φ1)−ψn(ψ1)),soFn=φn−ψn5.\begin{pmatrix} F_{n+1} \\ F_n \end{pmatrix} = A^n e_1 = \frac{1}{\sqrt5}\left(\varphi^n \begin{pmatrix} \varphi \\ 1 \end{pmatrix} - \psi^n \begin{pmatrix} \psi \\ 1 \end{pmatrix}\right), \qquad\text{so}\qquad F_n = \frac{\varphi^n - \psi^n}{\sqrt5}.

Since ∣ψ∣<1|\psi| < 1, ψn→0\psi^n \to 0 and Fn+1/Fn→φF_{n+1}/F_n \to \varphi: the eigenvector with the larger eigenvalue dominates. This is Binet's formula.

Formal mathematicsF

Linear algebra in Lean and Mathlib

Mathlib's linear algebra is written for modules over rings, and specialises to vector spaces over a field K: Module K V is the vector-space structure, V →ₗ[K] W the type of linear maps, LinearMap.ker and LinearMap.range the kernel and image, Module.finrank K V the dimension (as a natural number), and Matrix m n K the matrices, acting on vectors by A *ᵥ x. The lesson's module proves several results again from basic facts (independent) and cites the library for others.

Linear systems. The structure theorem is a two-line rewrite, exactly the human proof Tx−Tx0=T(x−x0)Tx - Tx_0 = T(x - x_0); the worked elimination is then checked in full: the solutions of x+2y+z=4x + 2y + z = 4, 2x+4y+3z=92x + 4y + 3z = 9 are precisely (3,0,1)+t(−2,1,0)(3, 0, 1) + t(-2, 1, 0), both directions of the "if and only if".

solutions_translate_kerLean 4Proved here from basic factsFormally verified
/-- **Solution sets are translates of the kernel.** If `x₀` is one solution of `f x = b`,
then `x` is a solution exactly when `x - x₀` lies in the kernel of `f`: the general solution is
"one particular solution plus the general solution of the homogeneous system". The proof is
the human one: `f x - f x₀ = f (x - x₀)` by linearity. -/
theorem solutions_translate_ker {K V W : Type*} [Field K] [AddCommGroup V] [Module K V]
    [AddCommGroup W] [Module K W] (f : V →ₗ[K] W) {x₀ : V} {b : W} (h₀ : f x₀ = b) (x : V) :
    f x = b ↔ x - x₀ ∈ LinearMap.ker f := by
  rw [LinearMap.mem_ker, map_sub, h₀, sub_eq_zero]
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/LinearAlgebra.leanTry it in the Lean web editor
systemMatrixLean 4Formally verified
/-- The coefficient matrix of the worked example in the lesson:
`x + 2y + z = 4`, `2x + 4y + 3z = 9` (two equations, three unknowns). -/
def systemMatrix : Matrix (Fin 2) (Fin 3) ℚ := !![1, 2, 1; 2, 4, 3]
Axioms used: propext, Quot.soundformal/Lumenary/LinearAlgebra.leanTry it in the Lean web editor
worked_systemLean 4Proved here from basic factsFormally verified
/-- **The worked Gaussian elimination, checked.** Elimination reduces the system to
`x + 2y = 3`, `z = 1` with `y` free, so the solutions are exactly
`(3, 0, 1) + t·(-2, 1, 0)`: a line, the translate of the one-dimensional null space by a
particular solution. Here `t` is the free variable `y`. -/
theorem worked_system (x : Fin 3 → ℚ) :
    systemMatrix *ᵥ x = ![4, 9] ↔ ∃ t : ℚ, x = ![3, 0, 1] + t • ![-2, 1, 0] := by
  constructor
  · intro h
    have h0 := congrFun h 0
    have h1 := congrFun h 1
    simp [systemMatrix, mulVec, dotProduct, Fin.sum_univ_three] at h0 h1
    refine ⟨x 1, ?_⟩
    funext i
    fin_cases i <;> simp <;> linarith
  · rintro ⟨t, rfl⟩
    funext i
    fin_cases i <;> simp [systemMatrix, mulVec, dotProduct, Fin.sum_univ_three] <;> ring
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/LinearAlgebra.leanTry it in the Lean web editor

Composition and matrices. Mathlib's Matrix.toLin' turns a matrix into the linear map x↦Axx \mapsto Ax; that it turns products into composites is the theorem of this lesson. Then two independent facts: the explicit non-commuting pair, and the rotation matrices composing by adding angles.

toLin_mulLean 4Applies a library theoremFormally verified
/-- **Composition is matrix multiplication.** The linear map of `M * N` is the composite
"first `N`, then `M`". This is Mathlib's `Matrix.toLin'_mul`; it is the reason matrix
multiplication is defined the way it is. -/
theorem toLin_mul {K : Type*} [Field K] {l m n : Type*} [Fintype m] [DecidableEq m]
    [Fintype n] [DecidableEq n] (M : Matrix l m K) (N : Matrix m n K) :
    Matrix.toLin' (M * N) = (Matrix.toLin' M).comp (Matrix.toLin' N) :=
  Matrix.toLin'_mul M N
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/LinearAlgebra.leanTry it in the Lean web editor
mul_not_commLean 4Proved here from basic factsFormally verified
/-- **Matrix multiplication is not commutative.** With `A = !![0, 1; 0, 0]` and
`B = !![0, 0; 1, 0]`, the top-left entries of `A * B` and `B * A` are `1` and `0`. -/
theorem mul_not_comm : ∃ A B : Matrix (Fin 2) (Fin 2) ℚ, A * B ≠ B * A := by
  refine ⟨!![0, 1; 0, 0], !![0, 0; 1, 0], fun h => ?_⟩
  have h00 := congrFun (congrFun h 0) 0
  simp [Matrix.mul_apply, Fin.sum_univ_two] at h00
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/LinearAlgebra.leanTry it in the Lean web editor
rotLean 4Formally verified
/-- The matrix of the rotation of the plane by the angle `θ`: its columns are the images
`(cos θ, sin θ)` and `(-sin θ, cos θ)` of the standard basis vectors. -/
noncomputable def rot (θ : ℝ) : Matrix (Fin 2) (Fin 2) ℝ :=
  !![Real.cos θ, -Real.sin θ; Real.sin θ, Real.cos θ]
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/LinearAlgebra.leanTry it in the Lean web editor
rot_mul_rotLean 4Proved here from basic factsFormally verified
/-- **Rotations compose by adding angles.** Rotating by `β` and then by `α` is rotating by
`α + β`. Multiplying the matrices entry by entry turns this into the addition formulas for
cosine and sine (`Real.cos_add`, `Real.sin_add`). -/
theorem rot_mul_rot (α β : ℝ) : rot α * rot β = rot (α + β) := by
  ext i j
  fin_cases i <;> fin_cases j <;>
    simp [rot, Matrix.mul_apply, Fin.sum_univ_two, Real.cos_add, Real.sin_add] <;> ring
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/LinearAlgebra.leanTry it in the Lean web editor

Dimension and rank–nullity come from the library, whose proofs follow the same route as ours (Mathlib proves rank–nullity via the isomorphism V/ker⁡T≅im⁡TV/\ker T \cong \operatorname{im} T, an equivalent formulation). The "more unknowns than equations" corollary is proved here from rank–nullity, mirroring the human proof line by line: bound the image by mm, subtract, and extract a non-zero vector from a subspace of positive dimension.

bases_same_cardLean 4Applies a library theoremFormally verified
/-- **Invariance of dimension.** Any two finite bases of a vector space have the same number
of elements. Both are equal to `Module.finrank K V` by Mathlib's `Module.finrank_eq_card_basis`,
whose proof rests on the exchange argument given in the lesson. -/
theorem bases_same_card {K V : Type*} [Field K] [AddCommGroup V] [Module K V]
    {ι ι' : Type*} [Fintype ι] [Fintype ι'] (b : Module.Basis ι K V) (b' : Module.Basis ι' K V) :
    Fintype.card ι = Fintype.card ι' :=
  (Module.finrank_eq_card_basis b).symm.trans (Module.finrank_eq_card_basis b')
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/LinearAlgebra.leanTry it in the Lean web editor
rank_nullityLean 4Applies a library theoremFormally verified
/-- **Rank–nullity.** For a linear map `f : V → W` with `V` finite-dimensional,
`dim (im f) + dim (ker f) = dim V`. This is Mathlib's `LinearMap.finrank_range_add_finrank_ker`. -/
theorem rank_nullity {K V W : Type*} [Field K] [AddCommGroup V] [Module K V]
    [AddCommGroup W] [Module K W] [FiniteDimensional K V] (f : V →ₗ[K] W) :
    Module.finrank K (LinearMap.range f) + Module.finrank K (LinearMap.ker f) =
      Module.finrank K V :=
  LinearMap.finrank_range_add_finrank_ker f
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/LinearAlgebra.leanTry it in the Lean web editor
exists_nonzero_solutionLean 4Proved here from basic factsFormally verified
/-- **More unknowns than equations.** A homogeneous system of `m` equations in `n > m`
unknowns has a non-zero solution. Proof from rank–nullity, as in the lesson:
`dim ker = n - dim im ≥ n - m > 0`, and a subspace of positive dimension contains a non-zero
vector. -/
theorem exists_nonzero_solution {K : Type*} [Field K] {m n : ℕ} (A : Matrix (Fin m) (Fin n) K)
    (h : m < n) : ∃ x : Fin n → K, x ≠ 0 ∧ A *ᵥ x = 0 := by
  have hrn := LinearMap.finrank_range_add_finrank_ker A.mulVecLin
  have him : Module.finrank K (LinearMap.range A.mulVecLin) ≤ m := by
    simpa using (LinearMap.range A.mulVecLin).finrank_le
  have hdim : Module.finrank K (Fin n → K) = n := by simp
  have hpos : 0 < Module.finrank K (LinearMap.ker A.mulVecLin) := by omega
  obtain ⟨x, hx, hx0⟩ := Submodule.exists_mem_ne_zero_of_ne_bot
    (Submodule.one_le_finrank_iff.mp hpos)
  exact ⟨x, hx0, by simpa using hx⟩
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/LinearAlgebra.leanTry it in the Lean web editor

Invertibility. Two of the equivalences of the invertibility theorem, from Mathlib. (A.col is the family of columns of A; IsUnit A means AA has a two-sided inverse.)

isUnit_iff_det_ne_zeroLean 4Applies a library theoremFormally verified
/-- **The determinant test.** A square matrix over a field is invertible if and only if its
determinant is non-zero. This combines Mathlib's `Matrix.isUnit_iff_isUnit_det` with the fact
that the units of a field are its non-zero elements. -/
theorem isUnit_iff_det_ne_zero {K n : Type*} [Field K] [Fintype n] [DecidableEq n]
    (A : Matrix n n K) : IsUnit A ↔ A.det ≠ 0 := by
  rw [Matrix.isUnit_iff_isUnit_det, isUnit_iff_ne_zero]
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/LinearAlgebra.leanTry it in the Lean web editor
cols_independent_iffLean 4Applies a library theoremFormally verified
/-- **The column test.** A square matrix over a field is invertible if and only if its
columns are linearly independent: Mathlib's `Matrix.linearIndependent_col_iff_isUnit`. -/
theorem cols_independent_iff {K n : Type*} [Field K] [Fintype n] [DecidableEq n]
    (A : Matrix n n K) : LinearIndependent K A.col ↔ IsUnit A :=
  Matrix.linearIndependent_col_iff_isUnit
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/LinearAlgebra.leanTry it in the Lean web editor

Eigenvectors. The two-eigenvector case of the independence theorem is proved exactly as on paper — apply TT, subtract λ\lambda times the relation, cancel — while the general statement is Mathlib's (proved there via the independence of the eigenspaces). Finally, the non-diagonalisability of NN, by the second proof above: PD2=N2P=0PD^2 = N^2P = 0, so D=0D = 0, so N=0N = 0.

eigen_pair_independentLean 4Proved here from basic factsFormally verified
/-- **Eigenvectors for distinct eigenvalues are independent** (two at a time). Suppose
`s • v + t • w = 0`. Applying `T` gives `s λ v + t μ w = 0`; subtracting `λ` times the first
equation leaves `t (μ - λ) w = 0`, so `t = 0` because `μ ≠ λ` and `w ≠ 0`; then `s v = 0`
forces `s = 0`. -/
theorem eigen_pair_independent {K V : Type*} [Field K] [AddCommGroup V] [Module K V]
    (T : V →ₗ[K] V) {v w : V} {lam mu : K} (hv : T v = lam • v) (hw : T w = mu • w)
    (hv0 : v ≠ 0) (hw0 : w ≠ 0) (hne : lam ≠ mu) : LinearIndependent K ![v, w] := by
  rw [LinearIndependent.pair_iff]
  intro s t hst
  -- Apply `T` to the relation.
  have hT : (s * lam) • v + (t * mu) • w = 0 := by
    have := congrArg T hst
    rw [map_add, map_smul, map_smul, hv, hw, map_zero, smul_smul, smul_smul] at this
    exact this
  -- Subtract `lam` times the relation.
  have hdiff : (t * (mu - lam)) • w = 0 := by
    have h2 : lam • (s • v + t • w) = 0 := by rw [hst, smul_zero]
    calc (t * (mu - lam)) • w
        = ((s * lam) • v + (t * mu) • w) - lam • (s • v + t • w) := by
          rw [smul_add, smul_smul, smul_smul, mul_sub, sub_smul]; abel_nf; module
      _ = 0 := by rw [hT, h2, sub_zero]
  have ht : t = 0 := by
    rcases smul_eq_zero.mp hdiff with h | h
    · rcases mul_eq_zero.mp h with h' | h'
      · exact h'
      · exact absurd (sub_eq_zero.mp h').symm hne
    · exact absurd h hw0
  refine ⟨?_, ht⟩
  rw [ht, zero_smul, add_zero] at hst
  rcases smul_eq_zero.mp hst with h | h
  · exact h
  · exact absurd h hv0
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/LinearAlgebra.leanTry it in the Lean web editor
eigenvectors_independentLean 4Applies a library theoremFormally verified
/-- **Eigenvectors for distinct eigenvalues are independent** (any number at a time). This is
Mathlib's `Module.End.eigenvectors_linearIndependent'`, proved there by showing that the
eigenspaces form an independent family of subspaces. -/
theorem eigenvectors_independent {K V ι : Type*} [Field K] [AddCommGroup V] [Module K V]
    (T : Module.End K V) (μ : ι → K) (hμ : Function.Injective μ) (v : ι → V)
    (hv : ∀ i, T.HasEigenvector (μ i) (v i)) : LinearIndependent K v :=
  T.eigenvectors_linearIndependent' μ hμ v hv
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/LinearAlgebra.leanTry it in the Lean web editor
nilpotent_not_diagonalisableLean 4Proved here from basic factsFormally verified
/-- **Not every matrix is diagonalisable.** The matrix `N = !![0, 1; 0, 0]` is not similar to
any diagonal matrix `D`: there is no invertible `P` with `N P = P D`. Proof from the lesson:
`N² = 0`, so `P D² = N² P = 0`, so `D² = 0` (cancel the invertible `P`), so every diagonal
entry of `D` is `0`; then `N P = P D = 0` and cancelling `P` again gives `N = 0`, which is
false. -/
theorem nilpotent_not_diagonalisable {K : Type*} [Field K] :
    ¬ ∃ (P : Matrix (Fin 2) (Fin 2) K) (d : Fin 2 → K),
      IsUnit P ∧ !![0, 1; 0, 0] * P = P * Matrix.diagonal d := by
  rintro ⟨P, d, hP, hNP⟩
  set N : Matrix (Fin 2) (Fin 2) K := !![0, 1; 0, 0] with hN
  have hNN : N * N = 0 := by
    ext i j
    fin_cases i <;> fin_cases j <;> simp [hN, Matrix.mul_apply, Fin.sum_univ_two]
  -- `P D² = 0`.
  have hPDD : P * (Matrix.diagonal d * Matrix.diagonal d) = 0 := by
    calc P * (Matrix.diagonal d * Matrix.diagonal d)
        = (P * Matrix.diagonal d) * Matrix.diagonal d := (Matrix.mul_assoc _ _ _).symm
      _ = (N * P) * Matrix.diagonal d := by rw [hNP]
      _ = N * (P * Matrix.diagonal d) := Matrix.mul_assoc _ _ _
      _ = N * (N * P) := by rw [hNP]
      _ = (N * N) * P := (Matrix.mul_assoc _ _ _).symm
      _ = 0 := by rw [hNN, Matrix.zero_mul]
  -- So `D² = 0`, hence `D = 0`.
  have hDD : Matrix.diagonal d * Matrix.diagonal d = 0 := (hP.mul_right_eq_zero).mp hPDD
  have hd : ∀ i, d i = 0 := by
    intro i
    have := congrFun (congrFun hDD i) i
    simpa [Matrix.diagonal_mul_diagonal] using this
  have hD : Matrix.diagonal d = 0 := by
    ext i j
    simp [Matrix.diagonal_apply, hd]
  -- Then `N P = 0`, hence `N = 0`: a contradiction.
  have hN0 : N = 0 := by
    have : N * P = 0 := by rw [hNP, hD, Matrix.mul_zero]
    exact (hP.mul_left_eq_zero).mp this
  have h01 := congrFun (congrFun hN0 0) 1
  simp [hN] at h01
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/LinearAlgebra.leanTry it in the Lean web editor

Not formalised here: the exchange lemma itself (it is inside Mathlib's proof that finrank is well defined), the permutation formula and multiplicativity of the determinant (Mathlib's Matrix.det and Matrix.det_mul), and Binet's formula (Mathlib has it as Real.coe_fib_eq).

ComputationC

Elimination by machine, and a census of matrices

Gaussian elimination is an algorithm, and computers run it billions of times a day. In floating-point arithmetic a tiny rounding error can turn a zero into 10−1710^{-17} and create a spurious pivot, so the rank of a matrix is numerically delicate. The first experiment works with exact fractions instead: it row-reduces the worked example, reads off the null space, and checks rank–nullity on 300 random integer matrices whose rank is controlled by building them as products of an m×rm \times r and an r×nr \times n matrix.

Exact Gaussian elimination and rank-nullityPythonExact computationExperimental evidenceComputationally tested
"""Gaussian elimination in exact arithmetic, and rank-nullity on many matrices.

The experiment row-reduces matrices with Python fractions, so every step is
exact: no rounding errors can create or destroy a pivot. It reduces the worked
example of the lesson, reads off a basis of the null space from the free
columns, and then checks rank + nullity = number of columns on a few hundred
random integer matrices whose rank is known in advance (they are built as a
product of an m x r and an r x n matrix). This is exact computation on finitely
many cases: evidence for the theorem, not a proof of it.
"""

import random
from fractions import Fraction

def rref(matrix):
    """Return (R, pivots): the reduced row echelon form and pivot columns."""
    rows = [[Fraction(x) for x in row] for row in matrix]
    m = len(rows)
    n = len(rows[0]) if m else 0
    pivots = []
    r = 0
    for c in range(n):
        p = next((i for i in range(r, m) if rows[i][c] != 0), None)
        if p is None:
            continue
        rows[r], rows[p] = rows[p], rows[r]
        lead = rows[r][c]
        rows[r] = [x / lead for x in rows[r]]
        for i in range(m):
            if i != r and rows[i][c] != 0:
                factor = rows[i][c]
                rows[i] = [a - factor * b for a, b in zip(rows[i], rows[r])]
        pivots.append(c)
        r += 1
        if r == m:
            break
    return rows, pivots

def rank(matrix):
    """The number of pivots in the reduced row echelon form."""
    return len(rref(matrix)[1])

def null_space(matrix):
    """A basis of {x : Ax = 0}, one vector per free column."""
    reduced, pivots = rref(matrix)
    n = len(matrix[0])
    basis = []
    for free in (c for c in range(n) if c not in pivots):
        v = [Fraction(0)] * n
        v[free] = Fraction(1)
        for row, p in zip(reduced, pivots):
            v[p] = -row[free]
        basis.append(v)
    return basis

def mat_vec(matrix, v):
    """The product A v."""
    return [sum(Fraction(a) * x for a, x in zip(row, v)) for row in matrix]

def mat_mul(a, b):
    """The product of two matrices given as lists of rows."""
    return [[sum(x * y for x, y in zip(row, col)) for col in zip(*b)]
            for row in a]

def random_matrix_of_rank(rng, m, n, r):
    """An m x n integer matrix (B C with B m x r, C r x n); rank <= r."""
    b = [[rng.randint(-4, 4) for _ in range(r)] for _ in range(m)]
    c = [[rng.randint(-4, 4) for _ in range(n)] for _ in range(r)]
    return mat_mul(b, c)

def check_rank_nullity(matrix):
    """True if rank + nullity = n and every null vector solves Ax = 0."""
    basis = null_space(matrix)
    solves = all(all(x == 0 for x in mat_vec(matrix, v)) for v in basis)
    return solves and rank(matrix) + len(basis) == len(matrix[0])

def fmt(v):
    """Format a vector of fractions compactly."""
    return "(" + ", ".join(str(x) for x in v) + ")"

def main():
    a = [[1, 2, 1], [2, 4, 3]]
    augmented = [[1, 2, 1, 4], [2, 4, 3, 9]]
    reduced, pivots = rref(augmented)
    print("Worked example: x + 2y + z = 4, 2x + 4y + 3z = 9")
    print("RREF of the augmented matrix [A | b]:")
    for row in reduced:
        print(f"   {fmt(row)}")
    print(f"pivot columns {pivots}: x and z are pivots, y is free")
    print(f"rank of A = {rank(a)}, nullity = {len(null_space(a))}, n = 3")
    print("null space basis:", ", ".join(fmt(v) for v in null_space(a)))
    print("so the solutions form the line (3, 0, 1) + t(-2, 1, 0).")
    print()
    rng = random.Random(2024)
    trials, ok, exact_rank = 0, 0, 0
    deficit = {}
    for _ in range(300):
        m, n = rng.randint(2, 6), rng.randint(2, 7)
        r = rng.randint(1, min(m, n))
        mat = random_matrix_of_rank(rng, m, n, r)
        trials += 1
        ok += check_rank_nullity(mat)
        k = rank(mat)
        exact_rank += k == r
        deficit[r - k] = deficit.get(r - k, 0) + 1
    print(f"Random integer matrices B*C of rank at most r: {trials}")
    print(f"  rank + nullity = n and A v = 0 checked: {ok} of {trials}")
    print(f"  rank came out exactly r: {exact_rank} of {trials}")
    print(f"  rank deficit r - rank -> count: {dict(sorted(deficit.items()))}")
    print("A random product usually has full rank r; a deficit happens when")
    print("the small random factors are accidentally dependent.")
    print()
    print("Epistemic status: exact rational arithmetic, so each case is a")
    print("genuine check with no rounding; but 300 matrices are finitely many")
    print("examples. Rank-nullity itself is proved in the lesson and in Lean.")

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

The second experiment asks how common diagonalisability is. For a real 2×22 \times 2 matrix the answer is decided by the discriminant (tr⁡A)2−4det⁡A(\operatorname{tr} A)^2 - 4\det A of pAp_A: positive gives two distinct real eigenvalues (diagonalisable over R\R), negative gives a pair of complex conjugate eigenvalues (diagonalisable over C\C only), and zero gives a repeated eigenvalue λ\lambda, in which case AA is diagonalisable only if it already equals λI\lambda I (if P−1AP=λIP^{-1}AP = \lambda I then A=P(λI)P−1=λIA = P(\lambda I)P^{-1} = \lambda I). It counts all 625 matrices with entries from −2-2 to 22, then diagonalises the Fibonacci matrix symbolically.

Diagonalisable or not: 625 matrices and the Fibonacci numbersPythonExhaustive finite checkSymbolic computationComputationally tested
"""Which 2 x 2 matrices can be diagonalised? An exhaustive count, and Fibonacci.

Part 1 classifies every 2 x 2 matrix with entries in {-2, ..., 2} (625 of
them) by its characteristic polynomial t^2 - (tr A) t + det A. Two distinct
real eigenvalues: diagonalisable over R. Non-real eigenvalues: diagonalisable
over C only. A repeated eigenvalue: diagonalisable only if A is already the
scalar matrix lambda I. Part 2 diagonalises the Fibonacci matrix with SymPy and
checks Binet's formula exactly for n <= 40. Part 3 shows SymPy's view of the
nilpotent matrix with rows (0, 1), (0, 0): one eigenvalue of algebraic
multiplicity 2 but only one independent eigenvector.
"""

import itertools

import sympy

def classify(a, b, c, d):
    """Classify [[a, b], [c, d]] by its eigenvalues.

    Returns 'distinct real', 'complex', 'scalar' or 'defective'.
    """
    trace, det = a + d, a * d - b * c
    disc = trace * trace - 4 * det
    if disc > 0:
        return "distinct real"
    if disc < 0:
        return "complex"
    return "scalar" if (b == 0 and c == 0 and a == d) else "defective"

def census(values):
    """Count the classes over all matrices with entries in ``values``."""
    counts = {"distinct real": 0, "complex": 0, "scalar": 0, "defective": 0}
    for a, b, c, d in itertools.product(values, repeat=4):
        counts[classify(a, b, c, d)] += 1
    return counts

def fibonacci(n):
    """F_0 = 0, F_1 = 1, F_{k+1} = F_k + F_{k-1}, by iteration."""
    x, y = 0, 1
    for _ in range(n):
        x, y = y, x + y
    return x

def binet(n):
    """(phi^n - psi^n) / sqrt(5) as an exact SymPy number."""
    s5 = sympy.sqrt(5)
    phi, psi = (1 + s5) / 2, (1 - s5) / 2
    return sympy.expand((phi**n - psi**n) / s5)

def fibonacci_by_diagonalising(n):
    """The top-right entry of A^n = P D^n P^-1 for A = [[1, 1], [1, 0]]."""
    p, d = sympy.Matrix([[1, 1], [1, 0]]).diagonalize()
    power = p * sympy.diag(d[0, 0] ** n, d[1, 1] ** n) * p.inv()
    return sympy.radsimp(sympy.expand(power[0, 1]))

def multiplicities(rows):
    """[(eigenvalue, algebraic, geometric)] for a SymPy matrix."""
    return [(val, alg, len(vecs))
            for val, alg, vecs in sympy.Matrix(rows).eigenvects()]

def main():
    counts = census(range(-2, 3))
    print("All 625 matrices [[a, b], [c, d]] with entries in -2..2:")
    for label, count in counts.items():
        print(f"  {label:<14} {count:>4}")
    print("  diagonalisable over R:", counts["distinct real"] + counts["scalar"])
    print("  diagonalisable over C:", 625 - counts["defective"])
    print()
    p, d = sympy.Matrix([[1, 1], [1, 0]]).diagonalize()
    print("Fibonacci matrix A = [[1, 1], [1, 0]] = P D P^-1 with")
    print("  D =", list(d.diagonal()))
    print("  A^n = P D^n P^-1, so F_n = (phi^n - psi^n) / sqrt 5")
    ok = all(binet(n) == fibonacci(n) for n in range(41))
    print(f"  Binet's formula equals iteration for n = 0..40: {ok}")
    print(f"  F_40 from A^40 = P D^40 P^-1: {fibonacci_by_diagonalising(40)}")
    print()
    print("N = [[0, 1], [0, 0]]: (eigenvalue, algebraic, geometric) =",
          multiplicities([[0, 1], [0, 0]]))
    print("One independent eigenvector in a 2-dimensional space: N is not")
    print("diagonalisable, exactly as the lesson (and Lean) proves.")
    print()
    print("Epistemic status: part 1 is an exhaustive check of 625 cases using")
    print("the lesson's criterion; part 2 is exact symbolic arithmetic for")
    print("n <= 40 only (the lesson proves Binet's formula for all n); part 3")
    print("trusts SymPy's eigenvector routine, which agrees with the proof.")

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

Notice that the defective matrices are rare (56 of 625) — they satisfy the polynomial equation "discriminant =0= 0" — while the matrices with complex eigenvalues are not rare at all: they fill an open region. The topologist's viewpoint below explains why this is the expected picture.

Explore

Explore: eigenvectors and the order of composition

The dashed lines are the eigenvector directions: the map slides points along them, stretching by the eigenvalue. Start from the symmetric matrix below (eigenvalues 33 and 11, eigenvectors along y=xy = x and y=−xy = -x), then try the shear (one invariant line only: defective) and the rotation (none).

Eigenvectors are invariant lines

Which presets have two invariant lines, one, or none?

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.

Composition: first a shear, then a quarter turn — or the other way round. The two results differ, which is the non-commutativity of matrix multiplication made visible.

AB is not BA

Apply A and then B, or B and then A, and compare the results.

Entries of the matrix A
A =
Entries of the matrix B
B =
First A, then B: the matrix BA
BA =
0−111
First B, then A: the matrix AB
AB =
1−110
  • image of the grid
  • image of the unit square
  • image of the flag
  • before the transformation
  • after the first step

AB ≠ BA: the order matters.

BA means “apply A first, then B”: products of transformations are read from right to left.

det(AB) = det(BA) = det A · det B = 1 · 1 = 1 The area scale factor is the same in either order.

Exercises

Exercises

1. Linear algebra

Warm-upHuman

What is the rank of the matrix (123246101)\begin{pmatrix} 1 & 2 & 3 \\ 2 & 4 & 6 \\ 1 & 0 & 1 \end{pmatrix}?

2. Linear algebra

Warm-upHuman

Which of these are subspaces of the given vector space? (Choose all that apply.)

Choose all that apply

3. Linear algebra

CoreHuman

A linear map T:R7→R4T : \R^7 \to \R^4 is surjective. What is dim⁡ker⁡T\dim \ker T?

4. Linear algebra

CoreHuman

AA is a 3×33 \times 3 matrix with det⁡A=5\det A = 5. What is det⁡(2A)\det(2A)?

5. Linear algebra

CoreHuman

Which of these real matrices are diagonalisable over R\R? (Choose all that apply.)

Choose all that apply

6. Linear algebra

CoreHuman

In the proof that eigenvectors v1,…,vmv_1, \dots, v_m with distinct eigenvalues are independent, we reach ci(λi−λm)=0c_i(\lambda_i - \lambda_m) = 0 for i<mi < m. Which fact lets us conclude ci=0c_i = 0?

Choose one

7. Linear algebra

StretchHuman

For a linear map T:V→VT : V \to V we proved: if VV is finite-dimensional, then TT injective ⇒\Rightarrow TT surjective. Which example shows that the finite-dimensionality hypothesis cannot be dropped?

Choose one

8. Linear algebra

CoreFormal

Let f : V →ₗ[K] W with [FiniteDimensional K V]. Which Lean statement correctly formalises the rank–nullity theorem?

Choose one

9. Linear algebra

StretchComputational

Write rank(rows) that returns the rank of a matrix (a list of rows of integers) by Gaussian elimination with exact Fraction arithmetic. Then use it to check rank–nullity on the photosynthesis matrix: its null space should be one-dimensional.

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

Common misconceptions

Misconception

"Matrix multiplication is commutative, like multiplying numbers." ABAB means "first BB, then AA", and doing two transformations in the other order usually gives a different result: shear-then-rotate is not rotate-then-shear. Even when both ABAB and BABA are defined they can differ, as (0100)\begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix} and (0010)\begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix} show. Some special families commute (diagonal matrices; rotations of the plane), and that is worth noticing when it happens.

Misconception

"Every square matrix is diagonalisable." (0100)\begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix} is not, over any field: its only eigenvalue is 00 and its eigenvectors fill only a line. Over R\R, rotations are not diagonalisable either, for a different reason — no real eigenvalues. What is true: over C\C, every matrix is similar to an upper triangular one, and to a Jordan normal form (see advanced linear algebra); and matrices with distinct eigenvalues are diagonalisable.

Misconception

"A linear map sends lines through the origin to lines." It sends them to lines or to the single point 00. The projection (x,y)↦(x,0)(x, y) \mapsto (x, 0) collapses the yy-axis. A linear map preserves lines exactly when it is injective, i.e. when its kernel is {0}\{0\}.

Misconception

"det⁡(A+B)=det⁡A+det⁡B\det(A + B) = \det A + \det B." The determinant is multiplicative, not additive: det⁡I+det⁡I=2\det I + \det I = 2 but det⁡(2I)=2n\det(2I) = 2^n for n×nn \times n matrices. In general det⁡(cA)=cndet⁡A\det(cA) = c^n \det A.

Misconception

"The zero vector is an eigenvector of every matrix." A0=λ0A0 = \lambda 0 for every λ\lambda, which is exactly why eigenvectors are required to be non-zero — otherwise every scalar would be an "eigenvalue". (The eigenspace EλE_\lambda does contain 00.)

Misconception

"Vectors no two of which are parallel are independent." In R2\R^2, the vectors (1,0)(1, 0), (0,1)(0, 1) and (1,1)(1, 1) are pairwise non-parallel but dependent: the third is the sum of the first two. Independence is about the whole list, not pairs.

ViewpointsH

Many ways of seeing

Geometry— Linear maps are geometry: area, orientation, principal axes

For a linear map TT of Rn\R^n and any region RR with a volume, vol⁡(T(R))=∣det⁡T∣ vol⁡(R)\operatorname{vol}(T(R)) = |\det T|\,\operatorname{vol}(R); the sign of det⁡T\det T says whether TT preserves or reverses orientation (the flag in the widget). The matrices preserving lengths are the orthogonal matrices, QTQ=IQ^{\mathsf T} Q = I; they have det⁡Q=±1\det Q = \pm 1 and in the plane they are exactly the rotations and reflections in lines through the origin. A real symmetric matrix (AT=AA^{\mathsf T} = A) is always diagonalisable by an orthogonal matrix — the spectral theorem. Geometrically: the curve xTAx=1x^{\mathsf T} A x = 1 is a conic whose axes are the eigenvector directions of AA; it is an ellipse when both eigenvalues are positive and a hyperbola when they have opposite signs. For instance 5x2+4xy+2y2=15x^2 + 4xy + 2y^2 = 1 has eigenvalues 66 and 11, so it is an ellipse with semi-axes 1/61/\sqrt6 and 11 along the eigenvectors (2,1)(2, 1) and (−1,2)(-1, 2). See conic sections and, for Klein's view of geometry through groups of matrices, transformation geometry.

Topology— Two kinds of invertible matrix, and why generic matrices are diagonalisable

The set GLn(R)GL_n(\R) of invertible real matrices is an open subset of Rn2\R^{n^2} (it is where the continuous function det⁡\det is non-zero), and it has exactly two path components: det⁡>0\det > 0 and det⁡<0\det < 0. One cannot continuously deform a reflection into the identity through invertible matrices, because along the path det⁡\det would have to pass through 00 (intermediate value theorem). This is the topological meaning of orientation. By contrast GLn(C)GL_n(\C) is connected: the complex numbers ≠0\neq 0 form a connected set, and one can always steer around the zeros of det⁡\det.

Over C\C, the matrices with nn distinct eigenvalues are those where the discriminant of pAp_A — a polynomial in the entries — is non-zero; this set is open and dense, so every complex matrix is a limit of diagonalisable ones, and "being defective" is a closed condition of measure zero. The census in the computation section shows the shadow of this: defective matrices are rare. Over R\R, however, the set with non-real eigenvalues is open too, so real diagonalisability is not generic. See matrix groups.

Analysis— The derivative is a linear map; infinite dimensions are different

Multivariable calculus is linear algebra applied locally: the derivative of f:Rn→Rmf : \R^n \to \R^m at a point is the linear map that best approximates ff nearby, its matrix is the Jacobian, and the chain rule D(g∘f)=Dg⋅DfD(g \circ f) = Dg \cdot Df is the theorem "composition is matrix multiplication" (see multivariable calculus). The linear system x′=Axx' = Ax of differential equations is solved by x(t)=etAx(0)x(t) = e^{tA}x(0), and if A=PDP−1A = PDP^{-1} then etA=PetDP−1e^{tA} = P e^{tD} P^{-1}, so the eigenvalues decide stability: all real parts negative means every solution decays.

In infinite dimensions linear algebra becomes functional analysis, and some theorems change: the shift operator on sequences is injective but not surjective, so rank–nullity has no direct analogue, and an operator can have no eigenvalues at all while still having a "spectrum". Fourier series are coordinates with respect to the orthonormal basis einxe^{inx} of a space of functions (see functional analysis).

Algebra— Vector spaces are modules over a field — and fields are what make bases exist

Replace the field kk by a ring RR and the same axioms define an RR-module. Much of this lesson then breaks: the Z\Z-module Z/2Z\Z/2\Z has no basis at all (every element xx satisfies 2x=02x = 0, a non-trivial relation), and in Z\Z the list (2)(2) is linearly independent but cannot be extended to a basis — the only bases of Z\Z are (1)(1) and (−1)(-1). The proofs of the exchange lemma and of the extension corollary divided by non-zero scalars — that is where fields are essential. Over a principal ideal domain such as Z\Z there is a substitute, the Smith normal form, which classifies finitely generated abelian groups (see modules).

Algebra also asks which matrix identities hold universally. The Cayley–Hamilton theorem says pA(A)=0p_A(A) = 0: for the Fibonacci matrix, A2=A+IA^2 = A + I. And a representation of a group GG is a homomorphism G→GL(V)G \to GL(V) — linear algebra used to study symmetry, which is the subject of representation theory.

Physics— Normal modes and quantum measurements are eigenvectors

Two equal masses mm joined to each other and to two walls by three equal springs (stiffness κ\kappa) obey mx¨=−κKxm\ddot x = -\kappa K x with K=(2−1−12)K = \begin{pmatrix} 2 & -1 \\ -1 & 2 \end{pmatrix}. The eigenvectors of KK are (1,1)(1, 1) (eigenvalue 11) and (1,−1)(1, -1) (eigenvalue 33): the normal modes, in which the masses swing together with frequency κ/m\sqrt{\kappa/m} or against each other with frequency 3κ/m\sqrt{3\kappa/m}. Every motion is a superposition of the two — a change of basis to eigen-coordinates decouples the equations. The same mathematics describes molecular vibrations and the modes of a bridge.

In quantum mechanics a state is a vector in a complex vector space, a measurable quantity is a self-adjoint operator, and the possible results of a measurement are its eigenvalues — real, by the spectral theorem. The word "eigen" entered physics through this route (see quantum mechanics).

Category theory— Vect, and matrices as morphisms

Vector spaces over kk and linear maps form a category Vectk\cat{Vect}_k: composites of linear maps are linear and identities are linear (see categories). Choosing bases shows that the full subcategory of finite-dimensional spaces is equivalent to a strikingly simple category Matk\cat{Mat}_k: its objects are the natural numbers 0,1,2,…0, 1, 2, \dots, a morphism n→mn \to m is an m×nm \times n matrix, and composition is matrix multiplication. The theorem "composition is matrix multiplication" is precisely the statement that this is a functor, and invariance of dimension says that isomorphic objects of Vectk\cat{Vect}_k go to the same number. Change of basis is the freedom in choosing this equivalence.

History & global context

History and global context

  • China. Chapter 8 of The Nine Chapters on the Mathematical Art (compiled by about the 1st century CE), titled fangcheng ("rectangular arrays"), solves systems with as many as six unknowns by arranging the coefficients on a counting board and eliminating column by column — essentially Gaussian elimination, with negative numbers handled by coloured rods. Liu Hui's commentary (263 CE) explains the method.
  • Japan and Europe, 1680s–1690s. Determinants appear independently in the work of Seki Takakazu (1683), in the context of eliminating unknowns from polynomial equations, and of Gottfried Wilhelm Leibniz (1693). Gabriel Cramer published his rule for solving square systems in 1750.
  • Gauss used systematic elimination in his least-squares calculations of asteroid orbits in the early nineteenth century; the name "Gaussian elimination" is a later, Western attribution for a method known in China some 1,700 years earlier.
  • The nineteenth century. Hermann Grassmann's Ausdehnungslehre (1844) developed linear combinations, independence and dimension in a geometric language that was decades ahead of its time. James Joseph Sylvester coined the word matrix (1850), and Arthur Cayley's Memoir on the theory of matrices (1858) introduced matrix algebra, including the Cayley–Hamilton theorem. Camille Jordan gave his normal form in 1870.
  • Axioms. Giuseppe Peano gave an axiomatic definition of a vector space in 1888. The prefix eigen- ("own, characteristic") comes from David Hilbert's work on integral equations around 1904.
  • Computation. Numerical linear algebra became a discipline with electronic computers; Alan Turing (1948) and James Wilkinson analysed rounding errors in elimination, and today large-scale eigenvector computations rank web pages and train machine-learning models.
Further reading

Further reading

  • Sheldon Axler, Linear Algebra Done Right (1996; 4th ed. 2024) — a clean, determinant-light treatment of vector spaces, linear maps and eigenvalues.
  • Gilbert Strang, Introduction to Linear Algebra (1993; 6th ed. 2023) — matrices, elimination and applications, with a strong geometric and computational flavour.
  • Paul R. Halmos, Finite-Dimensional Vector Spaces (1942; 2nd ed. 1958) — the classic coordinate-free account.
  • Kenneth Hoffman and Ray Kunze, Linear Algebra (1961; 2nd ed. 1971) — thorough, including determinants and canonical forms.
  • Lloyd N. Trefethen and David Bau, Numerical Linear Algebra (1997) — what happens to these algorithms on a real computer.