Linear Algebra 02 defined a vector space with only addition and scaling: an abstract vector space has no lengths and no angles until you add them. This post adds them with an inner product — the dot product of Rn\mathbb{R}^n is the model — and three big results follow. Orthogonal projection gives the best approximation from a subspace, which is the whole theory of least squares. The spectral theorem says every real symmetric matrix is diagonal in an orthonormal basis — the eigen-story of Linear Algebra 04 with no defective cases and perpendicular eigenvectors. And the singular value decomposition extends that to every matrix, square or not: any linear map is a rotation, a stretch along perpendicular axes, and another rotation. The SVD gives the best low-rank approximation, the pseudoinverse and principal component analysis. This is the last post of the base series; a table at the end lists planned extensions.

Series map: 00 Vectors & Linear Systems → 01 Matrix Algebra, Inverses & LU → 02 Vector Spaces, Basis & Dimension → 03 Linear Maps, Change of Basis & Determinants → 04 Eigenvalues & Diagonalization → 05 Inner Products, Spectral Theorem & SVD (this post).


Learning Outcome

  • State the inner product axioms, and prove the Cauchy–Schwarz and triangle inequalities.
  • Use orthonormal bases: coordinates by inner products, Pythagoras, Parseval.
  • Project onto a subspace, prove the best-approximation property, and run Gram–Schmidt to get A=QRA = QR.
  • Solve least-squares problems with the normal equations and with QR, and fit a line to data.
  • Recognise orthogonal matrices, state the spectral theorem, and sketch its proof.
  • Test a symmetric matrix for positive definiteness in four equivalent ways, and find the principal axes of a quadratic form.
  • State the SVD, compute it for a 2×22 \times 2 example, and read it geometrically as rotate–stretch–rotate.
  • Use the SVD for norms, condition numbers, best low-rank approximation (Eckart–Young), the pseudoinverse and PCA.

Chapter 1 — Inner products and norms

Terminology

  • Inner product on a real vector space VV — a function ⟨u,v⟩∈R\langle u, v\rangle \in \mathbb{R} that is symmetric, linear in each argument, and positive definite (axioms below).
  • Inner product space — a vector space together with an inner product.
  • Norm ∥v∥=⟨v,v⟩\lVert v\rVert = \sqrt{\langle v, v\rangle} — the length of vv. A unit vector has norm 1.
  • Orthogonal — ⟨u,v⟩=0\langle u, v\rangle = 0, written u⊥vu \perp v.
  • Orthonormal list — pairwise orthogonal unit vectors.
  • Orthogonal complement W⊥={v:⟨v,w⟩=0 for all w∈W}W^\perp = \{v : \langle v, w\rangle = 0 \text{ for all } w \in W\}.
  • Orthogonal matrix — a square real matrix QQ with QTQ=IQ^TQ = I.

Axioms and examples

An inner product on a real vector space satisfies, for all u,v,wu, v, w and scalars cc:

  1. Symmetry: ⟨u,v⟩=⟨v,u⟩\langle u, v\rangle = \langle v, u\rangle.
  2. Linearity: ⟨u+cv,w⟩=⟨u,w⟩+c⟨v,w⟩\langle u + cv, w\rangle = \langle u, w\rangle + c\langle v, w\rangle (and so, by symmetry, linear in the second slot too).
  3. Positive definiteness: ⟨v,v⟩≥0\langle v, v\rangle \ge 0, with equality only for v=0v = 0.

Examples:

  • Dot product on Rn\mathbb{R}^n: ⟨x,y⟩=xTy=∑xiyi\langle x, y\rangle = x^Ty = \sum x_i y_i. This is the default in this post.
  • Weighted dot product: ⟨x,y⟩=∑wixiyi\langle x, y\rangle = \sum w_i x_i y_i with all wi>0w_i > 0. More generally ⟨x,y⟩=xTMy\langle x, y\rangle = x^TMy for any symmetric positive definite MM (Chapter 6).
  • Functions: on C[0,1]C[0,1], ⟨f,g⟩=∫01f(t)g(t) dt\langle f, g\rangle = \int_0^1 f(t)g(t)\,dt. For example ⟨1,t−12⟩=∫01(t−12) dt=0\langle 1, t - \tfrac12\rangle = \int_0^1 (t - \tfrac12)\,dt = 0: the constant 1 and t−12t - \frac12 are orthogonal, and ∥t−12∥2=112\lVert t - \tfrac12\rVert^2 = \frac{1}{12}.
  • Matrices: ⟨A,B⟩=tr⁡(ATB)=∑i,jaijbij\langle A, B\rangle = \operatorname{tr}(A^TB) = \sum_{i,j} a_{ij}b_{ij} (the Frobenius inner product).

Over C\mathbb{C} the symmetry axiom becomes ⟨u,v⟩=⟨v,u⟩‾\langle u, v\rangle = \overline{\langle v, u\rangle} and the standard product is ∑xiyi‾\sum x_i \overline{y_i}; everything below has a complex version with ATA^T replaced by the conjugate transpose A∗A^*.

Cauchy–Schwarz and the triangle inequality

Theorem 1 (Cauchy–Schwarz). ∣⟨u,v⟩∣≤∥u∥ ∥v∥\lvert\langle u, v\rangle\rvert \le \lVert u\rVert\,\lVert v\rVert, with equality if and only if uu and vv are linearly dependent.

Proof. If v=0v = 0 both sides are 0. Otherwise, for every real tt,

0≤∥u−tv∥2=∥u∥2−2t⟨u,v⟩+t2∥v∥2.0 \le \lVert u - tv\rVert^2 = \lVert u\rVert^2 - 2t\langle u, v\rangle + t^2\lVert v\rVert^2.

A quadratic in tt with positive leading coefficient that is never negative has at most one real root, so its discriminant is ≤0\le 0: 4⟨u,v⟩2−4∥u∥2∥v∥2≤04\langle u, v\rangle^2 - 4\lVert u\rVert^2\lVert v\rVert^2 \le 0. Equality means the discriminant is 0, so for some tt the quadratic is 0, that is u=tvu = tv; conversely u=tvu = tv gives equality directly. ∎

Cauchy–Schwarz makes angles possible: define θ∈[0,π]\theta \in [0, \pi] by cos⁡θ=⟨u,v⟩∥u∥∥v∥\cos\theta = \frac{\langle u, v\rangle}{\lVert u\rVert\lVert v\rVert}, a number in [−1,1][-1, 1]. Example: u=(1,2,2)u = (1, 2, 2), v=(3,0,4)v = (3, 0, 4) have u⋅v=11u \cdot v = 11, ∥u∥=3\lVert u\rVert = 3, ∥v∥=5\lVert v\rVert = 5, so cos⁡θ=11/15\cos\theta = 11/15 and θ≈42.8°\theta \approx 42.8°.

Theorem 2 (triangle inequality). ∥u+v∥≤∥u∥+∥v∥\lVert u + v\rVert \le \lVert u\rVert + \lVert v\rVert.

Proof. ∥u+v∥2=∥u∥2+2⟨u,v⟩+∥v∥2≤∥u∥2+2∥u∥∥v∥+∥v∥2=(∥u∥+∥v∥)2\lVert u + v\rVert^2 = \lVert u\rVert^2 + 2\langle u, v\rangle + \lVert v\rVert^2 \le \lVert u\rVert^2 + 2\lVert u\rVert\lVert v\rVert + \lVert v\rVert^2 = (\lVert u\rVert + \lVert v\rVert)^2, using Cauchy–Schwarz in the middle. Take square roots. ∎

The same expansion gives Pythagoras: if u⊥vu \perp v then ∥u+v∥2=∥u∥2+∥v∥2\lVert u + v\rVert^2 = \lVert u\rVert^2 + \lVert v\rVert^2.


Chapter 2 — Orthogonality and projection

Orthonormal bases

Proposition 3. An orthogonal list of nonzero vectors is linearly independent.

Proof. If ∑civi=0\sum c_i v_i = 0, take the inner product with vjv_j: every term except cj⟨vj,vj⟩c_j\langle v_j, v_j\rangle vanishes, so cj∥vj∥2=0c_j\lVert v_j\rVert^2 = 0 and cj=0c_j = 0. ∎

The same computation shows why orthonormal bases are so convenient. If q1,…,qnq_1, \dots, q_n is an orthonormal basis, then for every vv:

v=∑i=1n⟨v,qi⟩ qi,∥v∥2=∑i=1n⟨v,qi⟩2.v = \sum_{i=1}^n \langle v, q_i\rangle\, q_i, \qquad \lVert v\rVert^2 = \sum_{i=1}^n \langle v, q_i\rangle^2.

Coordinates are just inner products — no linear system to solve. The second formula is Parseval's identity.

Orthogonal projection onto a subspace

Let WW be a subspace with orthonormal basis q1,…,qkq_1, \dots, q_k. The orthogonal projection of vv onto WW is

PWv=∑i=1k⟨v,qi⟩ qi.P_W v = \sum_{i=1}^{k} \langle v, q_i\rangle\, q_i.

The residual v−PWvv - P_W v is orthogonal to every qjq_j (take the inner product and use orthonormality), hence to all of WW. So every vv splits uniquely as v=PWv+(v−PWv)v = P_W v + (v - P_W v) with the first part in WW and the second in W⊥W^\perp, and dim⁡W+dim⁡W⊥=dim⁡V\dim W + \dim W^\perp = \dim V.

Theorem 4 (best approximation). PWvP_W v is the unique closest point of WW to vv: for every w∈Ww \in W with w≠PWvw \neq P_W v,

∥v−w∥>∥v−PWv∥.\lVert v - w\rVert > \lVert v - P_W v\rVert.

Proof. Write v−w=(v−PWv)+(PWv−w)v - w = (v - P_W v) + (P_W v - w). The first part is in W⊥W^\perp, the second in WW, so by Pythagoras ∥v−w∥2=∥v−PWv∥2+∥PWv−w∥2\lVert v - w\rVert^2 = \lVert v - P_W v\rVert^2 + \lVert P_W v - w\rVert^2, and the last term is positive when w≠PWvw \neq P_W v. ∎

In matrix form. If QQ is the n×kn \times k matrix with orthonormal columns qiq_i, then QTQ=IkQ^TQ = I_k and the projection matrix is P=QQTP = QQ^T. If the columns of AA are any basis of WW (not orthonormal), then

P=A(ATA)−1AT.P = A(A^TA)^{-1}A^T.

Every projection matrix satisfies P2=PP^2 = P and PT=PP^T = P. Projection onto a single line through aa is aaTaTa\frac{aa^T}{a^Ta}; for example the projection of b=(3,0,3)b = (3, 0, 3) onto the line through a=(1,2,2)a = (1, 2, 2) is a⋅ba⋅aa=99a=(1,2,2)\frac{a \cdot b}{a \cdot a}a = \frac{9}{9}a = (1, 2, 2), with residual (2,−2,1)⊥a(2, -2, 1) \perp a.

Common pitfall: ∑⟨v,qi⟩qi\sum \langle v, q_i\rangle q_i is the projection only when the qiq_i are orthonormal. With a non-orthogonal basis, adding up the one-dimensional projections double-counts, and the result is not the closest point. Use A(ATA)−1ATA(A^TA)^{-1}A^T, or orthonormalise first.


Chapter 3 — Gram–Schmidt and QR

The algorithm

Given independent vectors v1,…,vnv_1, \dots, v_n, Gram–Schmidt produces an orthonormal list q1,…,qnq_1, \dots, q_n with the same span at every stage: span⁡(q1,…,qj)=span⁡(v1,…,vj)\operatorname{span}(q_1, \dots, q_j) = \operatorname{span}(v_1, \dots, v_j) for each jj. At step jj, subtract from vjv_j its projection onto the span of the earlier qq's, then normalise:

wj=vj−∑i<j⟨vj,qi⟩ qi,qj=wj∥wj∥.w_j = v_j - \sum_{i < j} \langle v_j, q_i\rangle\, q_i, \qquad q_j = \frac{w_j}{\lVert w_j\rVert}.

wj≠0w_j \neq 0 because vjv_j is not in the span of v1,…,vj−1v_1, \dots, v_{j-1}. So every finite-dimensional inner product space has an orthonormal basis.

Worked example. v1=(1,1,0)v_1 = (1, 1, 0), v2=(1,0,1)v_2 = (1, 0, 1), v3=(0,1,1)v_3 = (0, 1, 1).

  • q1=12(1,1,0)q_1 = \frac{1}{\sqrt2}(1, 1, 0).
  • ⟨v2,q1⟩=12\langle v_2, q_1\rangle = \frac{1}{\sqrt2}, so w2=(1,0,1)−12(1,1,0)=(12,−12,1)w_2 = (1, 0, 1) - \frac12(1, 1, 0) = (\frac12, -\frac12, 1), with ∥w2∥=3/2\lVert w_2\rVert = \sqrt{3/2}. Then q2=16(1,−1,2)q_2 = \frac{1}{\sqrt6}(1, -1, 2).
  • ⟨v3,q1⟩=12\langle v_3, q_1\rangle = \frac{1}{\sqrt2} and ⟨v3,q2⟩=16\langle v_3, q_2\rangle = \frac{1}{\sqrt6}, so w3=(0,1,1)−12(1,1,0)−16(1,−1,2)=(−23,23,23)w_3 = (0, 1, 1) - \frac12(1, 1, 0) - \frac16(1, -1, 2) = (-\frac23, \frac23, \frac23), and q3=13(−1,1,1)q_3 = \frac{1}{\sqrt3}(-1, 1, 1).

Check: q1⋅q2=1−1+012=0q_1 \cdot q_2 = \frac{1 - 1 + 0}{\sqrt{12}} = 0, q1⋅q3=−1+1+06=0q_1 \cdot q_3 = \frac{-1 + 1 + 0}{\sqrt6} = 0, q2⋅q3=−1−1+218=0q_2 \cdot q_3 = \frac{-1 - 1 + 2}{\sqrt{18}} = 0.

QR factorisation

Gram–Schmidt, written as matrices, is a factorisation. Each vjv_j is a combination of q1,…,qjq_1, \dots, q_j only, with coefficients rij=⟨vj,qi⟩r_{ij} = \langle v_j, q_i\rangle (i<ji < j) and rjj=∥wj∥r_{jj} = \lVert w_j\rVert. So

A=QR,A = QR,

with QQ having orthonormal columns and RR upper triangular with positive diagonal. For the example, R=QTAR = Q^TA:

R=(21/21/203/21/6002/3)≈(1.41420.70710.707101.22470.4082001.1547).R = \begin{pmatrix} \sqrt2 & 1/\sqrt2 & 1/\sqrt2 \\ 0 & \sqrt{3/2} & 1/\sqrt6 \\ 0 & 0 & 2/\sqrt3 \end{pmatrix} \approx \begin{pmatrix} 1.4142 & 0.7071 & 0.7071 \\ 0 & 1.2247 & 0.4082 \\ 0 & 0 & 1.1547 \end{pmatrix}.

Watch out: Classical Gram–Schmidt loses orthogonality in floating point when the columns are nearly dependent. Libraries compute QR with Householder reflections (or use modified Gram–Schmidt, which subtracts each projection from the updated vector). The factorisation is the same; the arithmetic is more stable.


Chapter 4 — Least squares

The problem

An overdetermined system Ax=bAx = b (AA is m×nm \times n with m>nm > n) usually has no solution: bb is not in the column space C(A)C(A). The least-squares solution x^\hat x minimises ∥b−Ax∥\lVert b - Ax\rVert. By Theorem 4, Ax^A\hat x must be the projection of bb onto C(A)C(A), so the residual e=b−Ax^e = b - A\hat x is orthogonal to every column of AA: ATe=0A^Te = 0. That gives the normal equations

ATA x^=ATb.A^TA\,\hat x = A^Tb.

If the columns of AA are independent, ATAA^TA is invertible (if ATAx=0A^TAx = 0 then xTATAx=∥Ax∥2=0x^TA^TAx = \lVert Ax\rVert^2 = 0, so Ax=0Ax = 0, so x=0x = 0), and x^=(ATA)−1ATb\hat x = (A^TA)^{-1}A^Tb is unique.

Worked example — fitting a line

Fit y=c0+c1xy = c_0 + c_1 x to the points (1,1),(2,2),(3,2),(4,5)(1, 1), (2, 2), (3, 2), (4, 5). Each point gives one equation c0+c1xi=yic_0 + c_1 x_i = y_i:

A=(11121314),b=(1225),ATA=(4101030),ATb=(1031).A = \begin{pmatrix} 1 & 1 \\ 1 & 2 \\ 1 & 3 \\ 1 & 4 \end{pmatrix}, \quad b = \begin{pmatrix} 1 \\ 2 \\ 2 \\ 5 \end{pmatrix}, \quad A^TA = \begin{pmatrix} 4 & 10 \\ 10 & 30 \end{pmatrix}, \quad A^Tb = \begin{pmatrix} 10 \\ 31 \end{pmatrix}.

det⁡(ATA)=120−100=20\det(A^TA) = 120 - 100 = 20, so

c^=120(30−10−104)(1031)=120(−1024)=(−0.51.2).\hat c = \frac{1}{20}\begin{pmatrix} 30 & -10 \\ -10 & 4 \end{pmatrix}\begin{pmatrix} 10 \\ 31 \end{pmatrix} = \frac{1}{20}\begin{pmatrix} -10 \\ 24 \end{pmatrix} = \begin{pmatrix} -0.5 \\ 1.2 \end{pmatrix}.

The best line is y=−0.5+1.2xy = -0.5 + 1.2x. The fitted values are (0.7,1.9,3.1,4.3)(0.7, 1.9, 3.1, 4.3) and the residuals e=(0.3,0.1,−1.1,0.7)e = (0.3, 0.1, -1.1, 0.7). Checks: ATe=0A^Te = 0, that is, the residuals sum to 0 and ∑xiei=0.3+0.2−3.3+2.8=0\sum x_i e_i = 0.3 + 0.2 - 3.3 + 2.8 = 0. The minimum sum of squared errors is 0.09+0.01+1.21+0.49=1.80.09 + 0.01 + 1.21 + 0.49 = 1.8; no other line does better.

Least squares with QR

If A=QRA = QR (reduced: QQ is m×nm \times n), the normal equations RTQTQRx^=RTQTbR^TQ^TQR\hat x = R^TQ^Tb simplify to

Rx^=QTb,R\hat x = Q^Tb,

solved by back substitution. This is the method used in practice. Forming ATAA^TA squares the condition number (Chapter 7), which can destroy half the significant digits; QR avoids it.


Chapter 5 — Orthogonal matrices and the spectral theorem

Orthogonal matrices

A square QQ with QTQ=IQ^TQ = I has orthonormal columns and Q−1=QTQ^{-1} = Q^T. It preserves inner products, lengths and angles: (Qx)⋅(Qy)=xTQTQy=x⋅y(Qx)\cdot(Qy) = x^TQ^TQy = x \cdot y. Taking determinants, det⁡(Q)2=1\det(Q)^2 = 1, so det⁡Q=±1\det Q = \pm 1. In R2\mathbb{R}^2 the orthogonal matrices are exactly the rotations (det⁡=1\det = 1) and the reflections (det⁡=−1\det = -1) of Linear Algebra 03. Products and inverses of orthogonal matrices are orthogonal.

A change of basis to an orthonormal basis uses an orthogonal PP, so P−1AP=PTAPP^{-1}AP = P^TAP: no inverse to compute.

The spectral theorem

Theorem 5 (spectral theorem, real symmetric case). If AA is a real symmetric n×nn \times n matrix (AT=AA^T = A), then:

  1. all eigenvalues of AA are real;
  2. eigenvectors for distinct eigenvalues are orthogonal;
  3. AA has an orthonormal basis of eigenvectors, so A=QΛQTA = Q\Lambda Q^T with QQ orthogonal and Λ\Lambda real diagonal.

Conversely, any QΛQTQ\Lambda Q^T is symmetric, so a real matrix is orthogonally diagonalizable if and only if it is symmetric.

Proof sketch. The key identity is ⟨Ax,y⟩=xTATy=xTAy=⟨x,Ay⟩\langle Ax, y\rangle = x^TA^Ty = x^TAy = \langle x, Ay\rangle.

(1) Let Av=λvAv = \lambda v with v∈Cnv \in \mathbb{C}^n nonzero. The number vˉTAv\bar v^TAv equals its own complex conjugate (conjugate it, use that AA is real, then transpose the 1×11 \times 1 result and use AT=AA^T = A), so it is real. It also equals λ vˉTv=λ∑∣vi∣2\lambda\,\bar v^Tv = \lambda\sum\lvert v_i\rvert^2, and ∑∣vi∣2>0\sum\lvert v_i\rvert^2 > 0 is real. So λ\lambda is real.

(2) If Av1=λ1v1Av_1 = \lambda_1 v_1 and Av2=λ2v2Av_2 = \lambda_2 v_2, then λ1⟨v1,v2⟩=⟨Av1,v2⟩=⟨v1,Av2⟩=λ2⟨v1,v2⟩\lambda_1\langle v_1, v_2\rangle = \langle Av_1, v_2\rangle = \langle v_1, Av_2\rangle = \lambda_2\langle v_1, v_2\rangle, so (λ1−λ2)⟨v1,v2⟩=0(\lambda_1 - \lambda_2)\langle v_1, v_2\rangle = 0.

(3) Induction on nn. By (1) there is a real eigenvalue λ1\lambda_1 with a unit eigenvector q1q_1. The complement W=q1⊥W = q_1^\perp is mapped into itself: if w⊥q1w \perp q_1 then ⟨Aw,q1⟩=⟨w,Aq1⟩=λ1⟨w,q1⟩=0\langle Aw, q_1\rangle = \langle w, Aq_1\rangle = \lambda_1\langle w, q_1\rangle = 0. On the (n−1)(n-1)-dimensional space WW, AA still satisfies ⟨Ax,y⟩=⟨x,Ay⟩\langle Ax, y\rangle = \langle x, Ay\rangle, so by induction WW has an orthonormal basis of eigenvectors q2,…,qnq_2, \dots, q_n. Together with q1q_1 this is an orthonormal eigenbasis of Rn\mathbb{R}^n. ∎

Worked example. B=(211121112)B = \begin{pmatrix} 2 & 1 & 1 \\ 1 & 2 & 1 \\ 1 & 1 & 2 \end{pmatrix} from Linear Algebra 04 has eigenvalues 4,1,14, 1, 1. The eigenvector (1,1,1)(1,1,1) for 4 is automatically orthogonal to the eigenplane x+y+z=0x + y + z = 0 for 1. Inside that plane, Linear Algebra 04 used (−1,1,0)(-1, 1, 0) and (−1,0,1)(-1, 0, 1), which are not orthogonal to each other — Gram–Schmidt fixes that. An orthonormal choice is

q1=13(1,1,1),q2=12(1,−1,0),q3=16(1,1,−2),QTBQ=diag⁡(4,1,1).q_1 = \tfrac{1}{\sqrt3}(1, 1, 1), \quad q_2 = \tfrac{1}{\sqrt2}(1, -1, 0), \quad q_3 = \tfrac{1}{\sqrt6}(1, 1, -2), \qquad Q^TBQ = \operatorname{diag}(4, 1, 1).

The spectral decomposition writes AA as a sum of rank-one projections:

A=λ1q1q1T+λ2q2q2T+⋯+λnqnqnT.A = \lambda_1 q_1q_1^T + \lambda_2 q_2q_2^T + \dots + \lambda_n q_nq_n^T.

For BB: B=4q1q1T+q2q2T+q3q3TB = 4q_1q_1^T + q_2q_2^T + q_3q_3^T. Since q2q2T+q3q3T=I−q1q1Tq_2q_2^T + q_3q_3^T = I - q_1q_1^T, this is B=I+3q1q1TB = I + 3q_1q_1^T.

Trick: For symmetric matrices, eigenvectors from different eigenvalues are orthogonal for free. You only need Gram–Schmidt inside an eigenspace of dimension 2 or more.


Chapter 6 — Positive definite matrices and quadratic forms

Four equivalent tests

A symmetric matrix AA is positive definite if xTAx>0x^TAx > 0 for every x≠0x \neq 0, and positive semidefinite if xTAx≥0x^TAx \ge 0 for every xx.

Theorem 6. For a real symmetric n×nn \times n matrix AA, the following are equivalent:

  1. AA is positive definite;
  2. every eigenvalue of AA is positive;
  3. every leading principal minor (the determinant of the top-left k×kk \times k block, k=1,…,nk = 1, \dots, n) is positive (Sylvester's criterion);
  4. elimination without row swaps succeeds with every pivot positive;
  5. A=RTRA = R^TR for some invertible RR — for example the Cholesky factor, upper triangular with positive diagonal.

Proof of 1 ⇔ 2. Write A=QΛQTA = Q\Lambda Q^T and put y=QTxy = Q^Tx (a change to the eigenvector basis; y≠0y \neq 0 exactly when x≠0x \neq 0). Then

xTAx=yTΛy=λ1y12+⋯+λnyn2,x^TAx = y^T\Lambda y = \lambda_1 y_1^2 + \dots + \lambda_n y_n^2,

which is positive for all y≠0y \neq 0 exactly when every λi>0\lambda_i > 0. For 5 ⇒ 1: xTRTRx=∥Rx∥2>0x^TR^TRx = \lVert Rx\rVert^2 > 0 when x≠0x \neq 0 because RR is invertible. The links to 3 and 4 go through the LU factorisation of Linear Algebra 01: the kk-th pivot equals the ratio of the kk-th and (k−1)(k-1)-th leading minors. ∎

Worked example.

K=(2−10−12−10−12).K = \begin{pmatrix} 2 & -1 & 0 \\ -1 & 2 & -1 \\ 0 & -1 & 2 \end{pmatrix}.

  • Leading minors: 22, 4−1=34 - 1 = 3, det⁡K=4\det K = 4. All positive.
  • Pivots: 22, 32\frac32, 43\frac43 — the ratios 21,32,43\frac21, \frac32, \frac43 of consecutive minors.
  • Eigenvalues: 2−2≈0.5862 - \sqrt2 \approx 0.586, 22, 2+2≈3.4142 + \sqrt2 \approx 3.414.
  • The quadratic form is a sum of squares: xTKx=2x2−2xy+2y2−2yz+2z2=x2+(x−y)2+(y−z)2+z2x^TKx = 2x^2 - 2xy + 2y^2 - 2yz + 2z^2 = x^2 + (x - y)^2 + (y - z)^2 + z^2, which is 00 only when x=y=z=0x = y = z = 0.

All four tests agree: KK is positive definite. (This matrix is the second-difference matrix that appears when a differential equation −u′′=f-u'' = f is discretised.)

Common pitfall: Positive entries do not make a matrix positive definite, and negative entries do not prevent it. (1223)\begin{pmatrix} 1 & 2 \\ 2 & 3\end{pmatrix} has all entries positive but determinant −1-1, so its eigenvalues are 2±52 \pm \sqrt5, one of them negative; KK above has negative entries and is positive definite.

Quadratic forms and principal axes

A quadratic form is q(x)=xTAxq(x) = x^TAx with AA symmetric (any cross term bxybxy is split evenly between the two off-diagonal entries). The spectral theorem rotates the axes so the cross terms disappear.

Worked example. q(x,y)=5x2+4xy+2y2q(x, y) = 5x^2 + 4xy + 2y^2 has A=(5222)A = \begin{pmatrix} 5 & 2 \\ 2 & 2 \end{pmatrix}, with trace 7 and determinant 6, so eigenvalues 66 and 11. Unit eigenvectors: 15(2,1)\frac{1}{\sqrt5}(2, 1) for 6 and 15(−1,2)\frac{1}{\sqrt5}(-1, 2) for 1. In the rotated coordinates u=2x+y5u = \frac{2x + y}{\sqrt5}, v=−x+2y5v = \frac{-x + 2y}{\sqrt5},

q=6u2+v2.q = 6u^2 + v^2.

(Check at (x,y)=(1,0)(x, y) = (1, 0): u=2/5u = 2/\sqrt5, v=−1/5v = -1/\sqrt5, and 6⋅45+15=5=q(1,0)6 \cdot \frac45 + \frac15 = 5 = q(1, 0).) The level curve q=6q = 6 is the ellipse u2+v2/6=1u^2 + v^2/6 = 1: semi-axis 11 along (2,1)(2, 1) and 6\sqrt6 along (−1,2)(-1, 2). The principal axes are the eigenvectors, and the semi-axes are c/λi\sqrt{c/\lambda_i} for the level q=cq = c. In calculus the same idea classifies critical points: a positive definite Hessian means a local minimum.


Chapter 7 — The singular value decomposition

The theorem

Diagonalization needs a square matrix, and even then it can fail or need complex numbers. The SVD always works.

Theorem 7 (SVD). Every real m×nm \times n matrix AA of rank rr can be written as

A=UΣVT,A = U\Sigma V^T,

where UU (m×mm \times m) and VV (n×nn \times n) are orthogonal and Σ\Sigma is m×nm \times n with diagonal entries σ1≥σ2≥⋯≥σr>0\sigma_1 \ge \sigma_2 \ge \dots \ge \sigma_r > 0 and zeros elsewhere. The σi\sigma_i are the singular values (uniquely determined by AA); the columns viv_i of VV and uiu_i of UU are the right and left singular vectors, and Avi=σiuiAv_i = \sigma_i u_i.

Proof. ATAA^TA is symmetric and positive semidefinite (xTATAx=∥Ax∥2≥0x^TA^TAx = \lVert Ax\rVert^2 \ge 0), so by the spectral theorem it has an orthonormal eigenbasis v1,…,vnv_1, \dots, v_n with eigenvalues λ1≥⋯≥λn≥0\lambda_1 \ge \dots \ge \lambda_n \ge 0. Exactly rr of them are positive, because ATAA^TA has the same null space as AA (shown in Chapter 4), hence rank rr. Put σi=λi\sigma_i = \sqrt{\lambda_i} and, for i≤ri \le r, ui=Avi/σiu_i = Av_i/\sigma_i. These are orthonormal:

ui⋅uj=viTATAvjσiσj=λj vi⋅vjσiσj={1i=j0i≠j.u_i \cdot u_j = \frac{v_i^TA^TAv_j}{\sigma_i\sigma_j} = \frac{\lambda_j\, v_i \cdot v_j}{\sigma_i\sigma_j} = \begin{cases} 1 & i = j \\ 0 & i \neq j. \end{cases}

Extend u1,…,uru_1, \dots, u_r to an orthonormal basis of Rm\mathbb{R}^m. Then Avi=σiuiAv_i = \sigma_i u_i for i≤ri \le r and Avi=0Av_i = 0 for i>ri > r, which is AV=UΣAV = U\Sigma, that is A=UΣVTA = U\Sigma V^T. ∎

Dropping the zero parts gives the compact form A=∑i=1rσiuiviTA = \sum_{i=1}^{r}\sigma_i u_i v_i^T, a sum of rr rank-one matrices. The SVD also hands you orthonormal bases for all four fundamental subspaces of Linear Algebra 02: v1,…,vrv_1, \dots, v_r for the row space, vr+1,…,vnv_{r+1}, \dots, v_n for the null space, u1,…,uru_1, \dots, u_r for the column space, and ur+1,…,umu_{r+1}, \dots, u_m for the left null space.

Worked example

A=(3045),ATA=(25202025).A = \begin{pmatrix} 3 & 0 \\ 4 & 5 \end{pmatrix}, \qquad A^TA = \begin{pmatrix} 25 & 20 \\ 20 & 25 \end{pmatrix}.

ATAA^TA has trace 50 and determinant 625−400=225625 - 400 = 225, so eigenvalues 4545 and 55, with unit eigenvectors v1=12(1,1)v_1 = \frac{1}{\sqrt2}(1, 1) and v2=12(−1,1)v_2 = \frac{1}{\sqrt2}(-1, 1). The singular values are σ1=45=35≈6.708\sigma_1 = \sqrt{45} = 3\sqrt5 \approx 6.708 and σ2=5≈2.236\sigma_2 = \sqrt5 \approx 2.236. Then

u1=Av1σ1=(3,9)/235=110(1,3),u2=Av2σ2=(−3,1)/25=110(−3,1),u_1 = \frac{Av_1}{\sigma_1} = \frac{(3, 9)/\sqrt2}{3\sqrt5} = \frac{1}{\sqrt{10}}(1, 3), \qquad u_2 = \frac{Av_2}{\sigma_2} = \frac{(-3, 1)/\sqrt2}{\sqrt5} = \frac{1}{\sqrt{10}}(-3, 1),

A=110(1−331)⏟U(35005)⏟Σ12(11−11)⏟VT.A = \underbrace{\frac{1}{\sqrt{10}}\begin{pmatrix} 1 & -3 \\ 3 & 1 \end{pmatrix}}_{U} \underbrace{\begin{pmatrix} 3\sqrt5 & 0 \\ 0 & \sqrt5 \end{pmatrix}}_{\Sigma} \underbrace{\frac{1}{\sqrt2}\begin{pmatrix} 1 & 1 \\ -1 & 1 \end{pmatrix}}_{V^T}.

Checks: σ1σ2=15=det⁡A\sigma_1\sigma_2 = 15 = \det A (here det⁡U=det⁡V=1\det U = \det V = 1), and σ12+σ22=50=9+0+16+25\sigma_1^2 + \sigma_2^2 = 50 = 9 + 0 + 16 + 25, the sum of the squared entries.

Watch out: The singular values of AA are not its eigenvalues. This AA is triangular with eigenvalues 3 and 5, but singular values 6.7086.708 and 2.2362.236. For a symmetric matrix the singular values are the absolute values of the eigenvalues (more generally this holds for normal matrices, those with ATA=AATA^TA = AA^T), and for a positive semidefinite matrix they are exactly the eigenvalues.

Geometry: rotate, stretch, rotate

Read A=UΣVTA = U\Sigma V^T from right to left as three steps applied to the unit circle:

  1. VTV^T is orthogonal: it rotates (or reflects) the plane, carrying v1,v2v_1, v_2 to e1,e2e_1, e_2. Here VTV^T is rotation by −45°-45°. The circle stays a circle.
  2. Σ\Sigma stretches along the axes by σ1\sigma_1 and σ2\sigma_2. The circle becomes an axis-aligned ellipse with semi-axes 6.7086.708 and 2.2362.236.
  3. UU rotates again, carrying e1,e2e_1, e_2 to u1,u2u_1, u_2. Here UU is rotation by about 71.6°71.6° (the angle of (1,3)(1, 3)).

The SVD of A = [[3,0],[4,5]] as three steps applied to the unit circle: V transpose rotates by -45 degrees taking v1 and v2 to e1 and e2, Sigma stretches by 3 root 5 and root 5 into an axis-aligned ellipse, and U rotates by about 71.6 degrees; the result is the image of the unit circle under A, an ellipse with semi-axes along u1 and u2.

So every linear map of Rn\mathbb{R}^n sends the unit sphere to an ellipsoid (flattened when AA is singular); the singular values are its semi-axes, the uiu_i their directions, and the viv_i the unit vectors that land on them. In general UU and VV may include a reflection; both can be chosen as rotations exactly when det⁡A≥0\det A \ge 0 (for square AA).

Norms and conditioning

  • Spectral norm: ∥A∥2=max⁡∥x∥=1∥Ax∥=σ1\lVert A\rVert_2 = \max_{\lVert x\rVert = 1}\lVert Ax\rVert = \sigma_1 — the longest semi-axis.
  • Frobenius norm: ∥A∥F=∑aij2=σ12+⋯+σr2\lVert A\rVert_F = \sqrt{\sum a_{ij}^2} = \sqrt{\sigma_1^2 + \dots + \sigma_r^2} (orthogonal matrices do not change it).
  • Condition number of an invertible AA: κ(A)=σ1/σn\kappa(A) = \sigma_1/\sigma_n, the ratio of the longest to the shortest semi-axis. For the example κ=35/5=3\kappa = 3\sqrt5/\sqrt5 = 3. Solving Ax=bAx = b can amplify relative errors in bb by up to κ\kappa; since σi(ATA)=σi2\sigma_i(A^TA) = \sigma_i^2, forming the normal equations squares it. This, and not the size of det⁡A\det A, measures closeness to singularity (Linear Algebra 03, Chapter 7).

Chapter 8 — Using the SVD

Low-rank approximation

Theorem 8 (Eckart–Young, statement). Let A=∑i=1rσiuiviTA = \sum_{i=1}^r \sigma_i u_i v_i^T and, for k<rk < r, Ak=∑i=1kσiuiviTA_k = \sum_{i=1}^k \sigma_i u_i v_i^T. Among all matrices BB of rank at most kk,

min⁡rank⁡B≤k∥A−B∥2=∥A−Ak∥2=σk+1,min⁡rank⁡B≤k∥A−B∥F=∥A−Ak∥F=σk+12+⋯+σr2.\min_{\operatorname{rank} B \le k}\lVert A - B\rVert_2 = \lVert A - A_k\rVert_2 = \sigma_{k+1}, \qquad \min_{\operatorname{rank} B \le k}\lVert A - B\rVert_F = \lVert A - A_k\rVert_F = \sqrt{\sigma_{k+1}^2 + \dots + \sigma_r^2}.

Keep the kk largest singular triples and drop the rest; nothing of rank kk does better. For the example,

A1=35 u1v1T=32(1133)=(1.51.54.54.5),A−A1=(1.5−1.5−0.50.5),A_1 = 3\sqrt5\, u_1v_1^T = \frac{3}{2}\begin{pmatrix} 1 & 1 \\ 3 & 3 \end{pmatrix} = \begin{pmatrix} 1.5 & 1.5 \\ 4.5 & 4.5 \end{pmatrix}, \qquad A - A_1 = \begin{pmatrix} 1.5 & -1.5 \\ -0.5 & 0.5 \end{pmatrix},

and ∥A−A1∥F2=2.25+2.25+0.25+0.25=5=σ22\lVert A - A_1\rVert_F^2 = 2.25 + 2.25 + 0.25 + 0.25 = 5 = \sigma_2^2, as the theorem says.

Storage: a rank-kk approximation of an m×nm \times n matrix needs k(m+n+1)k(m + n + 1) numbers instead of mnmn. For a 1000×10001000 \times 1000 greyscale image and k=50k = 50, that is 100 050100\,050 numbers instead of 1 000 0001\,000\,000, about 10%. Whether the result looks acceptable depends on how fast the singular values decay.

The pseudoinverse

The Moore–Penrose pseudoinverse of A=UΣVTA = U\Sigma V^T is

A+=VΣ+UT,A^+ = V\Sigma^+U^T,

where Σ+\Sigma^+ is n×mn \times m with 1/σi1/\sigma_i in place of each nonzero σi\sigma_i. It inverts AA on the row space and sends the left null space to 0. x+=A+bx^+ = A^+b is the least-squares solution of Ax=bAx = b with the smallest norm — well defined even when AA is rank-deficient and the normal equations have infinitely many solutions. If AA has independent columns, A+=(ATA)−1ATA^+ = (A^TA)^{-1}A^T and A+bA^+b is the x^\hat x of Chapter 4; for the line fit, A+b=(−0.5,1.2)A^+b = (-0.5, 1.2). If AA is invertible, A+=A−1A^+ = A^{-1}.

Example. A=(1111)=2 uuTA = \begin{pmatrix} 1 & 1 \\ 1 & 1 \end{pmatrix} = 2\,uu^T with u=12(1,1)u = \frac{1}{\sqrt2}(1, 1), so A+=12uuT=14(1111)A^+ = \frac12 uu^T = \frac14\begin{pmatrix} 1 & 1 \\ 1 & 1\end{pmatrix}. For b=(1,3)b = (1, 3) (not in the column space), x+=A+b=(1,1)x^+ = A^+b = (1, 1). Every xx with x1+x2=2x_1 + x_2 = 2 gives the same smallest residual (because Ax=(2,2)Ax = (2, 2), the projection of bb), and (1,1)(1, 1) is the shortest of them.

Principal component analysis

Put NN data points in Rp\mathbb{R}^p as the rows of a matrix and subtract the mean of each column, giving a centred N×pN \times p matrix XX. The sample covariance matrix is C=1N−1XTXC = \frac{1}{N - 1}X^TX. If X=UΣVTX = U\Sigma V^T then C=VΣTΣN−1VTC = V\frac{\Sigma^T\Sigma}{N - 1}V^T, so:

  • the principal directions are the right singular vectors viv_i (eigenvectors of CC);
  • the variance along viv_i is σi2/(N−1)\sigma_i^2/(N - 1);
  • projecting the data onto v1,…,vkv_1, \dots, v_k is the best kk-dimensional summary in the least-squares sense (Eckart–Young applied to XX).

Worked example. The four points (3,3),(−3,−3),(1,−1),(−1,1)(3, 3), (-3, -3), (1, -1), (-1, 1) already have mean zero. XTX=(20161620)X^TX = \begin{pmatrix} 20 & 16 \\ 16 & 20\end{pmatrix} has eigenvalues 36 and 4 with eigenvectors (1,1)(1, 1) and (1,−1)(1, -1), so the singular values of XX are 6 and 2. The first principal direction is 12(1,1)\frac{1}{\sqrt2}(1, 1) with variance 36/3=1236/3 = 12; the second has variance 4/34/3. The first component explains 36/(36+4)=90%36/(36 + 4) = 90\% of the total variance.

Common pitfall: Forgetting to centre the data. Without subtracting the mean, the first "principal component" mostly points at the mean itself. Also scale the columns first when they are in different units, or the largest-unit variable dominates.


Practice Exercises

1. Show that ⟨f,g⟩=∫01f(t)g(t) dt\langle f, g\rangle = \int_0^1 f(t)g(t)\,dt satisfies the positive-definiteness axiom on C[0,1]C[0,1]. Then find the projection of f(t)=tf(t) = t onto the constants.

Solution

⟨f,f⟩=∫01f2≥0\langle f, f\rangle = \int_0^1 f^2 \ge 0. If ff is continuous and f(t0)≠0f(t_0) \neq 0, then f2>12f(t0)2f^2 > \frac12 f(t_0)^2 on some interval around t0t_0, so the integral is positive; hence ⟨f,f⟩=0\langle f, f\rangle = 0 forces f=0f = 0. (Continuity matters here.) Projection onto span⁡(1)\operatorname{span}(1): ⟨t,1⟩⟨1,1⟩⋅1=1/21=12\frac{\langle t, 1\rangle}{\langle 1, 1\rangle}\cdot 1 = \frac{1/2}{1} = \frac12. The residual t−12t - \frac12 is orthogonal to 1, as computed in Chapter 1.

2. Apply Gram–Schmidt to a1=(1,1,1,1)a_1 = (1, 1, 1, 1), a2=(0,1,2,3)a_2 = (0, 1, 2, 3).

Solution

q1=12(1,1,1,1)q_1 = \frac12(1, 1, 1, 1). ⟨a2,a1⟩/⟨a1,a1⟩=6/4=32\langle a_2, a_1\rangle / \langle a_1, a_1\rangle = 6/4 = \frac32, so w2=(0,1,2,3)−32(1,1,1,1)=(−32,−12,12,32)w_2 = (0, 1, 2, 3) - \frac32(1, 1, 1, 1) = (-\frac32, -\frac12, \frac12, \frac32) with ∥w2∥=94+14+14+94=5\lVert w_2\rVert = \sqrt{\frac94 + \frac14 + \frac14 + \frac94} = \sqrt5. So q2=125(−3,−1,1,3)q_2 = \frac{1}{2\sqrt5}(-3, -1, 1, 3). (This is the "centred xx" that makes line fitting at x=0,1,2,3x = 0, 1, 2, 3 decouple.)

3. For the line fit in Chapter 4, compute the projection matrix P=A(ATA)−1ATP = A(A^TA)^{-1}A^T and check PbPb.

Solution

(ATA)−1=120(30−10−104)(A^TA)^{-1} = \frac{1}{20}\begin{pmatrix} 30 & -10 \\ -10 & 4\end{pmatrix}, and

P=110(741−243211234−2147).P = \frac{1}{10}\begin{pmatrix} 7 & 4 & 1 & -2 \\ 4 & 3 & 2 & 1 \\ 1 & 2 & 3 & 4 \\ -2 & 1 & 4 & 7 \end{pmatrix}.

Pb=110(7+8+2−10, 4+6+4+5, 1+4+6+20, −2+2+8+35)=(0.7,1.9,3.1,4.3)Pb = \frac{1}{10}(7 + 8 + 2 - 10,\ 4 + 6 + 4 + 5,\ 1 + 4 + 6 + 20,\ -2 + 2 + 8 + 35) = (0.7, 1.9, 3.1, 4.3), the fitted values. Also P2=PP^2 = P and PT=PP^T = P.

4. Is (4223)\begin{pmatrix} 4 & 2 \\ 2 & 3\end{pmatrix} positive definite? Use two different tests.

Solution

Leading minors: 4>04 > 0 and 12−4=8>012 - 4 = 8 > 0: yes. Eigenvalues: trace 7, determinant 8, so λ=7±49−322=7±172\lambda = \frac{7 \pm \sqrt{49 - 32}}{2} = \frac{7 \pm \sqrt{17}}{2}, both positive because 17<7\sqrt{17} < 7. Or complete the square: 4x2+4xy+3y2=(2x+y)2+2y24x^2 + 4xy + 3y^2 = (2x + y)^2 + 2y^2.

5. Find the singular values of E=(221−1)E = \begin{pmatrix} 2 & 2 \\ 1 & -1\end{pmatrix} and its condition number.

Solution

ETE=(5335)E^TE = \begin{pmatrix} 5 & 3 \\ 3 & 5\end{pmatrix} has eigenvalues 8 and 2, so σ1=22\sigma_1 = 2\sqrt2, σ2=2\sigma_2 = \sqrt2, and κ=2\kappa = 2. Check: σ1σ2=4=∣det⁡E∣=∣−2−2∣\sigma_1\sigma_2 = 4 = \lvert\det E\rvert = \lvert -2 - 2\rvert.

6. Prove that if QQ is orthogonal then every real eigenvalue of QQ is ±1\pm1, and every singular value of QQ is 1.

Solution

If Qv=λvQv = \lambda v with v≠0v \neq 0, then ∥v∥=∥Qv∥=∣λ∣ ∥v∥\lVert v\rVert = \lVert Qv\rVert = \lvert\lambda\rvert\,\lVert v\rVert, so ∣λ∣=1\lvert\lambda\rvert = 1. Singular values are square roots of the eigenvalues of QTQ=IQ^TQ = I, all equal to 1: an orthogonal map sends the unit sphere to itself.

7. Show that for a symmetric positive semidefinite matrix the SVD and the spectral decomposition coincide, and give a 2×22 \times 2 symmetric matrix where they differ.

Solution

If A=QΛQTA = Q\Lambda Q^T with all λi≥0\lambda_i \ge 0 (sorted in decreasing order), then U=V=QU = V = Q and Σ=Λ\Sigma = \Lambda is a valid SVD. For a symmetric matrix with a negative eigenvalue, such as (1221)\begin{pmatrix} 1 & 2 \\ 2 & 1\end{pmatrix} (eigenvalues 3,−13, -1), the singular values are 33 and 11: the sign moves into UU (take u2=−v2u_2 = -v_2).


Cheat-sheet

Idea Formula or fact
Inner product symmetric, linear, ⟨v,v⟩>0\langle v, v\rangle > 0 for v≠0v \neq 0
Cauchy–Schwarz ∣⟨u,v⟩∣≤∥u∥∥v∥\lvert\langle u, v\rangle\rvert \le \lVert u\rVert\lVert v\rVert
Orthonormal coordinates v=∑⟨v,qi⟩qiv = \sum\langle v, q_i\rangle q_i
Projection P=QQTP = QQ^T or A(ATA)−1ATA(A^TA)^{-1}A^T; P2=P=PTP^2 = P = P^T
Best approximation PWvP_Wv is the closest point of WW
Gram–Schmidt wj=vj−∑i<j⟨vj,qi⟩qiw_j = v_j - \sum_{i<j}\langle v_j, q_i\rangle q_i
QR A=QRA = QR, RR upper triangular
Least squares ATAx^=ATbA^TA\hat x = A^Tb, or Rx^=QTbR\hat x = Q^Tb
Orthogonal matrix QTQ=IQ^TQ = I, det⁡Q=±1\det Q = \pm1, keeps lengths
Spectral theorem A=AT  ⟺  A=QΛQTA = A^T \iff A = Q\Lambda Q^T, real Λ\Lambda
Positive definite eigenvalues, leading minors, pivots all >0> 0; A=RTRA = R^TR
Quadratic form principal axes = eigenvectors of AA
SVD A=UΣVTA = U\Sigma V^T, Avi=σiuiAv_i = \sigma_iu_i, σi=λi(ATA)\sigma_i = \sqrt{\lambda_i(A^TA)}
Norms ∥A∥2=σ1\lVert A\rVert_2 = \sigma_1, ∥A∥F2=∑σi2\lVert A\rVert_F^2 = \sum\sigma_i^2, κ=σ1/σn\kappa = \sigma_1/\sigma_n
Eckart–Young best rank kk: keep the top kk terms; error σk+1\sigma_{k+1}
Pseudoinverse A+=VΣ+UTA^+ = V\Sigma^+U^T, minimum-norm least squares
PCA centre, SVD; variance along viv_i is σi2/(N−1)\sigma_i^2/(N-1)

What's next

This completes the base series: from solving Ax=bAx = b by elimination (post 00) to the SVD, which describes any matrix completely by two orthonormal bases and a list of stretch factors. The table below lists the posts planned to extend the series. The most natural next step is canonical forms — the full proof of the Jordan form stated in Linear Algebra 04 — followed by the numerical side, where the algorithms behind numpy.linalg (LU with pivoting, Householder QR, the QR eigenvalue algorithm, Golub–Kahan SVD) are studied for speed and accuracy.

Planned future extensions

Post Topic What it covers
06 Jordan form and canonical forms generalised eigenvectors, the Jordan form proof, minimal polynomial, rational canonical form, eAte^{At} for defective matrices
07 Numerical linear algebra floating point and conditioning, LU with pivoting, Householder QR, QR eigenvalue algorithm, computing the SVD, iterative solvers (conjugate gradient, GMRES)
08 Linear algebra for machine learning linear regression and ridge regression, PCA in practice, matrix calculus and gradients, low-rank methods, embeddings
09 Tensors and multilinear algebra dual spaces, bilinear forms, tensor products, exterior algebra and the determinant revisited, tensor decompositions
10 Functional analysis preview normed and Hilbert spaces, infinite orthonormal bases and Fourier series, bounded operators, the spectral theorem for compact self-adjoint operators

References

  • Sheldon Axler, Linear Algebra Done Right, 4th ed., Springer (2024) — Chapter 6 (inner product spaces, Gram–Schmidt, orthogonal projection, least squares) and Chapter 7 (self-adjoint operators, the spectral theorem, positive operators, SVD). Open access at linear.axler.net.
  • Gilbert Strang, Introduction to Linear Algebra, 6th ed., Wellesley-Cambridge Press (2023) — orthogonality, projections, least squares, Gram–Schmidt; symmetric and positive definite matrices; the SVD and PCA.
  • Gilbert Strang, Linear Algebra and Learning from Data, Wellesley-Cambridge Press (2019) — the SVD, Eckart–Young, PCA and low-rank approximation from the data-science side.
  • Lloyd N. Trefethen, David Bau III, Numerical Linear Algebra, SIAM (1997) — Lectures 4–5 (SVD), 6–11 (projectors, QR, Gram–Schmidt, Householder, least squares), 12–15 (conditioning and stability).
  • Gene H. Golub, Charles F. Van Loan, Matrix Computations, 4th ed., Johns Hopkins University Press (2013) — the reference for QR, SVD and least-squares algorithms.
  • Roger A. Horn, Charles R. Johnson, Matrix Analysis, 2nd ed., Cambridge University Press (2012) — positive definite matrices, the spectral theorem and the SVD with complete proofs.
  • Carl Eckart, Gale Young, "The approximation of one matrix by another of lower rank", Psychometrika 1 (1936), 211–218 — the original low-rank approximation theorem.
  • MIT OpenCourseWare, 18.06 Linear Algebra (Spring 2010), Gilbert Strang — lectures 14–17 (orthogonality, projections, least squares, Gram–Schmidt), 25 and 27 (symmetric and positive definite matrices) and 29 (SVD); and 18.065 Matrix Methods in Data Analysis, Signal Processing, and Machine Learning (Spring 2018).

Note: this post is in progress. Planned additions: complex inner product spaces and unitary matrices, the spectral theorem for normal matrices, a proof of Eckart–Young, a larger PCA example on real data with a scree plot, and a total-least-squares section.