A. Linear Algebra II: Norms, Positive Definiteness & the SVD
From a first linear algebra course to the matrix tools every later module uses
This primer assumes:
- A first course in linear algebra; refresh matrix products, solves, rank and eigenvectors in the worked recap below (baseline)
- School algebra (squares, fractions and inequalities); integrals only enter Section 8, with a local recap (baseline)
- Sets, quantifiers & logic (Primer 0)
- Supremum, infimum & maxima over infinite sets (Primer 0)
- Sequences, limits & the geometric series (Primer 0)
- Open, closed & compact sets (Primer 0)
Book contents · Apply this chapter to a real decision · Glossary
Almost every certificate in the modules is a statement about a matrix: this matrix is positive semidefinite (an LMI), this matrix stretches no vector by more than $L$ (a Lipschitz bound), this Gram matrix has these eigenvalues (a GP confidence bound). The modules need to compare sizes: of vectors in several norms, of matrices as maps, of quadratic forms in different directions. This primer builds those tools from $2\times2$ examples and says where each is used.
Begin with the first-course refresher if matrix arithmetic or eigenvectors feel rusty. Read Sections 1–5 in order, then use Section 6 before the LMI modules. Sections 7–8 build the structured-matrix and kernel tools; return to their deeper paragraphs when those applications arise.
Each of the eight sections has an Easy, Medium and Hard practice sequence: 24 local exercises, in addition to the mixed exercises at the end. Try the question, use the independent hint only when stuck, and write a complete attempt before opening the worked solution. Afterwards close it and reproduce the reasoning.
Practice menu: Vectors, norms and worst-case directions, Matrices as maps and norm bounds, Eigenvectors, quadratic forms and spectral limits, Definiteness, factors and ellipsoid support, Singular values, least squares and power iteration, Block algebra, Schur complements and updates, Orthogonal maps, projections and Cayley transforms, Functions as vectors, kernels and RKHS norms.
Use the readiness check to decide what to revisit. Research-module links show where the tools will be used; you do not need to read those modules while learning the definitions.
1. Vectors, Inner Products & Norms
A first course measures length by $\sqrt{x_1^2+\dots+x_n^2}$. The modules need several notions of size, inequalities that convert between them, and distances between points and sets.
First-course refresher: what a matrix calculation means
A vector is a list of coordinates. A matrix combines them by linear rules. Recover the following operations before learning the new norms; each calculation below has a direct substitution check.
Shapes: an $m\times n$ matrix has m rows and n columns and maps a column vector with n entries to one with m entries. For $A=\begin{bmatrix}1&2\\0&1\end{bmatrix}$ and $x=(1,2)^\top$, each output is one row dotted with x:
Products: AB means apply B first, then A; the inner dimensions must agree. With $B=\begin{bmatrix}2&0\\1&3\end{bmatrix}$, the first column of AB is A times $(2,1)^\top$ and the second is A times $(0,3)^\top$. Therefore
These differ: matrix products generally cannot be reordered. A transpose swaps rows and columns, so $A^\top=\begin{bmatrix}1&0\\2&1\end{bmatrix}$ and $(AB)^\top=B^\top A^\top$. The reversed order makes the shapes line up. A superscript $\top$ means transpose; an integer superscript such as $A^2=AA$ means a power.
Solve: $Ax=b$ with A above and $b=(5,2)^\top$ means $x_1+2x_2=5$, $x_2=2$. Solve the second equation first, then substitute into the first: $x_2=2$, $x_1=1$. This is backward substitution.
Inverse and determinant: $A^{-1}=\begin{bmatrix}1&-2\\0&1\end{bmatrix}$ undoes A because direct multiplication gives $A^{-1}A=AA^{-1}=I$. A square matrix has an inverse exactly when its determinant is nonzero. For $\begin{bmatrix}a&b\\c&d\end{bmatrix}$, the determinant is $ad-bc$; here it is $1$. Solving a system is usually better than explicitly computing its inverse.
Rank and null space: for $R=\begin{bmatrix}1&2\\2&4\end{bmatrix}$, the second row is twice the first, so there is only one independent equation: rank 1. The null space consists of all x with Rx=0, equivalently $x_1+2x_2=0$. Thus $x=t(-2,1)^\top$ for any real t. R loses this direction and has no inverse. Its range consists of multiples of $(1,2)^\top$; hence Rx=b is solvable exactly for such b.
Invariant direction: an eigenvector is a nonzero v with $Mv=\lambda v$. For $M=\begin{bmatrix}2&1\\1&2\end{bmatrix}$, multiplication gives $M(1,1)^\top=3(1,1)^\top$ and $M(1,-1)^\top=(1,-1)^\top$. The matrix scales these directions by eigenvalues 3 and 1.
Finding the values: a nonzero solution of $(M-\lambda I)v=0$ requires $\det(M-\lambda I)=0$. Here $(2-\lambda)^2-1=(1-\lambda)(3-\lambda)=0$. After finding an eigenvalue, solve its homogeneous equations to get the eigenvectors.
Perpendicular and unit: $(1,1)^\top(1,-1)=1-1=0$, so these vectors are orthogonal. Each has length $\sqrt2$, so dividing by $\sqrt2$ makes them orthonormal (unit length and perpendicular). Section 3 explains why a real symmetric matrix always has a complete basis of this kind.
Check before continuing: multiply A by $(2,-1)^\top$ to obtain $(0,-1)^\top$, solve $Ax=(4,1)^\top$ to obtain $(2,1)^\top$, and verify the eigenvector equations above. If the steps are clear, continue to the inner product; fluency returns with the local Easy exercises.
1.1 Inner products and the Cauchy–Schwarz inequality
Intuition and example. In the plane $x^\top y=\|x\|\,\|y\|\cos\theta$: the inner product measures alignment. For $x=(1,2)$, $y=(3,-1)$: $x^\top y=1$, $\|x\|=\sqrt5$, $\|y\|=\sqrt{10}$, $\theta\approx81.9^\circ$. With $M=\mathrm{diag}(1,4)$ (coordinate 2 counts double): $\langle x,y\rangle_M=3-8=-5$, $\|x\|_M=\sqrt{17}$, $\|y\|_M=\sqrt{13}$, an obtuse angle. Which vectors are long or perpendicular depends on the inner product.
Proof. If $y=0$ both sides are $0$. Otherwise, for every real $t$, $0\le\|x-ty\|^2=\|x\|^2-2t\langle x,y\rangle+t^2\|y\|^2$. This parabola in $t$ is smallest at $t^\star=\langle x,y\rangle/\|y\|^2$, where it equals $\|x\|^2-\langle x,y\rangle^2/\|y\|^2\ge0$. Equality forces $x=t^\star y$. $\square$ Only (i)–(iii) were used, so it holds for weighted inner products and for functions (Section 8).
Uses. $|a^\top d|\le\|a\|\bar d$ for a disturbance with $\|d\|\le\bar d$, and, for $u_{\max}\ge0$, $\max_{\|u\|\le u_{\max}}b^\top u=u_{\max}\|b\|$. For a distinct class $j\ne y$, a logit difference is $(e_y-e_j)^\top f$ with $\|e_y-e_j\|=\sqrt2$, so an $L$-Lipschitz $f$ moves the margin by at most $\sqrt2L\|\delta\|$ (the $\sqrt2$ of Module 12's certified radius). For $H\succ0$, $u^\top H^{-1}v$ is an inner product, and for CPO's $q=g^\top H^{-1}g$, $r=g^\top H^{-1}b$, $s=b^\top H^{-1}b$ Cauchy–Schwarz reads $qs\ge r^2$.
1.2 Norms and their unit balls
Example. $x=(3,-4)$: $\|x\|_1=7$, $\|x\|_2=5$, $\|x\|_\infty=4$. The unit balls are a diamond, a disc and a square, nested as $\{\|x\|_1\le1\}\subseteq\{\|x\|_2\le1\}\subseteq\{\|x\|_\infty\le1\}$; all are convex and symmetric.
Triangle inequality for $\ell_2$ from Cauchy–Schwarz: $\|x+y\|^2=\|x\|^2+2x^\top y+\|y\|^2\le(\|x\|+\|y\|)^2$. The reverse triangle inequality $\big|\,\|x\|-\|y\|\,\big|\le\|x-y\|$ follows from $\|x\|\le\|x-y\|+\|y\|$ and symmetry: every norm is 1-Lipschitz. Stacked vectors $z=(x,u)$: $\|z\|_2^2=\|x\|_2^2+\|u\|_2^2$, $\|z\|_1=\|x\|_1+\|u\|_1$, $\|z\|_\infty=\max\{\|x\|_\infty,\|u\|_\infty\}$. A punctured ball $\{u:0\lt\|u\|_2\le1\}$ excludes the centre, where $u/\|u\|_2$ is undefined.
1.3 Hölder's inequality and dual norms
Proof of the $(1,\infty)$ case (used in Module 9): $|\sum_iu_iv_i|\le\sum_i|u_i||v_i|\le\max_j|v_j|\sum_i|u_i|$. The general case follows from Young's inequality $ab\le a^p/p+b^q/q$ (see Further Reading). Example: $w=(2,-1,3)$, $\varepsilon=0.1$: $w^\top\delta$ ranges over $\pm0.6$ on the $\ell_\infty$ ball, $\pm\sqrt{14}/10\approx\pm0.374$ on the $\ell_2$ ball, $\pm0.3$ on the $\ell_1$ ball. Since the box $[-1,1]^n$ is the $\ell_\infty$ unit ball, the hyperplane $w^\top a=b$ meets it iff $|b|\le\|w\|_1$.
1.4 Norm equivalence: the dimension factors
Proof. $\max_ix_i^2\le\sum_ix_i^2\le(\sum_i|x_i|)^2$ (cross terms are $\ge0$); $\sum_i|x_i|\cdot1\le\|x\|_2\|\mathbf 1\|_2$ by Cauchy–Schwarz; $\sum_ix_i^2\le n\max_ix_i^2$. $\square$ E.g. $x=(3,-4,12)$: $12\le13\le19\le13\sqrt3\approx22.5$.
Balls and certificates. $\{\|\delta\|_\infty\le\varepsilon/\sqrt n\}\subseteq\{\|\delta\|_2\le\varepsilon\}\subseteq\{\|\delta\|_\infty\le\varepsilon\}$, so an $\ell_2$ certificate of radius $\varepsilon$ certifies only the $\ell_\infty$ radius $\varepsilon/\sqrt n$: on MNIST ($\sqrt{784}=28$) an $\ell_2$ radius $1.58$ gives $0.056$. Lipschitz constants convert likewise, $\|f(x)-f(y)\|_\infty\le\|f(x)-f(y)\|_2\le L\|x-y\|_2\le L\sqrt n\|x-y\|_\infty$: changing the input norm costs a factor in the input dimension $n$, changing the output norm one in the output dimension $m$.
Covering numbers. Assume $s\ge0$, $\tau>0$ and $d\ge1$. A cube of side $s$ lies in the $\ell_2$ ball of radius $s\sqrt d/2$ about its centre. Cutting $[0,1]^d$ into $m^d$ cubes with $m=\lceil\sqrt d/(2\tau)\rceil$ covers it by $m^d$ balls of radius $\tau$; their centres form a $\tau$-net, and the fewest balls that suffice is the covering number $M(\tau,[0,1]^d)$. For $\tau=0.1$: $64$ balls in $d=2$, about $1.1\times10^{12}$ in $d=10$. If an $L$-Lipschitz function has margin $m_0$ at every net point, its margin is at least $m_0-L\tau$ everywhere (Primer B).
1.5 Metrics, balls and distances to sets
Examples. $\mathrm{dist}(x,\{x_1\le0\})=\max\{x_1,0\}$; for the unit disc, $\max\{\|x\|_2-1,0\}$. The $\ell_\infty$ ball $\{\|x-x_0\|_\infty\le\varepsilon\}$ is the box $|x_i-x_{0,i}|\le\varepsilon$, handled coordinate by coordinate by interval methods. Shortest-path length on a grid is a metric too. Certified balls: if $g$ is $L$-Lipschitz with $L\gt0$ and $g(z)=c\gt0$, then $g\ge0$ on $B_{c/L}(z)$, since $g(y)\ge c-L\,d(y,z)$; a union of such balls is certified. If $L=0$, the Lipschitz inequality makes $g$ constant on its domain, so the positive value at $z$ certifies the whole domain; no division by zero is needed.
Signed distance and Hausdorff distance. For a closed set $C$ with $C\ne\emptyset$ and $C^c\ne\emptyset$, a signed distance equals $\mathrm{dist}(x,C)$ on one side of the boundary and $-\mathrm{dist}(x,\text{complement})$ on the other; which side is positive is a declared convention (reachability modules put the safe side positive). It vanishes on the boundary, so "$\ell\gt0$" and "$\ell\ge0$" differ exactly there. The Hausdorff distance $d_H(A,B)=\max\{\sup_{a\in A}\mathrm{dist}(a,B),\sup_{b\in B}\mathrm{dist}(b,A)\}$ compares nonempty compact sets, e.g. $d_H([0,1],[0,2])=1$.
Isometric embeddings. $E:D\to\mathbb R^m$ is isometric if $\|E(x)-E(x')\|=d(x,x')$; e.g. a line $E(t)=x_0+tu$ with $\|u\|=1$. A kernel that depends only on distance, $k=\kappa(d(x,x'))$, is unchanged under such a map; a learned nonlinear embedding is generally not isometric and changes which points count as close.
Practice: Vectors, norms and worst-case directions
Work from Easy to Medium before trying Hard. Use the review link for a missing definition, then try again with the explanation closed.
Exercise A.1a — Easy: Compute a dot product and three lengths
Let $x=(2,-1,2)$ and $y=(1,2,0)$. Find $x^\top y$, $\|x\|_1$, $\|x\|_2$ and $\|x\|_\infty$. Are the vectors perpendicular?
Review: Vectors, norms and worst-case directions
Show hint
Multiply corresponding coordinates for the dot product. Norms use absolute values, squares or the largest absolute coordinate.
Show worked solution
For $x=(2,-1,2)^\top$ and $y=(1,2,0)^\top$, multiply corresponding coordinates and add:
Both vectors are nonzero, so this zero dot product means they are perpendicular in the standard Euclidean inner product.
The one-norm adds absolute coordinates, the two-norm takes the square root of their squared sum, and the infinity-norm takes the largest absolute coordinate:
The negative coordinate contributes positively to every length. In three dimensions, the comparison is $\|x\|_\infty\le\|x\|_2\le\|x\|_1\le\sqrt3\|x\|_2$. Here it reads $2\le3\le5\le3\sqrt3$. For the last inequality both sides are nonnegative, so it is equivalent to $25\le27$. Norms measure size; the dot product also records relative direction.
Exercise A.1b — Medium: Find the worst perturbation in two balls
For $w=(3,-4)$, maximise $w^\top\delta$ subject first to $\|\delta\|_\infty\le0.2$ and then to $\|\delta\|_2\le0.2$. Give a maximiser in each case and verify it.
Review: Vectors, norms and worst-case directions
Show hint
For a box choose each sign separately. For the Euclidean ball align $\delta$ with $w$.
Show worked solution
The objective is $w^\top\delta=3\delta_1-4\delta_2$ for $w=(3,-4)^\top$.
Coordinatewise ball. The constraint $\|\delta\|_\infty\le0.2$ means $|\delta_1|,|\delta_2|\le0.2$. Hence
Choose $\delta=(0.2,-0.2)^\top$. Its infinity-norm is $0.2$, and the objective is $3(0.2)-4(-0.2)=1.4$. An upper bound and a feasible attaining point prove the maximum is $1.4$.
Euclidean ball. First $\|w\|_2=\sqrt{3^2+(-4)^2}=\sqrt{25}=5$. Cauchy–Schwarz gives $w^\top\delta\le|w^\top\delta|\le5\|\delta\|_2\le5(0.2)=1$. Choose the vector in the positive $w$ direction:
It is feasible because $\|\delta\|_2=\sqrt{0.12^2+(-0.16)^2}=\sqrt{0.0144+0.0256}=\sqrt{0.04}=0.2$. Its objective is $3(0.12)-4(-0.16)=0.36+0.64=1$. Thus the Euclidean maximum is $1$.
The Euclidean ball lies inside the coordinatewise ball since each coordinate magnitude is at most the Euclidean norm. The box corner used above has Euclidean length $0.2\sqrt2\gt0.2$, so it is unavailable in the second problem. Equal numerical radii in different norms describe different perturbations.
Exercise A.1c — Hard: Prove that distance cannot change too fast
Let $C$ be a nonempty closed subset of $\mathbb R^n$. Prove $|\operatorname{dist}(x,C)-\operatorname{dist}(y,C)|\le\|x-y\|$. Compute the distance from $(3,4)$ to the closed unit disc, and bound its change after a displacement of Euclidean length at most $0.1$.
Review: Vectors, norms and worst-case directions
Show hint
Choose a closest point in $C$ to $y$, apply the triangle inequality, then interchange $x$ and $y$. A nearest point exists for a closed nonempty set in finite dimensions.
Show worked solution
1. Turn the definition into an inequality. Write $d_x=\inf_{c\in C}\|x-c\|$ and $d_y=\inf_{c\in C}\|y-c\|$. These are finite nonnegative numbers because $C$ is nonempty. For any $\varepsilon\gt0$, the definition of infimum supplies $c_\varepsilon\in C$ with $\|y-c_\varepsilon\|\lt d_y+\varepsilon$. The triangle inequality gives
This holds for every positive $\varepsilon$, so $d_x-d_y\le\|x-y\|$. Otherwise choosing $\varepsilon$ smaller than the positive gap would contradict the displayed bound. Interchanging $x$ and $y$ gives $d_y-d_x\le\|x-y\|$. The two bounds together say $|d_x-d_y|\le\|x-y\|$. This proof works even without closedness; for the closed finite-dimensional set in the question one could instead use an actual nearest point as suggested by the hint.
2. Compute the distance to the disc. The point $x=(3,4)$ has length $5$. Every point $c$ in the closed unit disc has $\|c\|_2\le1$, so the reverse triangle inequality gives $\|x-c\|_2\ge5-1=4$. The point $c=(3/5,4/5)$ lies on the unit circle, and $x-c=(12/5,16/5)$ has length $\sqrt{144+256}/5=4$. A lower bound and a point attaining it prove that the distance is exactly $4$.
3. Carry the displacement bound through the theorem. If $\|x'-x\|_2\le0.1$, then $|\operatorname{dist}(x',C)-4|\le0.1$. Hence the new distance lies in $[3.9,4.1]$. The displacement direction need not be known.
2. Matrix Norms & Operator Norms
A matrix is a map $x\mapsto Ax$; its most useful size is the largest factor by which it stretches a vector, i.e. the Lipschitz constant of the map.
Proofs. $|(Ax)_i|\le\sum_j|a_{ij}|\,\|x\|_\infty$, attained by $x_j=\mathrm{sign}(a_{i^\star j})$ for the worst row $i^\star$. $\|Ax\|_1\le\sum_j|x_j|\sum_i|a_{ij}|$, attained at $x=e_{j^\star}$. Each output coordinate $a_{i,:}x$ is bounded by $\|a_{i,:}\|_q\|x\|_p$ (Hölder, attainable). $\square$ Running example $A=\begin{bmatrix}2 & 2\\ -1 & 1\end{bmatrix}$: $\|A\|_1=3$, $\|A\|_\infty=4$ (at $x=(1,1)$), $\|A\|_{1\to\infty}=2$, $\|A\|_{2\to\infty}=\sqrt8$, $\|A\|_2=2\sqrt2\approx2.83$: the longest semi-axis of the ellipse $A$ makes of the unit circle (Section 5, explorer).
Examples. A column-stochastic $P$ (entries $\ge0$, columns summing to $1$) has $\|P\|_1=1$; for $0\le\gamma\lt1$, $G=(I-\gamma P)^{-1}=\sum_k\gamma^kP^k\ge0$ and $\mathbf 1^\top G=\mathbf 1^\top/(1-\gamma)$, so $\|G\|_1=1/(1-\gamma)$ exactly; for a substochastic (transient) chain $(I-P)^{-1}=\sum_tP^t$ counts expected visits. For $K\succeq0$ with $\|K\|\lt\lambda$: $(K+\lambda I)^{-1}=\lambda^{-1}I-\lambda^{-2}K+\lambda^{-3}K^2-\dots$, with remainder after the $\lambda^{-2}$ term of norm $\le\lambda^{-1}(\|K\|/\lambda)^2/(1-\|K\|/\lambda)=O(\lambda^{-3})$.
The image of a box is a zonotope. For $\varepsilon>0$, $W$ maps $\{\|\delta\|_\infty\le\varepsilon\}$ to a sum of segments $\varepsilon[-w_j,w_j]$ over its columns (a parallelogram for invertible $2\times2$ $W$). The tightest enclosing box has half-widths $\varepsilon\|w_{i,:}\|_1$, which is what interval bound propagation keeps: for $W=\begin{bmatrix}1 & 1\\ 1 & -1\end{bmatrix}$, $\varepsilon=1$, the image is the square with corners $(\pm2,0),(0,\pm2)$, area $8$, inside the box $[-2,2]^2$ of area $16$.
Practice: Matrices as maps and norm bounds
Work from Easy to Medium before trying Hard. Use the review link for a missing definition, then try again with the explanation closed.
Exercise A.2a — Easy: Do not interchange row and column sums
For $A=\begin{bmatrix}1&-2\\0&3\end{bmatrix}$, compute $\|A\|_1$, $\|A\|_\infty$ and $\|A\|_F$. Verify the 1-norm bound at $x=(0,1)$.
Review: Matrices as maps and norm bounds
Show hint
Induced 1-norm uses absolute column sums; induced infinity-norm uses absolute row sums.
Show worked solution
Plan. Use the column-sum formula for the induced 1-norm, the row-sum formula for the induced $\infty$-norm and the entrywise formula for the Frobenius norm; then test the 1-norm bound on $x=(0,1)$.
Step 1 — Recall why column sums give the 1-norm. For any $x$, the triangle inequality applied to each output coordinate, then swapping the order of the two finite sums, gives
The last step replaces every column sum $\sum_i|a_{ij}|$ by the largest one, which can only increase the total because each weight $|x_j|$ is nonnegative.
The basis vector $e_j$ of the column with the largest absolute sum attains the bound, so $\|A\|_1$ is the largest absolute column sum. The same argument with the roles of rows and columns exchanged (bound $|\sum_j a_{ij}x_j|\le\|x\|_\infty\sum_j|a_{ij}|$) shows that $\|A\|_\infty$ is the largest absolute row sum.
Step 2 — Column sums. For $A=\begin{bmatrix}1&-2\\0&3\end{bmatrix}$:
so $\|A\|_1=\max\{1,5\}=5$.
Step 3 — Row sums.
so $\|A\|_\infty=\max\{3,3\}=3$. Swapping the two rules would give the wrong pair $(3,5)$, which is why the title warns against it.
Step 4 — Frobenius norm. Square every entry, add, take the square root:
This treats the four entries as one long vector; it is not an induced norm, so it need not equal either value above.
Step 5 — Test the bound at $x=(0,1)$. Row by column,
Since $\|x\|_1=0+1=1$, the bound $\|Ax\|_1\le\|A\|_1\|x\|_1$ reads $5\le5\cdot1$: it holds with equality. This is expected, because $x=e_2$ selects exactly the column with the largest absolute sum.
Check. The $\infty$-norm is attained too: $x=(1,-1)$ has $\|x\|_\infty=1$ and $Ax=(1+2,\,0-3)=(3,-3)$, so $\|Ax\|_\infty=3=\|A\|_\infty$.
Interpretation. The 1-norm and $\infty$-norm of the same matrix differ ($5$ versus $3$), and negative entries count by their absolute values. A bound quoted for one norm cannot be reused for another.
Exercise A.2b — Medium: Compare a product bound with the actual product
Let $A=\operatorname{diag}(3,1/2)$ and $B=\operatorname{diag}(1/2,3)$. Compute their spectral norms, $AB$, and $\|AB\|_2$. Explain the gap from $\|A\|_2\|B\|_2$.
Review: Matrices as maps and norm bounds
Show hint
A diagonal matrix stretches each coordinate separately. Its spectral norm is the largest absolute diagonal entry.
Show worked solution
Plan. Compute each spectral norm from the diagonal entries, apply the product bound, then multiply the matrices and compare.
Step 1 — Spectral norm of a diagonal matrix. For $D=\operatorname{diag}(d_1,d_2)$,
with equality at the basis vector of the largest $|d_i|$. Hence $\|D\|_2=\max_i|d_i|$. Applied here: $\|A\|_2=\max\{3,1/2\}=3$ (attained at $e_1$) and $\|B\|_2=\max\{1/2,3\}=3$ (attained at $e_2$).
Step 2 — The product bound. Applying the definition of the operator norm twice, $\|ABx\|_2\le\|A\|_2\|Bx\|_2\le\|A\|_2\|B\|_2\|x\|_2$, so
Step 3 — Multiply. Products of diagonal matrices multiply entry by entry on the diagonal:
Step 4 — Its spectral norm. For every $x$, $\|ABx\|_2=\|\tfrac32x\|_2=\tfrac32\|x\|_2$, so every direction is stretched by exactly $1.5$ and $\|AB\|_2=1.5$.
Step 5 — Locate the gap. Follow the two directions through the composition (B acts first):
B stretches $e_2$ by $3$, but A then shrinks that same direction by $1/2$; A would stretch $e_1$ by $3$, but B has already shrunk it by $1/2$. The bound $9$ would require one direction that both maps stretch maximally, and no such direction exists. The bound overestimates by the factor $9/1.5=6$.
Check. Diagonal matrices commute, so $BA=\tfrac32I$ as well; and $1.5\le9$ is consistent with the theorem.
Interpretation. Submultiplicativity is always valid but is tight only when the largest output direction of B is a largest input direction of A. Chaining norm bounds through many layers can therefore be very conservative.
Exercise A.2c — Hard: Bound a truncated matrix geometric series
For $A=\operatorname{diag}(1/2,1/4)$, compute $(I-A)^{-1}$. Let $S_T=\sum_{k=0}^{T-1}A^k$. Find the exact spectral norm of $(I-A)^{-1}-S_T$ and the smallest $T$ making it at most $0.01$.
Review: Matrices as maps and norm bounds
Show hint
Apply the scalar geometric-tail formula to each diagonal entry, then take the larger tail.
Show worked solution
1. Sum each diagonal entry. Here $A=\operatorname{diag}(1/2,1/4)$, so $A^t=\operatorname{diag}((1/2)^t,(1/4)^t)$. For a scalar $r\ne1$, multiplying $1+r+\cdots+r^{T-1}$ by $1-r$ cancels every middle term and leaves $1-r^T$. Therefore
Both powers tend to zero as $T$ grows. Thus the infinite sum is $\operatorname{diag}(2,4/3)=(I-A)^{-1}$, and subtracting the finite sum gives the exact remainder $\operatorname{diag}(2^{1-T},(4/3)4^{-T})$.
2. Take the spectral norm. A diagonal matrix stretches coordinate axes by the absolute values of its diagonal entries, so its spectral norm is the larger one. Their ratio is $2^{1-T}/[(4/3)4^{-T}]=(3/2)2^T\ge1$ for $T\ge0$. The remainder norm is consequently $2^{1-T}$.
3. Find the first acceptable integer. The tolerance requires $2^{1-T}\le0.01$, equivalently $2^T\ge200$. Since $2^7=128\lt200$ and $2^8=256\ge200$, the smallest $T$ is $8$. This means the eight terms $A^0$ through $A^7$. The errors at $T=7$ and $T=8$ are respectively $1/64=0.015625$ and $1/128=0.0078125$, confirming the cutoff.
3. Symmetric Matrices & the Spectral Theorem
In a first course eigenvalues can be complex (a rotation has no real ones) and eigenvectors can be missing (the shear $\begin{bmatrix}1 & 1\\ 0 & 1\end{bmatrix}$ has one direction). Symmetric matrices, $A=A^\top$, have neither problem, and every certificate matrix in the modules is symmetric.
Two short proofs. Real eigenvalues: if $Av=\lambda v$, $v\ne0$ complex, then $v^*Av=\lambda v^*v$; the number $v^*Av$ equals its own conjugate $v^*A^\top v=v^*Av$, so it is real, hence so is $\lambda$ (and the real singular matrix $A-\lambda I$ has a real null vector). Orthogonality: if $Av=\lambda v$, $Aw=\mu w$, $\lambda\ne\mu$, then $\lambda v^\top w=(Av)^\top w=v^\top Aw=\mu v^\top w$, so $v^\top w=0$.
Example. $A=\begin{bmatrix}2 & 1\\ 1 & 2\end{bmatrix}$: $(2-\lambda)^2-1=0$ gives $\lambda_1=3$, $\lambda_2=1$, $q_1=(1,1)/\sqrt2$, $q_2=(1,-1)/\sqrt2$, and $3q_1q_1^\top+q_2q_2^\top=\tfrac32\begin{bmatrix}1 & 1\\ 1 & 1\end{bmatrix}+\tfrac12\begin{bmatrix}1 & -1\\ -1 & 1\end{bmatrix}=A$. In words: this positive-definite example is a pure stretch along perpendicular axes (by $3$ along the diagonal and by $1$ across it), with no rotation or shear.
Functions of a symmetric matrix. $f(A)=Qf(\Lambda)Q^\top=\sum_if(\lambda_i)q_iq_i^\top$ agrees with powers, polynomials and $A^{-1}$ (all $\lambda_i\ne0$), gives $(A+\eta I)^{-1}=\sum_i(\lambda_i+\eta)^{-1}q_iq_i^\top$ (all $\lambda_i+\eta\ne0$) and square roots (Section 4). Functions of one $A$ share its eigenvectors, so comparing them reduces to comparing scalars eigenvalue by eigenvalue: for $K\succeq0$ and $\eta\gt0$, $K(K+\eta I)^{-1}$ has eigenvalues $\lambda_i/(\lambda_i+\eta)\in[0,1)$.
Proof. With $y=Q^\top x$ ($\|y\|=\|x\|$): $x^\top Ax=\sum_i\lambda_iy_i^2\le\lambda_{\max}\|x\|^2$, and similarly from below. $\square$ For the example, $x=(1,0)$ gives $2$ and $x=(1,1)/\sqrt2$ gives $3=\lambda_{\max}$. A Lyapunov function $x^\top Px$ is thus squeezed between $\lambda_{\min}(P)\|x\|^2$ and $\lambda_{\max}(P)\|x\|^2$.
Complex matrices. $M$ is Hermitian if $M^*=M$. Everything above holds with $^\top$ replaced by $^*$: real eigenvalues, $M=U\Lambda U^*$ with $U$ unitary ($U^*U=I$), and $v^*Mv$ real for all complex $v$. Example: $\begin{bmatrix}2 & i\\ -i & 2\end{bmatrix}$ has eigenvalues $3,1$, and $v=(1,i)$ gives $v^*Mv=2$. Hermitian semidefiniteness ($v^*Mv\ge0$ for all $v\in\mathbb C^n$) is the complex version of Section 4.
The Jacobi method repeatedly applies a plane rotation $J$ in coordinates $(p,q)$, $A\leftarrow J^\top AJ$, with $\tan2\theta=2a_{pq}/(a_{pp}-a_{qq})$ zeroing the $(p,q)$ entry. Each step keeps the eigenvalues and removes $2a_{pq}^2$ from the off-diagonal sum of squares $\mathrm{off}=\sum_{i\ne j}a_{ij}^2$. Convergence needs a pivot rule (repeatedly choosing an entry that is already zero changes nothing): if $(p,q)$ is the off-diagonal entry of largest magnitude, $a_{pq}^2\ge\mathrm{off}/(n(n-1))$, so each step shrinks $\mathrm{off}$ by at least the factor $1-2/(n(n-1))$ and $A\to\mathrm{diag}(\lambda_i)$ (cyclic sweeps over all pairs also converge); the rotations multiply to $Q$. For $\begin{bmatrix}2 & 1\\ 1 & 2\end{bmatrix}$ one $45^\circ$ rotation finishes.
In double precision (unit roundoff $\approx1.1\times10^{-16}$) computed eigenvalues carry errors of order $10^{-16}\|A\|$: a computed $\lambda_{\min}=10^{-15}$ does not prove $A\succeq0$. Rigorous checks test a margin ($A-\tau I\succ0$ with $\tau$ above an error bound) or use exact or interval arithmetic.
Practice: Eigenvectors, quadratic forms and spectral limits
Work from Easy to Medium before trying Hard. Use the review link for a missing definition, then try again with the explanation closed.
Exercise A.3a — Easy: Verify an orthonormal eigenbasis
Let $A=\begin{bmatrix}3&1\\1&3\end{bmatrix}$. Verify that $q_+=(1,1)/\sqrt2$ and $q_-=(1,-1)/\sqrt2$ are orthonormal eigenvectors. State their eigenvalues.
Review: Eigenvectors, quadratic forms and spectral limits
Show hint
You can verify a proposed eigenvector directly by multiplying, without solving a determinant.
Show worked solution
Plan. Multiply $A$ by each proposed vector and recognise a scalar multiple; then check unit length and perpendicularity; finally rebuild $A$ from the pieces.
Step 1 — Test $q_+$. Work with the unscaled vector $(1,1)$ first; the factor $1/\sqrt2$ can be pulled out because matrix multiplication is linear.
Multiplying both sides by $1/\sqrt2$ gives $Aq_+=4q_+$: $q_+$ is an eigenvector with eigenvalue $4$.
Step 2 — Test $q_-$.
so $Aq_-=2q_-$: eigenvalue $2$.
Step 3 — Orthonormality. Unit length and zero dot product:
This is what the spectral theorem predicts: $A$ is symmetric and the two eigenvalues are distinct, so the eigenvectors must be perpendicular.
Step 4 — Rebuild $A$ (spectral decomposition). The outer products are $q_+q_+^\top=\tfrac12\begin{bmatrix}1&1\\1&1\end{bmatrix}$ and $q_-q_-^\top=\tfrac12\begin{bmatrix}1&-1\\-1&1\end{bmatrix}$, so
Check. The eigenvalues must add to the trace and multiply to the determinant: $4+2=6=3+3$ and $4\cdot2=8=3\cdot3-1\cdot1$. Both agree.
Interpretation. $A$ stretches by $4$ along the diagonal direction $(1,1)$ and by $2$ along the perpendicular direction $(1,-1)$; it is a pure stretch along perpendicular axes, with no rotation.
Exercise A.3b — Medium: Use the Rayleigh bound and recognise equality
For the matrix of the Easy exercise and $x=(1,2)$, compute $x^\top Ax$ and the Rayleigh quotient. Check the eigenvalue bounds, then give directions attaining both bounds.
Review: Eigenvectors, quadratic forms and spectral limits
Show hint
The Rayleigh quotient divides the quadratic form by $x^\top x$, so you need not normalise $x$ explicitly.
Show worked solution
Plan. Compute the quadratic form and the Rayleigh quotient directly, then explain the bounds by writing $x$ in the orthonormal eigenbasis from Exercise A.3a ($\lambda=4$ along $q_+$, $\lambda=2$ along $q_-$).
Step 1 — The quadratic form.
Step 2 — The Rayleigh quotient. With $x^\top x=1^2+2^2=5$,
Step 3 — Why the bounds hold. $A$ is symmetric, so by the spectral theorem we may write $x=c_+q_++c_-q_-$ with $c_\pm=q_\pm^\top x$. Here
Since $Aq_+=4q_+$ and $Aq_-=2q_-$, linearity gives $Ax=4c_+q_++2c_-q_-$. Multiplying out and using $q_+^\top q_+=q_-^\top q_-=1$, $q_+^\top q_-=0$:
Replacing the weight $4$ by $2$, or the weight $2$ by $4$, gives
that is, $\lambda_{\min}\|x\|^2\le x^\top Ax\le\lambda_{\max}\|x\|^2$ with $\lambda_{\min}=2$, $\lambda_{\max}=4$.
Step 4 — Check the numbers. $c_+^2=9/2$ and $c_-^2=1/2$, so $c_+^2+c_-^2=5=x^\top x$ and $4(9/2)+2(1/2)=18+1=19=x^\top Ax$. The bounds read
Step 5 — When equality holds. Subtracting, $4\|x\|^2-x^\top Ax=2c_-^2$ and $x^\top Ax-2\|x\|^2=2c_+^2$. The upper bound is an equality exactly when $c_-=0$, i.e. $x$ is a nonzero multiple of $(1,1)$; the lower bound exactly when $c_+=0$, i.e. $x$ is a nonzero multiple of $(1,-1)$. Directly: $(1,1)$ gives $Ax=(4,4)$, quotient $8/2=4$; $(1,-1)$ gives $Ax=(2,-2)$, quotient $4/2=2$.
Check. At $x=(1,2)$ both $c_+$ and $c_-$ are nonzero, so both inequalities are strict, as observed. In fact $3.8$ is the weighted average $\tfrac{9}{10}\cdot4+\tfrac{1}{10}\cdot2$ with weights $c_\pm^2/\|x\|^2$.
Interpretation. The Rayleigh quotient is always an average of the eigenvalues, weighted by how much of $x$ lies in each eigendirection; that is why it can never leave $[\lambda_{\min},\lambda_{\max}]$.
Exercise A.3c — Hard: Positive eigenvalues can hide a negative quadratic form
For $N=\begin{bmatrix}1&4\\0&1\end{bmatrix}$, compute its eigenvalues and $x^\top Nx$ at $x=(1,-1)$. Find the symmetric part $S=(N+N^\top)/2$ and its eigenvalues. Explain why the spectral theorem cannot be applied to N.
Review: Eigenvectors, quadratic forms and spectral limits
Show hint
For an upper triangular matrix, the eigenvalues are on the diagonal. A real quadratic form uses only the symmetric part.
Show worked solution
Plan. Get the eigenvalues of $N$ from its characteristic polynomial, evaluate the form at $x=(1,-1)$, then split $N$ into symmetric and skew parts to see which part the form actually measures.
Step 1 — Eigenvalues of $N$. For a triangular matrix the determinant is the product of the diagonal:
So $\lambda=1$ is a double eigenvalue. Its eigenvectors solve $(N-I)v=\begin{bmatrix}0&4\\0&0\end{bmatrix}v=0$, i.e. $4v_2=0$: only multiples of $(1,0)$. There is a single eigendirection, so $N$ has no eigenbasis at all.
Step 2 — The form at $x=(1,-1)$.
Both eigenvalues are positive, yet the form is negative.
Step 3 — Symmetric and skew parts.
and $S+K=N$, $S^\top=S$, $K^\top=-K$.
Step 4 — Eigenvalues of $S$. $\det(S-\lambda I)=(1-\lambda)^2-4=0$ gives $1-\lambda=\pm2$, so $\lambda=3$ or $\lambda=-1$. Checking directions: $S(1,1)^\top=(3,3)^\top=3(1,1)^\top$ and $S(1,-1)^\top=(1-2,\,2-1)^\top=(-1,1)^\top=-1\cdot(1,-1)^\top$.
Step 5 — Why only $S$ matters. The number $x^\top Kx$ is a $1\times1$ matrix, so it equals its own transpose:
(Directly: $x^\top Kx=2x_1x_2-2x_2x_1=0$.) Hence $x^\top Nx=x^\top Sx+x^\top Kx=x^\top Sx$. Our $x=(1,-1)$ is the eigenvector of $S$ for $-1$, so $x^\top Sx=-1\cdot\|x\|^2=-1\cdot2=-2$, matching Step 2.
Step 6 — Assumption audit. The spectral theorem requires a real symmetric matrix. $N$ is not symmetric (entry $(1,2)$ is $4$, entry $(2,1)$ is $0$), so none of its conclusions transfer: there is no orthonormal eigenbasis (Step 1) and the bound $x^\top Nx\ge\lambda_{\min}\|x\|^2$ fails (it would claim $x^\top Nx\ge2$ at our $x$, but the value is $-2$).
Check. $\operatorname{tr}S=2=3+(-1)$ and $\det S=1-4=-3=3\cdot(-1)$.
Interpretation. To decide the sign of a quadratic form, symmetrise first and apply positivity tests to $S$. Eigenvalues of a non-symmetric matrix describe invariant directions, not the sign of $x^\top Nx$.
4. Positive (Semi)Definite Matrices & Quadratic Forms
A quadratic form is $q(x)=x^\top Px=\sum_{ij}p_{ij}x_ix_j$; only the symmetric part of $P$ matters, so take $P\in\mathbb S^n$. In the plane, if $p_{11}\gt0$, completing the square gives $$q(x)=p_{11}\Big(x_1+\frac{p_{12}}{p_{11}}x_2\Big)^2+\Big(p_{22}-\frac{p_{12}^2}{p_{11}}\Big)x_2^2,$$ so $q\gt0$ for all $x\ne0$ iff $p_{11}\gt0$ and $p_{11}p_{22}-p_{12}^2\gt0$. The second coefficient is our first Schur complement (Section 6).
Examples. $\begin{bmatrix}1 & 2\\ 2 & 1\end{bmatrix}$ has positive entries, yet $x=(1,-1)$ gives $-2$: indefinite. $\begin{bmatrix}1 & -1\\ -1 & 1\end{bmatrix}$ gives $(x_1-x_2)^2\ge0$: PSD and singular. For diagonal matrices the notions agree: $T=\mathrm{diag}(\lambda_i)\succeq0$ iff every $\lambda_i\ge0$. In the plane, the level sets $q=1$ are ellipses (PD), two parallel lines (nonzero singular PSD) or hyperbolas (indefinite); for the zero matrix this level set is empty: see the explorer.
$P\succeq0$ $\iff$ all eigenvalues $\ge0$ $\iff$ all principal minors $\ge0$ (so $p_{ii}\ge0$) $\iff$ $P=R^\top R$ for some $R$.
Minors. A principal minor is $\det P[I,I]$, the determinant of the submatrix that keeps the same index set $I$ of rows and columns; the leading ones use $I=\{1,\dots,k\}$. A $3\times3$ matrix has $3$ leading principal minors ($p_{11}$, the top-left $2\times2$ determinant, $\det P$) but $7$ nonempty principal minors (also $p_{22}$, $p_{33}$ and the determinants for $I=\{1,3\}$ and $\{2,3\}$).
Proof of (a), (d). With $y=Q^\top x$, $x^\top Px=\sum_i\lambda_iy_i^2$: positive for all $y\ne0$ iff all $\lambda_i\gt0$ (take $x=q_i$). If $P=R^\top R$, $x^\top Px=\|Rx\|^2$, positive for $x\ne0$ iff $R$ has independent columns; conversely take $R=\Lambda^{1/2}Q^\top$. $\square$ Module 5's Gram matrix $K=\begin{bmatrix}1 & 0 & 0\\ 0 & 1 & 2\\ 0 & 2 & 5\end{bmatrix}$ has leading minors $1,1,1$, so $K\succ0$ (eigenvalues $3\mp2\sqrt2$, $1$).
4.1 Gram matrices, outer products and regularisation
For any $R$, $R^\top R\succeq0$ and $RR^\top\succeq0$ ($x^\top R^\top Rx=\|Rx\|^2$); $R^\top R\succ0$ iff $R$ has independent columns. For $\epsilon\gt0$, $x^\top(\epsilon I+R^\top R)x=\epsilon\|x\|^2+\|Rx\|^2\gt0$ ($x\ne0$), so $\epsilon I+R^\top R\succ0$ is invertible: a neural certificate uses this to get $\|(\epsilon I+R^\top R)(\xi-\xi^\ast)\|_1\gt0$ for $\xi\ne\xi^\ast$. Likewise $K+\lambda I\succ0$ for a kernel matrix $K\succeq0$ and $\lambda\gt0$, so a regularised GP never fails Cholesky in exact arithmetic. The outer product $aa^\top$ is PSD, of rank one when $a\ne0$ and $0$ when $a=0$ ($v^\top aa^\top v=(a^\top v)^2$; for $a\ne0$, eigenvalue $\|a\|^2$ on $a$, $0$ on $a^\perp$), and adding $\beta aa^\top$, $\beta\ge0$, is a PSD increase: the quadratic form grows by $\beta(a^\top v)^2$ and decreases nowhere (whether a damped loop then converges faster is a separate question).
4.2 The Loewner order, congruence and the PSD cone
Meaning and facts. $\mathrm{Var}(u^\top X)=u^\top\Sigma u$, so $\Sigma_1\succeq\Sigma_2$ means at least as much variance in every direction (a "consistent" uncertainty estimate never under-reports). $\lambda_{\min}(A)I\preceq A\preceq\lambda_{\max}(A)I$; $A\succeq B$ implies $\lambda_i(A)\ge\lambda_i(B)$ for each ordered eigenvalue (Courant–Fischer) and $\mathrm{tr}A\ge\mathrm{tr}B$; and, for $\gamma\ge0$, $\|W\|_2\le\gamma\iff W^\top W\preceq\gamma^2I$ (both say $\|Wx\|^2\le\gamma^2\|x\|^2$; squaring loses the sign of $\gamma$).
Example. $T=\begin{bmatrix}1 & -2\\ 0 & 1\end{bmatrix}$ turns $M=\begin{bmatrix}1 & 2\\ 2 & 1\end{bmatrix}$ into $T^\top MT=\mathrm{diag}(1,-3)$: it completed the square, changed the eigenvalues ($3,-1$) but not their signs (Sylvester's law of inertia). The PSD cone: $A,B\succeq0$, $\alpha,\beta\ge0\Rightarrow\alpha A+\beta B\succeq0$, so PSD matrices form a convex cone (Primer B) with the PD matrices as interior; for $2\times2$, $\begin{bmatrix}a & b\\ b & c\end{bmatrix}\succeq0\iff a,c\ge0,\ ac\ge b^2$. A linear matrix inequality $F_0+\sum_iz_iF_i\succeq0$ is a convex constraint on $z$ (Module 2).
4.3 Square roots, weighted norms and ellipsoids
Example. $\begin{bmatrix}2 & 1\\ 1 & 2\end{bmatrix}^{1/2}=\sqrt3\,q_1q_1^\top+q_2q_2^\top=\tfrac12\begin{bmatrix}\sqrt3+1 & \sqrt3-1\\ \sqrt3-1 & \sqrt3+1\end{bmatrix}\approx\begin{bmatrix}1.366 & 0.366\\ 0.366 & 1.366\end{bmatrix}$. Weighted norms. For $H\succ0$, $\|x\|_H=\sqrt{x^\top Hx}=\|H^{1/2}x\|$, and $|g^\top x|=|(H^{-1/2}g)^\top(H^{1/2}x)|\le\|g\|_{H^{-1}}\|x\|_H$, with equality for $x\propto H^{-1}g$. Steps live in the $H$-norm, gradients in the $H^{-1}$-norm: $\max\{g^\top x:\tfrac12x^\top Hx\le\delta\}=\sqrt{2\delta\,g^\top H^{-1}g}$ for $\delta\ge0$, at $x^\star\propto H^{-1}g$ if $g\ne0$ (the natural-gradient step), and $\varphi^\top V^{-1}\varphi$ is a "squared $V^{-1}$-norm". For $a\ne0$ the $H$-norm projection of $u_0$ onto $\{a^\top u\ge b\}$ moves along $H^{-1}a$: $u^\star=u_0+[b-a^\top u_0]_+H^{-1}a/(a^\top H^{-1}a)$, with the positive part $[t]_+=\max\{t,0\}$ (no move if $u_0$ is already feasible). For $a=0$ the set is all of $\mathbb R^n$ if $b\le0$ and empty if $b\gt0$. A merely PSD $H$ may be singular; the damped $H+\epsilon I\succ0$ is not.
Inversion reverses the order. If $A\succeq B\succ0$, congruence gives $B^{-1/2}AB^{-1/2}\succeq I$; its eigenvalues are $\ge1$, those of its inverse $B^{1/2}A^{-1}B^{1/2}$ are $\le1$, and congruence again gives $A^{-1}\preceq B^{-1}$.
Generalised eigenvalues: for $A\succeq0$, $M\succ0$, the nonsymmetric $AM^{-1}=M^{1/2}(M^{-1/2}AM^{-1/2})M^{-1/2}$ is similar to a symmetric PSD matrix, so its eigenvalues are real and $\ge0$, $\lambda_{\max}(AM^{-1})=\max_{x\ne0}x^\top Ax/x^\top Mx$, and for $F\ge0$: $M-FA\succeq0\iff F\lambda_{\max}(AM^{-1})\le1$.
Reading off sizes ($c=0$). Cauchy–Schwarz with $y=P^{1/2}x$ gives $\max_{\mathcal E}a^\top x=\sqrt{a^\top Sa}$, so the enclosing box has half-widths $\sqrt{S_{ii}}$ and the farthest point lies at $1/\sqrt{\lambda_{\min}(P)}=\sqrt{\lambda_{\max}(S)}$. For $P=\begin{bmatrix}2 & 1\\ 1 & 2\end{bmatrix}$: semi-axes $1/\sqrt3$ along $(1,1)$ and $1$ along $(1,-1)$, area $\pi/\sqrt3\approx1.81$. The slice $x_2=0$ has half-width $1/\sqrt{p_{11}}\approx0.707$, the projection (shadow) on $x_1$ has $\sqrt{S_{11}}=\sqrt{2/3}\approx0.816$: minimising over $x_2$ leaves the Schur complement $p_{11}-p_{12}^2/p_{22}=1.5$. Slices underestimate projections unless $p_{12}=0$.
4.4 Cholesky factorisation and linear solves
Worked example. $P=\begin{bmatrix}4 & 2 & -2\\ 2 & 5 & 1\\ -2 & 1 & 3\end{bmatrix}$: $L_{11}=2$, $L_{21}=1$, $L_{31}=-1$, $L_{22}=\sqrt{5-1}=2$, $L_{32}=(1+1)/2=1$, $L_{33}=\sqrt{3-1-1}=1$. To solve $Px=b$, $b=(2,7,5)$, never form $P^{-1}$: solve $Ly=b$ forwards, $y=(1,3,3)$, then $L^\top x=y$ backwards, $x=(2,0,3)$ (each $\approx n^2$ operations). $\log\det P=2\sum_j\log L_{jj}=\log16$.
Setting for Algorithm 1. Given observations $y_i=f(x_i)+\varepsilon_i$ at inputs $x_1,\dots,x_t$ ($y=(y_1,\dots,y_t)$), take a zero-mean GP prior on $f$ with kernel $k$ and noise $\varepsilon_i\sim\mathcal N(0,\sigma_n^2)$, $\sigma_n^2\gt0$, independent of each other and of $f$. Write $K_{ij}=k(x_i,x_j)$ for the prior covariances among the data and $k(x)=(k(x_i,x))_{i\le t}$ for those between the data and a new input $x$. The algorithm returns the posterior mean and variance of the latent function value at $x$; a new noisy observation there has variance $\sigma_t^2(x)+\sigma_n^2$. The probabilistic reading is in Primer C; here it is linear algebra, two triangular solves instead of an inverse.
- Factor $K+\sigma_n^2I=LL^\top$ (it exists because $\sigma_n^2\gt0$).
- $\alpha=L^{-\top}(L^{-1}y)$ by two triangular solves; mean $\mu_t(x)=k(x)^\top\alpha$.
- $v=L^{-1}k(x)$; variance $\sigma_t^2(x)=k(x,x)-v^\top v$; $\log\det(K+\sigma_n^2I)=2\sum_i\log L_{ii}$.
Orientation. NumPy's cholesky returns lower $L$ ($P=LL^\top$), MATLAB's chol upper $R=L^\top$ ($P=R^\top R$). Module 13 writes $F=L^\top L$ with an upper-type $L$; a library's lower factor silently transposes its formulas. Conjugate gradients solve $Hx=g$ for $H\succ0$ using only products $v\mapsto Hv$ (Fisher-vector products), by minimising $\tfrac12x^\top Hx-g^\top x$ over growing subspaces until the residual $r_k=g-Hx_k$ has $\|r_k\|\le\mathrm{tol}\|g\|$; the output exactly solves $Hx=g-r_k$, and the $H$-norm error shrinks at least like $2\big((\sqrt\kappa-1)/(\sqrt\kappa+1)\big)^k$ (Section 5).
Sum-of-squares certificates. If $p(x)=z(x)^\top Qz(x)$ with a vector of monomials $z(x)$ and $Q=\sum_il_il_i^\top\succeq0$, then $p=\sum_i(l_i^\top z)^2\ge0$; e.g. $z=(1,x,x^2)$, $Q=\mathbf 1\mathbf 1^\top$ gives $x^4+2x^3+3x^2+2x+1=(1+x+x^2)^2$. Finding such a $Q$ is an SDP; the test is only sufficient (some nonnegative polynomials are not SOS).
Practice: Definiteness, factors and ellipsoid support
Work from Easy to Medium before trying Hard. Use the review link for a missing definition, then try again with the explanation closed.
Exercise A.4a — Easy: Classify by the quadratic form
Classify $P=\operatorname{diag}(2,0)$ and $Q=\begin{bmatrix}2&3\\3&2\end{bmatrix}$ as positive definite, singular positive semidefinite or indefinite. Supply vectors witnessing any failure of positive definiteness.
Review: Definiteness, factors and ellipsoid support
Show hint
Expand $x^\top Px$. For Q compare $(1,1)$ with $(1,-1)$.
Show worked solution
Plan. Expand each quadratic form $x^\top Mx$ as a polynomial in $x_1,x_2$, then test it on well-chosen vectors. Recall the definitions: PSD means $x^\top Mx\ge0$ for all $x$; PD means $x^\top Mx\gt0$ for all $x\ne0$; indefinite means both signs occur.
Step 1 — Expand the form of $P$.
A real square is never negative, so $2x_1^2\ge0$ for every $x$: $P$ is PSD.
Step 2 — Show $P$ is not PD, and is singular. The nonzero vector $x=(0,1)$ gives $x^\top Px=2\cdot0^2=0$, which violates the strict inequality required for PD. Moreover $P(0,1)^\top=(0,0)^\top$, so $P$ has a nonzero null vector and $\det P=2\cdot0=0$. Classification: singular positive semidefinite.
Step 3 — Expand the form of $Q$. The off-diagonal entry $3$ appears twice (positions $(1,2)$ and $(2,1)$):
Step 4 — Evaluate in two directions.
The form takes both signs, so $Q$ is indefinite; the vector $(1,-1)$ witnesses the failure of PSD (and hence of PD).
Check. $\det Q=2\cdot2-3\cdot3=-5\lt0$, and the determinant is the product of the two eigenvalues, so they have opposite signs. Indeed $Q(1,1)^\top=5(1,1)^\top$ and $Q(1,-1)^\top=(2-3,3-2)^\top=-1\cdot(1,-1)^\top$, which reproduces the values $5\cdot2=10$ and $-1\cdot2=-2$ found above. For $P$ the eigenvalues are simply $2$ and $0$.
Interpretation. All entries of $Q$ are positive, but definiteness asks about every direction, including mixed-sign ones where the cross term $6x_1x_2$ is negative. A single negative value disproves PSD; a single zero at a nonzero vector disproves PD but not PSD.
Exercise A.4b — Medium: Solve with a Cholesky factor
Factor $P=\begin{bmatrix}4&2\\2&2\end{bmatrix}=LL^\top$ with L lower triangular and positive diagonal. Use two triangular solves to solve $Px=(6,4)^\top$, and compute $\log\det P$.
Review: Definiteness, factors and ellipsoid support
Show hint
Set $L_{11}=\sqrt4$, then obtain $L_{21}$ from the off-diagonal entry and $L_{22}$ from the remaining diagonal.
Show worked solution
1. Construct the factor. Seek a lower triangular matrix $L=\begin{bmatrix}\ell_{11}&0\\\ell_{21}&\ell_{22}\end{bmatrix}$ with positive diagonal and $LL^\top=P=\begin{bmatrix}4&2\\2&2\end{bmatrix}$. Multiplication gives the three equations $\ell_{11}^2=4$, $\ell_{11}\ell_{21}=2$, and $\ell_{21}^2+\ell_{22}^2=2$. Solving in that order gives $\ell_{11}=2$, $\ell_{21}=1$, and $\ell_{22}=1$. Hence $L=\begin{bmatrix}2&0\\1&1\end{bmatrix}$.
2. Solve $Px=(6,4)^\top$ without forming an inverse. Because $P=LL^\top$, first solve $Ly=(6,4)^\top$: $2y_1=6$ gives $y_1=3$, and $y_1+y_2=4$ gives $y_2=1$. Next solve $L^\top x=y$: the bottom equation is $x_2=1$, and the top is $2x_1+x_2=3$, giving $x_1=1$. Thus $x=(1,1)$; direct multiplication gives $Px=(4+2,2+2)=(6,4)$.
3. Read the determinant from the factor. The determinant of a triangular matrix is the product of its diagonal entries. Therefore $\det P=(\det L)^2=(2\cdot1)^2=4$, and $\log\det P=2(\log2+\log1)=\log4$. The positive pivots also make $L$ invertible, so $x^\top Px=\|L^\top x\|_2^2\gt0$ for every nonzero $x$: the factor verifies positive definiteness.
Exercise A.4c — Hard: Maximise a linear margin over an ellipsoid
Let $P=\operatorname{diag}(4,1)$ and $\mathcal E=\{x:x^\top Px\le1\}$. Find $\max_{x\in\mathcal E}(x_1+2x_2)$, a maximiser, and the two semi-axis lengths. Derive the maximum rather than only citing the formula.
Review: Definiteness, factors and ellipsoid support
Show hint
Change variables to $u=P^{1/2}x$. The constraint becomes a unit ball and the objective becomes an inner product.
Show worked solution
1. Remove the unequal coordinate scales. The constraint is $4x_1^2+x_2^2\le1$. Set $u=(2x_1,x_2)$; then $\|u\|_2\le1$, $x_1=u_1/2$, and $x_2=u_2$. The objective becomes $x_1+2x_2=(1/2,2)^\top u$.
2. Find an upper bound and attain it. With $w=(1/2,2)$, Cauchy–Schwarz gives $w^\top u\le\|w\|_2\|u\|_2\le\sqrt{1/4+4}=\sqrt{17}/2$. Equality holds at $u=w/\|w\|_2=(1,4)/\sqrt{17}$. Transforming back gives $x^\star=(1/(2\sqrt{17}),4/\sqrt{17})$.
3. Check both claims. At this point $4(x_1^\star)^2+(x_2^\star)^2=1/17+16/17=1$, so it is feasible. Its objective is $1/(2\sqrt{17})+8/\sqrt{17}=17/(2\sqrt{17})=\sqrt{17}/2$, meeting the upper bound. The maximum is therefore exactly $\sqrt{17}/2$.
The ellipsoid has coordinate half-widths $1/2$ and $1$. The maximizing direction is proportional to $P^{-1}(1,2)^\top=(1/4,2)^\top$, where $P=\operatorname{diag}(4,1)$. The inverse weights compensate for the constraint's unequal scales; pointing along the Euclidean objective vector would not in general attain the bound.
5. The Singular Value Decomposition
Eigenvalues can be complex and say little about stretching. The SVD exists for every matrix, rectangular or not, and describes exactly how it stretches.
Geometry. Read $U\Sigma V^\top x$ right to left: rotate or reflect by $V^\top$, stretch coordinate $i$ by $\sigma_i$, rotate or reflect by $U$. The unit ball becomes a filled, possibly flat ellipsoid with semi-axes $\sigma_iu_i$ ($i\le r$), and $v_1$ is the most-stretched input direction. For an injective $A$ the unit sphere maps onto the boundary of this ellipsoid within $\mathrm{range}(A)$ (an invertible $2\times2$ matrix turns the circle into an ellipse); if $A$ has a nontrivial null space, the sphere covers the whole filled ellipsoid ($A=\begin{bmatrix}1 & 0\end{bmatrix}$ maps the unit circle onto $[-1,1]$).
Consequences. (1) $\|A\|_2=\sigma_1$, because $\max_{\|x\|=1}\|Ax\|^2=\max_{\|x\|=1}x^\top A^\top Ax=\lambda_{\max}(A^\top A)$ (Rayleigh). Hence $\|A^\top\|_2=\|A\|_2$ and $\|A\|_F^2=\sum_i\sigma_i^2$; for $n\le m$, $\sigma_n=\min_{\|x\|=1}\|Ax\|$. (2) $\mathrm{range}(A)=\mathrm{span}(u_1,\dots,u_r)$ and $\mathrm{null}(A)=\mathrm{span}(v_{r+1},\dots,v_n)$: orthonormal bases of both, e.g. the nullspace basis of elimination arguments. (3) Keeping $k$ terms gives the best rank-$k$ approximation, with spectral error $\sigma_{k+1}$ (Eckart–Young).
5.1 Conditioning and the pseudo-inverse
Why Gram matrices become ill-conditioned. $K^{-1}y=\sum_i(q_i^\top y/\lambda_i)q_i$ amplifies components along small-eigenvalue directions by $1/\lambda_i$. Two inputs $0.01$ apart under a squared-exponential kernel with length scale $1$ give $K=\begin{bmatrix}1 & 0.99995\\ 0.99995 & 1\end{bmatrix}$, eigenvalues $1.99995$ and $5\times10^{-5}$, $\kappa\approx4\times10^4$; adding $\lambda=0.01$ lifts the small one to $0.01005$ and $\kappa\approx200$. Sixty close grid points are far worse.
Range conditions. $b\in\mathrm{range}(A)\iff(I-AA^+)b=0$. Module 2 writes $C^\dagger$ and $(I-CC^\dagger)B^\top=0$ (the columns of $B^\top$ lie in $\mathrm{range}(C)$), Module 9 $G^+$, Module 13 $(A^\top)^+$: the same object. Example: $\begin{bmatrix}1 & 2\\ 2 & 4\end{bmatrix}=5uu^\top$, $u=(1,2)/\sqrt5$, has rank 1 and pseudo-inverse $\tfrac15uu^\top$.
5.2 Power iteration and matrix factors
- Pick a unit $x_0$ (random, so that $v_1^\top x_0\ne0$ almost surely).
- For $k=0,1,\dots$: $x_{k+1}=A^\top Ax_k/\|A^\top Ax_k\|$ (needs $A^\top Ax_k\ne0$); estimate $\hat\sigma_k=\|Ax_k\|$.
Since $\|Ax\|\le\sigma_1$ for every unit $x$, every estimate is a lower bound. If $\sigma_1\gt\sigma_2$ and $v_1^\top x_0\ne0$, the angle to $v_1$ shrinks like $(\sigma_2/\sigma_1)^{2k}$, slowly when $\sigma_2\approx\sigma_1$; if $\sigma_1=\sigma_2\gt0$, there is no single dominant $v_1$; provided $x_0$ has a nonzero projection onto the dominant right-singular subspace, $x_k$ approaches that subspace while $\hat\sigma_k\to\sigma_1$. The step breaks down only if $A^\top Ax_k=0$, i.e. $Ax_k=0$; all iterates after the first lie in $\mathrm{range}(A^\top)=\mathrm{null}(A)^\perp$, so this can only happen at $x_0$, which a random start avoids unless $A=0$. For the walkthrough matrix from $(1,0)$: $2.236,\ 2.765,\ 2.824,\ 2.8282\to2\sqrt2$. Dividing $W$ by such an estimate can leave $\|W/\hat\sigma\|_2\gt1$; guaranteed upper bounds are $\|A\|_F$ and $\sqrt{\|A\|_1\|A\|_\infty}$ ($\sqrt{12}\approx3.46$ here).
Polar factors and factor recovery. $A=(UV^\top)(V\Sigma V^\top)$ splits a square $A$ into an orthogonal factor and a PSD stretch; $UV^\top$ is the orthogonal matrix nearest to $A$ in Frobenius norm, the usual projection back onto orthogonal matrices after a gradient step. To write an invertible nonsymmetric $N$ as $VU^\top$, take $N=\tilde U\tilde\Sigma\tilde V^\top$ and $V=\tilde U\tilde\Sigma^{1/2}$, $U=\tilde V\tilde\Sigma^{1/2}$: both factors are invertible with condition number $\sqrt{\kappa(N)}$ (any $VT$, $UT^{-\top}$ also works; the SVD choice is balanced). Complex matrices have $A=U\Sigma V^*$ with unitary $U,V$, and $\sigma_{\max}(G(e^{j\omega}))$ is the gain of a transfer matrix at frequency $\omega$ (Primer D).
Practice: Singular values, least squares and power iteration
Work from Easy to Medium before trying Hard. Use the review link for a missing definition, then try again with the explanation closed.
Exercise A.5a — Easy: A negative eigenvalue still has positive stretch
For $A=\operatorname{diag}(2,-1)$, give one SVD $A=U\Sigma V^\top$, the singular values, spectral and Frobenius norms, and condition number. What happens to the unit circle?
Review: Singular values, least squares and power iteration
Show hint
Put the sign in an orthogonal factor. Singular values measure lengths and cannot be negative.
Show worked solution
Plan. Find the singular values from $A^\top A$, build $V$ and $U$ from them, read the norms off $\Sigma$, then map the unit circle.
Step 1 — Singular values. The singular values are the square roots of the eigenvalues of $A^\top A$:
Its eigenvalues are $4$ and $1$, so $\sigma_1=\sqrt4=2$ and $\sigma_2=\sqrt1=1$. Square roots are taken nonnegative by definition, so the sign of the eigenvalue $-1$ cannot appear here.
Step 2 — Build $V$ and $U$. The columns of $V$ are orthonormal eigenvectors of $A^\top A$: $v_1=e_1$, $v_2=e_2$, so $V=I$. The columns of $U$ are $u_i=Av_i/\sigma_i$:
so $U=\operatorname{diag}(1,-1)$ and $\Sigma=\operatorname{diag}(2,1)$. The sign has been moved into the orthogonal factor $U$.
Step 3 — Verify the factorisation. $U^\top U=\operatorname{diag}(1,1)=I$ and $V^\top V=I$, so both are orthogonal, and
Step 4 — Norms and condition number.
The Frobenius value agrees with the entrywise definition: $\sqrt{2^2+0^2+0^2+(-1)^2}=\sqrt5$.
Step 5 — Image of the unit circle. Write $x=(\cos t,\sin t)$. Then $y=Ax=(2\cos t,-\sin t)$, and
This is an ellipse with semi-axis $2$ along the horizontal axis and $1$ along the vertical axis, i.e. lengths $\sigma_1$ and $\sigma_2$. The minus sign only reverses the direction in which the ellipse is traced (a reflection), not its shape.
Check. $\|Ae_1\|_2=\|(2,0)\|_2=2=\|A\|_2$, so the largest stretch is attained, and $\|Ae_2\|_2=\|(0,-1)\|_2=1=\sigma_2$.
Interpretation. The eigenvalues $2,-1$ describe signed invariant directions; the singular values $2,1$ describe unsigned stretches. Norms and condition numbers are built from the latter.
Exercise A.5b — Medium: Solve an underdetermined system with minimum length
Let $A=\begin{bmatrix}1&2\end{bmatrix}$ and $b=5$. Compute $A^+$, find $x^\star=A^+b$, and prove it is the minimum Euclidean norm solution of $Ax=5$.
Review: Singular values, least squares and power iteration
Show hint
For a nonzero row, $A^+=A^\top/(AA^\top)$. All other solutions differ by a vector in the null space.
Show worked solution
Plan. Compute $A^+$ from the SVD of the single row, apply it to $b$, describe every solution as $x^\star$ plus a null-space vector, and compare lengths with Pythagoras.
Step 1 — SVD of the row. $AA^\top=1^2+2^2=5$, so $A$ has one singular value $\sigma=\sqrt5$, with $u=1$ and $v=A^\top/\sqrt5=(1,2)^\top/\sqrt5$. Indeed $\sigma uv^\top=\sqrt5\cdot(1,2)/\sqrt5=A$.
Step 2 — Pseudo-inverse. Inverting the nonzero singular value and swapping the factors gives
which is the formula $A^+=A^\top(AA^\top)^{-1}$ for a matrix with independent rows.
Step 3 — The candidate solution.
Step 4 — All solutions. The equation $x_1+2x_2=5$ has one equation and two unknowns. The null space is spanned by $n=(-2,1)$ since $An=-2+2=0$. Indeed the null space is exactly the multiples of $n$: $y_1+2y_2=0$ means $y_1=-2y_2$, so $y=y_2(-2,1)=y_2\,n$. If $Ax=5$, then $A(x-x^\star)=5-5=0$, so $x-x^\star$ lies in the null space and $x-x^\star=tn$ for some real $t$; conversely every such $x$ solves $Ax=5$:
Step 5 — Compare lengths. Expand the squared norm:
Here $(x^\star)^\top n=1(-2)+2(1)=0$, $\|x^\star\|^2=1+4=5$ and $\|n\|^2=4+1=5$, so
with equality only at $t=0$. Hence $x^\star=(1,2)$ is the unique minimum-norm solution, of length $\sqrt5$.
Check. Take $t=1$: $x=(-1,3)$ satisfies $-1+6=5$ and has $\|x\|^2=1+9=10=5+5\cdot1^2$.
Interpretation. $x^\star$ is a multiple of $A^\top$, so it lies in the row space, which is perpendicular to the null space. Any move along the null direction keeps the equation satisfied but adds length. The pseudo-inverse picks this solution by convention; the equation alone does not single it out.
Exercise A.5c — Hard: A power estimate cannot certify normalisation
Let $A=\operatorname{diag}(3,1)$ and $x_0=(1,1)/\sqrt2$. Compute $\hat\sigma_0=\|Ax_0\|_2$, one power iterate $x_1=A^\top Ax_0/\|A^\top Ax_0\|_2$, and $\hat\sigma_1$. If W is A divided by $\hat\sigma_0$, is $\|W\|_2\le1$? Give a simple guaranteed alternative.
Review: Singular values, least squares and power iteration
Show hint
The largest singular value is $3$. A power estimate evaluates one unit direction and therefore provides a lower bound.
Show worked solution
Plan. Evaluate the estimates, note why each is only a lower bound on $\sigma_{\max}=3$, show that dividing by a lower bound overshoots, and replace it by a guaranteed upper bound.
Step 1 — True value. $A^\top A=\operatorname{diag}(9,1)$, so $\sigma_{\max}=\sqrt9=3=\|A\|_2$.
Step 2 — Initial estimate. $\|x_0\|_2^2=\tfrac12+\tfrac12=1$, and
Because $\|A\|_2=\max_{\|x\|_2=1}\|Ax\|_2$ and $x_0$ is one particular unit vector, $\hat\sigma_0\le3$ automatically.
Step 3 — One power iteration.
Dividing, the factors $1/\sqrt2$ cancel: $x_1=(9,1)/\sqrt{82}$, a unit vector tilted towards $e_1$.
Step 4 — New estimate.
Closer to $3$, but $x_1$ is still a unit vector, so again $\hat\sigma_1\le3$; it is strictly below because $x_1$ is not parallel to $e_1$.
Step 5 — Test the proposed normalisation. $W=A/\hat\sigma_0=\operatorname{diag}(3/\sqrt5,\,1/\sqrt5)$ is diagonal, so its spectral norm is its largest absolute entry:
So no, $\|W\|_2\le1$ fails. In general $\|A/\hat\sigma\|_2=\sigma_{\max}/\hat\sigma\ge1$ whenever $\hat\sigma\le\sigma_{\max}$: dividing by a lower bound can only give a ratio of at least one.
Step 6 — A guaranteed alternative. Divide by an upper bound instead. The Frobenius norm is one: $\|A\|_2^2=\sigma_1^2\le\sigma_1^2+\sigma_2^2=\|A\|_F^2$. Here $\|A\|_F=\sqrt{9+1}=\sqrt{10}\approx3.1623$ and
In this small example the exact value $3$ is also known, and dividing by it gives norm exactly $1$.
Check. The ordering $\hat\sigma_0\lt\hat\sigma_1\lt\sigma_{\max}\lt\|A\|_F$ reads $2.236\lt2.984\lt3\lt3.162$.
Interpretation. A finite number of power iterations produces lower bounds that converge from below. A certificate such as $\|W\|_2\le1$ needs an upper bound; Frobenius (or the exact value) supplies one, at the price of some conservatism.
6. Block Matrices, Determinants, Trace & log det
6.1 Blocks, stacked vectors and sparsity
Partition into blocks of compatible sizes and multiply blocks like numbers, keeping their order: $\begin{bmatrix}A & B\\ C & D\end{bmatrix}\begin{bmatrix}x\\ u\end{bmatrix}=\begin{bmatrix}Ax+Bu\\ Cx+Du\end{bmatrix}$ (a state-space model in one matrix), and $\begin{bmatrix}x\\ y\end{bmatrix}^\top\begin{bmatrix}A & B\\ B^\top & C\end{bmatrix}\begin{bmatrix}x\\ y\end{bmatrix}=x^\top Ax+2x^\top By+y^\top Cy$. $\mathrm{blkdiag}(M_1,\dots,M_k)\succeq0$ iff every $M_i\succeq0$, which is how several LMIs become one. A selection matrix $E_i=[0\ \cdots\ I\ \cdots\ 0]$ extracts block $i$ of a stacked vector, $E_iz=z_i$, and $E_i^\top z_i$ zero-pads it back. Blocks are often named by the variables they couple ($P_{x,u}$: rows of $x$, columns of $u$); zero blocks are left blank.
Sparsity. If $L$ is block-bidiagonal (blocks only on the diagonal and first subdiagonal), $(LL^\top)_{ij}=\sum_kL_{ik}L_{jk}^\top$ vanishes unless $|i-j|\le1$: $LL^\top$ is block-tridiagonal. Conversely the block Cholesky factor of a PD block-tridiagonal matrix is block-bidiagonal (no fill-in), so layer-wise LMIs are cheap to factor. More generally, a symmetric sparsity pattern is a graph (edge $\{i,j\}$ if entry $ij$ may be nonzero); if it is chordal (every cycle of length $\ge4$ has a chord), a PSD matrix with that pattern is a sum of PSD matrices each supported on one clique (Vandenberghe & Andersen 2014, Thm. 9.2), so a large LMI splits into small ones. A tridiagonal pattern is a path; its cliques are consecutive pairs.
6.2 Block elimination and the Schur complement
Example (multiply out the factors to verify the theorem). For $M=\begin{bmatrix}2 & 1 & 0\\ 1 & 2 & 1\\ 0 & 1 & 2\end{bmatrix}$ with $A=2$: $S=\begin{bmatrix}2 & 1\\ 1 & 2\end{bmatrix}-\tfrac12\begin{bmatrix}1 & 0\\ 0 & 0\end{bmatrix}=\begin{bmatrix}1.5 & 1\\ 1 & 2\end{bmatrix}$, $\det S=2$, $\det M=2\cdot2=4$.
Proof. Complete the square: $x^\top Ax+2x^\top By+y^\top Cy=x^\top(A-BC^{-1}B^\top)x+(y+C^{-1}B^\top x)^\top C(y+C^{-1}B^\top x)$. The second term is $\ge0$ and vanishes at $y=-C^{-1}B^\top x$. $\square$ (A congruence with a block-triangular $T$.)
Why GP regression needs it. With features $\varphi(x_i)^\top$ as rows of $\Phi$, $\Phi\Phi^\top=K_t$ is the $t\times t$ kernel matrix while $\Phi^\top\Phi=\sum_i\varphi(x_i)\varphi(x_i)^\top$ lives in feature space (possibly $p=\infty$). Push-through moves between them, and Woodbury gives, with $k_t(x)=\Phi\varphi(x)$, $$\varphi(x)^\top(\lambda I+\Phi^\top\Phi)^{-1}\varphi(x)=\lambda^{-1}\big(k(x,x)-k_t(x)^\top(K_t+\lambda I)^{-1}k_t(x)\big)=\lambda^{-1}\sigma_t^2(x).$$ Gaussian conditioning uses the same Schur complement (Primer C).
6.3 Determinants and log det
Meaning. $\{x:x^\top P^{-1}x\le1\}$ has volume $\propto\det(P)^{1/2}$, so $\tfrac12\log\det P$ is a log-volume, as in the Gaussian entropy $\tfrac12\log\det(2\pi e\Sigma)$ (Primer C); products of factors become sums of logs. Pitfall: $\det(2I_3)=8$, so $\det\big(\lambda^{-1}(\lambda I_t+K_t)\big)=\lambda^{-t}\det(\lambda I_t+K_t)$.
Proof. Eliminate either corner of $\begin{bmatrix}I_m & -A\\ B & I_n\end{bmatrix}$: the Schur complement of $I_m$ gives $\det(I_n+BA)$, that of $I_n$ gives $\det(I_m+AB)$. Then $\det(V+uv^\top)=\det V\det(I+V^{-1}uv^\top)$. $\square$ Uses. (1) $\det(I_t+\lambda^{-1}K_t)=\det(I_p+\lambda^{-1}\Phi^\top\Phi)$; in infinite-dimensional feature space the right side is a Fredholm determinant, which for the rank-$\le t$ operator $\Phi^\top\Phi$ is just $\prod_i(1+\mu_i/\lambda)$ over its nonzero eigenvalues, those of $K_t$. (2) Adding a point, $V_t=V_{t-1}+\varphi_t\varphi_t^\top$, raises $\log\det$ by $\log(1+\|\varphi_t\|_{V_{t-1}^{-1}}^2)$; the sum over $t$ is the "elliptical potential" (Exercise A.6).
6.4 Trace
Lifting. $y^\top My=\langle M,yy^\top\rangle$, and $Y=yy^\top$ is PSD, rank one, $\mathrm{diag}(Y)=(y_i^2)$: a nonconvex quadratic problem in $y$ becomes linear in $Y$, and dropping "rank one" but keeping $Y\succeq0$ gives an SDP whose value upper-bounds the original maximum (the Goemans–Williamson idea).
Total variance: $\mathrm{tr}\,\Sigma=\sum_i\mathrm{Var}(X_i)=\mathbb E\|X-\mathbb EX\|^2$, while $\mathrm{tr}(\Sigma^{1/2})=\sum_i\sqrt{\lambda_i}$ is the sum of marginal standard deviations only for diagonal $\Sigma$; for $\begin{bmatrix}1 & 0.8\\ 0.8 & 1\end{bmatrix}$ it is $\sqrt{1.8}+\sqrt{0.2}\approx1.79$, not $2$.
Tight frames: unit $x_1,\dots,x_T\in\mathbb R^d$ with $\sum_tx_tx_t^\top=cI$ force $c=T/d$ (take traces: $T=cd$); three unit vectors at $120^\circ$ give $\tfrac32I$.
Let $\bar\Sigma\succ0$ (aleatoric), $\hat\Sigma\succeq0$ (epistemic) be $n\times n$ ($n=n_S$, the state dimension), $S=\bar\Sigma+\hat\Sigma$. $G=\bar\Sigma S^{-1}$ is generally not symmetric, so its diagonal entries are no "variance ratios". But $S^{-1/2}GS^{1/2}=S^{-1/2}\bar\Sigma S^{-1/2}$, and $0\prec\bar\Sigma\preceq S$ gives by congruence $0\prec S^{-1/2}\bar\Sigma S^{-1/2}\preceq I$. Similar matrices share eigenvalues, so those of $G$ lie in $(0,1]$ and $\mathrm{tr}\,G\in(0,n]$.
Numbers: $\bar\Sigma=\mathrm{diag}(2,1)$, $\hat\Sigma=\begin{bmatrix}1 & 1\\ 1 & 1\end{bmatrix}$ give $G=\tfrac15\begin{bmatrix}4 & -2\\ -1 & 3\end{bmatrix}$, eigenvalues $1$ and $0.4$, $\tfrac12\mathrm{tr}\,G=0.7$. The eigenvalue $1$ comes from the null direction $(1,-1)$ of $\hat\Sigma$, where the epistemic part adds nothing.
Practice: Block algebra, Schur complements and updates
Work from Easy to Medium before trying Hard. Use the review link for a missing definition, then try again with the explanation closed.
Exercise A.6a — Easy: Read a block matrix as ordinary equations
For $M=\begin{bmatrix}2&1&0\\1&3&0\\0&0&4\end{bmatrix}$ and $z=(1,2,3)$, compute $Mz$, $\operatorname{tr}M$ and $\det M$. Explain the determinant using its block structure.
Review: Block algebra, Schur complements and updates
Show hint
The top-left $2\times2$ block and the scalar $4$ act independently.
Show worked solution
Plan. Partition $M$ as $\begin{bmatrix}B&0\\0&4\end{bmatrix}$ with $B=\begin{bmatrix}2&1\\1&3\end{bmatrix}$, compute $Mz$ row by row and blockwise, then get the trace and the determinant from the blocks.
Step 1 — Product, row by row.
Step 2 — The same product, blockwise. Split $z=(z_a,z_3)$ with $z_a=(1,2)$. Block multiplication follows the same row-times-column rule, and the zero blocks kill the cross terms:
Coordinate 3 does not influence coordinates 1–2 and vice versa.
Step 3 — Trace. Add the diagonal entries: $\operatorname{tr}M=2+3+4=9$, which is $\operatorname{tr}B+4=5+4$.
Step 4 — Determinant. Expand along the third row. It has a single nonzero entry, $4$ at position $(3,3)$, whose cofactor sign is $(-1)^{3+3}=+1$ and whose minor is $\det B$:
This is the block-diagonal rule $\det\begin{bmatrix}B&0\\0&C\end{bmatrix}=\det B\det C$ in its simplest case.
Check. The eigenvalues of $M$ are those of $B$, namely $(5\pm\sqrt5)/2$, together with $4$. Their sum is $5+4=9=\operatorname{tr}M$ and their product is $\tfrac{25-5}{4}\cdot4=5\cdot4=20=\det M$.
Interpretation. A block-diagonal matrix is two independent systems side by side: trace adds across blocks, determinant multiplies across blocks.
Exercise A.6b — Medium: Find the parameter range of a Schur complement
For which real a is $M(a)=\begin{bmatrix}a&2\\2&3\end{bmatrix}$ PSD? For which is it PD? Show a null vector at the boundary using a completed square.
Review: Block algebra, Schur complements and updates
Show hint
Use the strictly positive lower-right corner $3$ as the pivot.
Show worked solution
1. Complete the square. For $z=(x,y)$ the quadratic form is $ax^2+4xy+3y^2$. Since $3(y+2x/3)^2=3y^2+4xy+(4/3)x^2$, subtraction gives
2. Classify PSD. If $a\ge4/3$, both terms are nonnegative for every $z$, proving PSD. Conversely, choose $y=-2x/3$ so the second square vanishes. For $x\ne0$ the remaining value is negative when $a\lt4/3$. Thus PSD holds exactly for $a\ge4/3$.
3. Classify PD and the boundary. If $a\gt4/3$ and $x\ne0$, the first term is positive. If $x=0$ but $z\ne0$, then $y\ne0$ and the second term is positive. This proves PD. At $a=4/3$, the nonzero vector $z=(3,-2)$ makes both terms zero, and direct multiplication gives $M(4/3)z=(4-4,6-6)=(0,0)$. The boundary is singular PSD, not PD. For $a\lt4/3$ this same vector gives the negative value $9(a-4/3)$.
Exercise A.6c — Hard: Update an inverse and a log determinant
Let $V=\operatorname{diag}(2,1)$ and $u=(1,2)$. Compute $\det(V+uu^\top)$ and the increase in $\log\det V$ using the determinant lemma. Compute $(V+uu^\top)^{-1}$ using the rank-one inverse formula, then verify by multiplication.
Review: Block algebra, Schur complements and updates
Show hint
First compute $V^{-1}u$ and the scalar $u^\top V^{-1}u$; both identities reuse them.
Show worked solution
1. Compute the quantities used by both update formulas. For $V=\operatorname{diag}(2,1)$, $V^{-1}=\operatorname{diag}(1/2,1)$. Thus $v=V^{-1}u=(1/2,2)$ and $u^\top v=1/2+4=9/2$. The denominator $1+u^\top v=11/2$ is positive, so the rank-one inverse formula applies.
2. Update the determinant. The determinant lemma gives $\det(V+uu^\top)=\det V(1+u^\top V^{-1}u)=2(11/2)=11$. The increase in log determinant is $\log11-\log2=\log(11/2)\approx1.70475$, using natural logarithms.
3. Update the inverse entry by entry. Sherman–Morrison gives $V^{-1}-vv^\top/(11/2)$. Here $vv^\top=\begin{bmatrix}1/4&1\\1&4\end{bmatrix}$. Its entries are $1/2-(2/11)(1/4)=5/11$, $0-(2/11)(1)=-2/11$, and $1-(2/11)(4)=3/11$. Therefore
4. Verify independently. Adding $uu^\top$ gives $V+uu^\top=\begin{bmatrix}3&2\\2&5\end{bmatrix}$, whose direct determinant is $15-4=11$. Multiplication by the proposed inverse gives $\frac1{11}\begin{bmatrix}15-4&-6+6\\10-10&-4+15\end{bmatrix}=I$. Both update results pass direct checks.
7. Orthogonal, Skew-Symmetric & Structured Matrices
7.1 Orthogonal matrices, reflections and projections
Householder reflections. For a unit vector $v$, $H=I-2vv^\top$ reflects across $v^\perp$ ($Hv=-v$, $Hw=w$ for $w\perp v$); it is symmetric, orthogonal and its own inverse, while $I-vv^\top$ is the (singular) orthogonal projector onto $v^\perp$. For $v=(1,1)/\sqrt2$, $H=\begin{bmatrix}0 & -1\\ -1 & 0\end{bmatrix}$ maps $(1,0)$ to $(0,-1)$. Since $\det$ is continuous with values $\pm1$ on orthogonal matrices, no continuous path joins a reflection to a rotation: orthogonal matrices form two separate pieces, and a continuous parameterisation from $\mathbb R^p$ reaches only one (Primer 0).
7.2 Skew-symmetric matrices and the Cayley transform
Proof of orthogonality. $I\pm A$ are polynomials in $A$, so they commute; and $XY=YX$ with $Y$ invertible gives $Y^{-1}X=XY^{-1}$ (multiply by $Y^{-1}$ on both sides), so $I-A$ also commutes with $(I+A)^{-1}$. With $(I+A)^\top=I-A$: $Q^\top Q=(I-A)^{-1}(I+A)(I-A)(I+A)^{-1}=(I-A)^{-1}(I-A)(I+A)(I+A)^{-1}=I$. $\square$ Example: $A=\begin{bmatrix}0 & -\tfrac12\\ \tfrac12 & 0\end{bmatrix}$ gives $Q=\begin{bmatrix}0.6 & 0.8\\ -0.8 & 0.6\end{bmatrix}$, a rotation by $-53.1^\circ$. Optimising over orthogonal matrices: differentiating $Q(t)^\top Q(t)=I$ gives $\dot Q^\top Q+Q^\top\dot Q=0$, so the tangent directions at $Q$ are $QA$ with $A$ skew; methods move along them ($Q\,\mathrm{Cayley}(tA)$, $Qe^{tA}$) or take a plain step and project back with the polar factor $UV^\top$ (Section 5).
7.3 Diagonal, permutation, Toeplitz and circulant matrices
$D=\mathrm{diag}(d)$ scales coordinates, $\|D\|_p=\max_i|d_i|$, and $D\succeq0$ iff $d\ge0$. A permutation matrix $\Pi$ is orthogonal, and $\Pi^\top M\Pi$ keeps eigenvalues and definiteness. $\ell_p$ norms are permutation invariant; GroupSort and MaxMin permute entries within groups, so where differentiable their Jacobian is a permutation matrix: orthogonal, norm-preserving.
Example. $h=(1,2)$: $T_4=\begin{bmatrix}1 & 0 & 0 & 0\\ 2 & 1 & 0 & 0\\ 0 & 2 & 1 & 0\\ 0 & 0 & 2 & 1\end{bmatrix}$. The matrix grows with the signal, the filter does not: $\|T_N\|_2=2.41,\,2.83,\,2.95,\,3.00$ for $N=2,4,8,32$, approaching the frequency-response gain $\max_\omega|1+2e^{-i\omega}|=3$. The $4\times4$ circulant has eigenvalues $3,\,1-2i,\,-1,\,1+2i$ and norm $3$; for real $h$, $\hat h_{N-k}=\overline{\hat h_k}$ (conjugate symmetry), so per-frequency operations can return real outputs. Vector-valued signals give block-Toeplitz matrices; finite memory makes them banded. Time invariance is the Toeplitz structure, finite memory the band.
7.4 Kronecker products and flattening
Examples. $I_2\otimes\begin{bmatrix}1 & 2\\ 3 & 4\end{bmatrix}=\begin{bmatrix}1 & 2 & 0 & 0\\ 3 & 4 & 0 & 0\\ 0 & 0 & 1 & 2\\ 0 & 0 & 3 & 4\end{bmatrix}$ is block diagonal; $\begin{bmatrix}1 & 2\\ 3 & 4\end{bmatrix}\otimes I_2=\begin{bmatrix}1 & 0 & 2 & 0\\ 0 & 1 & 0 & 2\\ 3 & 0 & 4 & 0\\ 0 & 3 & 0 & 4\end{bmatrix}$ interleaves. So $I_N\otimes Q$ applies $Q$ to each of $N$ pixels, $\mathrm{diag}(\lambda)\otimes I_g$ gives each group of $g$ neurons one multiplier, and $z^\top(\mathrm{diag}(\gamma)\otimes\mathbf 1\mathbf 1^\top)z=\sum_i\gamma_i(\mathbf 1^\top z_i)^2$ collects group sums. Flattening order matters: $c$ channels at $N$ pixels flattened pixel by pixel turn $\sum_px_p^\top Qx_p$ into $\mathrm{vec}^\top(I_N\otimes Q)\mathrm{vec}$; channel by channel it is $Q\otimes I_N$. Complex counterparts: unitary ($U^*U=I$) and skew-Hermitian ($A^*=-A$) matrices; the Cayley transform of the latter is unitary.
Practice: Orthogonal maps, projections and Cayley transforms
Work from Easy to Medium before trying Hard. Use the review link for a missing definition, then try again with the explanation closed.
Exercise A.7a — Easy: A reflection preserves length
Let $Q=\operatorname{diag}(1,-1)$. Compute $Q^\top Q$, $Q(3,4)^\top$ and its length. Is Q a rotation or a reflection?
Review: Orthogonal maps, projections and Cayley transforms
Show hint
An orthogonal matrix satisfies $Q^\top Q=I$. The determinant distinguishes a plane rotation from a reflection.
Show worked solution
Plan. Check $Q^\top Q=I$, deduce length preservation, test on $(3,4)$, then use the determinant to decide between rotation and reflection.
Step 1 — Orthogonality. $Q$ is diagonal, so $Q^\top=Q$, and
Step 2 — Length preservation for every $x$. Write the squared length as a product and insert Step 1:
Step 3 — The example.
equal to $\|(3,4)\|_2=\sqrt{9+16}=5$, as Step 2 guarantees.
Step 4 — Rotation or reflection? Taking determinants in $Q^\top Q=I$ gives $(\det Q)^2=1$, so an orthogonal matrix has $\det Q=\pm1$. Every plane rotation $\begin{bmatrix}c&-s\\s&c\end{bmatrix}$ with $c^2+s^2=1$ has determinant $c^2+s^2=+1$. Here $\det Q=1\cdot(-1)-0\cdot0=-1$, so $Q$ is not a rotation. It fixes $e_1$ ($Qe_1=e_1$) and flips $e_2$ ($Qe_2=-e_2$): a reflection across the horizontal axis.
Check. Reflecting twice must return every vector: $Q^2=\operatorname{diag}(1,1)=I$.
Interpretation. Orthogonal matrices preserve lengths and angles, but they include reflections ($\det=-1$) as well as rotations ($\det=+1$).
Exercise A.7b — Medium: Projection is different from an orthogonal matrix
Let $P=\operatorname{diag}(1,0)$. Show that it is an orthogonal projection onto the horizontal axis. Is P itself an orthogonal matrix? Find the projection error of $x=(3,4)$.
Review: Orthogonal maps, projections and Cayley transforms
Show hint
A projection matrix satisfies $P^2=P$; an orthogonal projection is also symmetric. An orthogonal matrix must satisfy $P^\top P=I$.
Show worked solution
Plan. Verify the two defining properties of an orthogonal projection ($P^2=P$ and $P^\top=P$), compute the error for $(3,4)$, then test the different condition $P^\top P=I$.
Step 1 — What $P$ does. $Px=\operatorname{diag}(1,0)(x_1,x_2)^\top=(x_1,0)^\top$: it keeps the horizontal component and deletes the vertical one. Its range is the horizontal axis, and it fixes that axis: $P(a,0)^\top=(a,0)^\top$.
Step 2 — Projection and orthogonality properties.
$P^2=P$ says projecting twice changes nothing. Symmetry makes the residual perpendicular to the projection for every $x$:
Hence $P$ is the orthogonal projection onto the horizontal axis.
Step 3 — Error for $x=(3,4)$. $Px=(3,0)$ and the error is $e=x-Px=(0,4)$, with length $4$. Check perpendicularity and Pythagoras:
Step 4 — Is $P$ an orthogonal matrix? That would require $P^\top P=I$. But $P^\top P=P^2=P=\operatorname{diag}(1,0)\ne I$. Concretely $P(0,1)^\top=(0,0)^\top$ turns a unit vector into a zero vector, so lengths are not preserved, and $\det P=0$ makes $P$ singular. So no.
Step 5 — Its operator norm. $\|Px\|_2^2=x_1^2\le x_1^2+x_2^2=\|x\|_2^2$, with equality at $(1,0)$. Hence $\|P\|_2=1$, even though $P$ is not orthogonal.
Check. The error length $4$ is the distance from $(3,4)$ to the horizontal axis, which is the vertical coordinate, as expected.
Interpretation. "Orthogonal projection" means the residual is orthogonal to the range; "orthogonal matrix" means all lengths are preserved. The two share a word, not a property: an orthogonal projection other than $I$ is never an orthogonal matrix.
Exercise A.7c — Hard: Derive a Cayley rotation and its missing case
For $A=\begin{bmatrix}0&-1\\1&0\end{bmatrix}$ compute $Q=(I-A)(I+A)^{-1}$ and verify orthogonality. Prove that the Cayley transform of any real skew-symmetric A cannot have a nonzero vector v with $Qv=-v$.
Review: Orthogonal maps, projections and Cayley transforms
Show hint
For the proof set $w=(I+A)^{-1}v$, so that the eigenvector equation becomes $(I-A)w=-(I+A)w$.
Show worked solution
1. Calculate this Cayley transform. For $A=\begin{bmatrix}0&-1\\1&0\end{bmatrix}$, the determinant of $I+A=\begin{bmatrix}1&-1\\1&1\end{bmatrix}$ is $2$, so $(I+A)^{-1}=\frac12\begin{bmatrix}1&1\\-1&1\end{bmatrix}$. Multiplying gives
Its columns are perpendicular unit vectors, hence $Q^\top Q=I$. Also $\det Q=1$ and $Q(1,0)^\top=(0,-1)^\top$, so it is a clockwise $90$ degree rotation.
2. Explain why $I+A$ is invertible for any real skew-symmetric $A$. Transposing the real scalar $w^\top Aw$ gives $w^\top A^\top w=-w^\top Aw$, so $w^\top Aw=0$. If $(I+A)w=0$, multiplying on the left by $w^\top$ gives $\|w\|_2^2+w^\top Aw=0$, and therefore $w=0$. A finite square matrix with trivial nullspace is invertible.
3. Explain the missing rotation. Suppose $Qv=-v$ and put $w=(I+A)^{-1}v$, so $v=(I+A)w$. Substitution gives $(I-A)w=-(I+A)w$, or $w-Aw=-w-Aw$. Cancelling the $Aw$ terms leaves $2w=0$, hence $v=0$. Thus no nonzero vector can have eigenvalue $-1$ for a Cayley transform with a finite real skew parameter. In particular $-I$ cannot be represented this way. In the two-dimensional example, $-I_2$ can arise as a limit by taking $A_t=tA$ and letting $t$ tend to infinity; no finite parameter attains it.
8. Functions as Vectors: Inner Product & Hilbert Spaces
Functions $f:D\to\mathbb R$ add and scale pointwise, so they are vectors. On a finite $D=\{x_1,\dots,x_n\}$, $f$ is the vector $(f(x_1),\dots,f(x_n))$; on an interval there are infinitely many independent functions ($1,x,x^2,\dots$). Kernel methods (Modules 3–6) do linear algebra in such infinite-dimensional spaces.
Examples. On $[0,1]$: $\langle1,x\rangle=\tfrac12$, $\|x\|=1/\sqrt3$, angle $30^\circ$. In the Fourier basis $1,\sqrt2\cos2\pi kx,\sqrt2\sin2\pi kx$, $3+4\sqrt2\cos2\pi x$ has coefficients $(3,4,0,\dots)$ and norm $5$: Pythagoras for functions.
What infinite dimensions add. (1) A Hilbert space is an inner-product space that is complete: every Cauchy sequence converges inside it. Polynomials are not complete in $L^2$ on $[0,1]$ (the Taylor polynomials of $e^x$ converge to $e^x$, which is no polynomial); the completion adds such limits, as the reals complete the rationals. (2) Norms are no longer equivalent: $x^n$ on $[0,1]$ has sup norm $1$ but $L^2$ norm $1/\sqrt{2n+1}\to0$. (3) Projection still works: the best approximation of $f$ in $\mathrm{span}(g_1,\dots,g_t)$ solves $G\alpha=b$, $G_{ij}=\langle g_i,g_j\rangle$, $b_i=\langle g_i,f\rangle$, and $\|f\|^2=\|f_\parallel\|^2+\|f_\perp\|^2$.
Functionals and adjoints. On $\mathbb R^n$ every linear functional is $x\mapsto a^\top x$; on a Hilbert space every bounded one ($|L(f)|\le C\|f\|$) is $\langle g_L,f\rangle$ for a unique $g_L$ (Riesz). Point evaluation $f\mapsto f(x)$ is not even defined on $L^2(dx)$ (changing $f$ at one point changes nothing), and on continuous functions with the $L^2$ norm it is unbounded: the spikes $f_n(y)=\max\{1-n|y-x|,0\}$ have $f_n(x)=1$ but $\|f_n\|_{L^2}^2\le\tfrac2{3n}\to0$. (For a discrete $\mu$ with a point mass $p\gt0$ at $x$ it is bounded, $|f(x)|\le\|f\|_{L^2}/\sqrt p$.) The spaces where it is bounded are the RKHSs below. The adjoint is defined by $\langle Tv,w\rangle=\langle v,T^*w\rangle$ ($T^*=T^\top$ on $\mathbb R^n$). For the design operator $\Phi g=(\langle\varphi(x_i),g\rangle)_{i\le t}$, $v^\top\Phi g=\langle\sum_iv_i\varphi(x_i),g\rangle$ gives $\Phi^*v=\sum_iv_i\varphi(x_i)$; $\Phi\Phi^*$ is the $t\times t$ matrix $[\langle\varphi(x_i),\varphi(x_j)\rangle]$, and $\Phi^*\Phi=\sum_i\varphi(x_i)\langle\varphi(x_i),\cdot\,\rangle$ is a positive operator of rank $\le t$, the operator version of $\sum_i\varphi_i\varphi_i^\top$.
8.1 Feature maps and kernels
Examples. $\varphi(x)=(1,\sqrt2x,x^2)$ gives $k(x,x')=(1+xx')^2$ (at $x=1$, $x'=2$ both sides are $9$): a kernel computes feature inner products without forming features. The squared-exponential kernel $\sigma_f^2\exp(-\|x-x'\|^2/(2\ell^2))$ has infinitely many features; $\sigma_f^2=k(x,x)$ is the prior variance and $\ell$ the length scale: $k/\sigma_f^2=0.61,\,0.14,\,0.011$ at distances $\ell,2\ell,3\ell$. Building kernels: sums, positive multiples and products of kernels are kernels. A product kernel on pairs, $k_1(\theta,\theta')k_2(t,t')$, has features $\varphi_1(\theta)\otimes\varphi_2(t)$, and its Gram matrix $K_1\circ K_2$ (entrywise product) is a principal submatrix of the PSD $K_1\otimes K_2$. The Wiener kernel $\min(t,t')=\int_0^\infty\mathbf 1[s\le t]\,\mathbf 1[s\le t']\,ds$ ($t,t'\ge0$) has the feature functions $\mathbf 1_{[0,t]}$.
8.2 The reproducing kernel Hilbert space (the bridge to Module 3)
The RKHS norm measures wiggliness. If $K\succ0$ (e.g. the SE kernel at distinct inputs), the smallest-norm $f$ with $f(x_i)=y_i$ has $\|f\|_k^2=y^\top K^{-1}y$. (For singular $K$ an interpolant exists iff $y\in\mathrm{range}(K)$, and the smallest squared norm is then $y^\top K^+y$: for the constant kernel $k\equiv1$ at two inputs, $K=\mathbf 1\mathbf 1^\top$, the data $(1,1)$ cost $1$ and $(1,-1)$ cannot be interpolated.) SE kernel, $\ell=1$, two points $0.1$ apart ($k=0.995$): $y=(1,1)$ needs $\|f\|_k\approx1.00$, $y=(1,-1)$ needs $\|f\|_k\approx20.0$. For a smooth kernel such as this one, a bound $\|f\|_k\le B$ rules out fast oscillation (the assumption behind GP confidence bounds); the alternating data sit on the small-eigenvalue direction of $K$ (Section 5).
Intuition. On a finite $D$ with $K=Q\Lambda Q^\top\succ0$, $\|f\|_k^2=f^\top K^{-1}f=\sum_j(q_j^\top f)^2/\lambda_j$, so small-eigenvalue components are expensive: the RKHS unit ball is an ellipsoid with semi-axes $\sqrt{\lambda_j}$ along the eigenvectors, and fast eigenvalue decay makes it thin in all but a few directions. For a smooth kernel such as the SE kernel the expensive components are the rough, oscillating ones; in general smoothness depends on the eigenfunctions as well as the eigenvalues. Stationary kernels are a separate whole-space case: if $k(x,x')=\kappa(x-x')$ on $\mathbb R^d$ with $\kappa$ continuous and integrable, and $\hat g(\omega)=\int g(x)e^{-i\omega^\top x}dx$, Fourier modes replace eigenfunctions: if $\hat\kappa\gt0$, $\mathcal H_k$ consists of the continuous $f\in L^2$ with $\|f\|_k^2=(2\pi)^{-d}\int|\hat f(\omega)|^2/\hat\kappa(\omega)\,d\omega\lt\infty$ (Kanagawa et al., arXiv 2018, Thm. 2.4; smooth kernels have $\hat\kappa$ tiny at high frequencies, which makes rough $f$ expensive). On a compact $D$ this does not apply directly: the RKHS norm of $f$ is the smallest whole-space norm among its extensions to $\mathbb R^d$. Operator eigenvalues are not those of a sampled $K_t$, though $\lambda_j(K_t)/t\approx\lambda_j$ for large $t$ if $\mu$ is a probability measure and the inputs are i.i.d. from $\mu$ (for a general finite $\mu$, sampling from $\mu/\mu(D)$ gives the limit $\lambda_j/\mu(D)$).
Distances between distributions: the mean embedding $m_P=\mathbb E_{X\sim P}\varphi(X)$ gives the maximum mean discrepancy $\mathrm{MMD}(P,Q)=\|m_P-m_Q\|_k$, with $\mathrm{MMD}^2=\mathbb Ek(X,X')-2\mathbb Ek(X,Y)+\mathbb Ek(Y,Y')$ ($X,X'\sim P$, $Y,Y'\sim Q$ independent); for the SE kernel it vanishes only if $P=Q$, the basis of kernel two-sample tests.
Practice: Functions as vectors, kernels and RKHS norms
Work from Easy to Medium before trying Hard. Use the review link for a missing definition, then try again with the explanation closed.
Exercise A.8a — Easy: Replace a sum by an integral
In $L^2([0,1])$, take $f(x)=1$ and $g(x)=x$. Compute $\langle f,g\rangle$, both norms, and the constant c such that $g-cf$ is perpendicular to f.
Review: Functions as vectors, kernels and RKHS norms
Show hint
Use $\int_0^1x\,dx=1/2$ and $\int_0^1x^2\,dx=1/3$. Perpendicular means inner product zero.
Show worked solution
Plan. In $L^2([0,1])$ the inner product is $\langle f,g\rangle=\int_0^1f(x)g(x)\,dx$ and $\|f\|=\sqrt{\langle f,f\rangle}$; evaluate the integrals, then use linearity to choose $c$.
Step 1 — Inner product.
Step 2 — Norms.
Step 3 — Choose $c$. The integral is linear, so the inner product is linear in its second argument:
Perpendicular means this is zero, so $c=1/2$, and $g-cf$ is the function $x-\tfrac12$. This is the vector projection formula $c=\langle f,g\rangle/\langle f,f\rangle$.
Step 4 — Verify and apply Pythagoras. Directly, $\int_0^1(x-\tfrac12)\,dx=\tfrac12-\tfrac12=0$. The squared length of the remainder is
and the two perpendicular pieces of $g=cf+(g-cf)$ recombine as
Check. Cauchy–Schwarz requires $|\langle f,g\rangle|\le\|f\|\|g\|$: indeed $0.5\le1\cdot0.577$.
Interpretation. $c=1/2$ is the mean of $g$ on $[0,1]$; subtracting it leaves the zero-mean part $x-\tfrac12$. The projection algebra for vectors carries over unchanged once sums are replaced by integrals.
Exercise A.8b — Medium: Build a kernel matrix from explicit features
Let $\varphi(x)=(1,x)$ and $k(x,x^\prime)=\varphi(x)^\top\varphi(x^\prime)$. Compute k and its Gram matrix at inputs $0,1$. Verify PSD by writing $\alpha^\top K\alpha$ as a sum of squares. Is K PD?
Review: Functions as vectors, kernels and RKHS norms
Show hint
Write $\alpha_1\varphi(0)+\alpha_2\varphi(1)$ and square its length.
Show worked solution
Plan. Compute the kernel from the features, fill the Gram matrix, and rewrite $\alpha^\top K\alpha$ as the squared length of one feature vector.
Step 1 — The kernel. $k(x,x^\prime)=\varphi(x)^\top\varphi(x^\prime)=1\cdot1+x\cdot x^\prime=1+xx^\prime$.
Step 2 — Gram matrix at $x_1=0$, $x_2=1$. Entry $(i,j)$ is $k(x_i,x_j)$:
Step 3 — Sum of squares. Because each entry is an inner product, the double sum collapses into one squared length:
With $\varphi(0)=(1,0)$ and $\varphi(1)=(1,1)$ the weighted sum is $\alpha_1(1,0)+\alpha_2(1,1)=(\alpha_1+\alpha_2,\alpha_2)$, so
Cross-check by expanding both sides: $\alpha^\top K\alpha=\alpha_1^2+2\alpha_1\alpha_2+2\alpha_2^2$ and $(\alpha_1+\alpha_2)^2+\alpha_2^2=\alpha_1^2+2\alpha_1\alpha_2+\alpha_2^2+\alpha_2^2$, the same polynomial. So $K$ is PSD.
Step 4 — Is it PD? A sum of two squares is zero only if both are zero: $\alpha_2=0$, and then $\alpha_1+\alpha_2=0$ forces $\alpha_1=0$. So $\alpha^\top K\alpha\gt0$ for every $\alpha\ne0$, and $K$ is PD. The reason is that $\varphi(0)$ and $\varphi(1)$ are linearly independent.
Check. Sylvester's criterion from Section 4 (all leading principal minors positive): $K_{11}=1\gt0$ and $\det K=1\cdot2-1\cdot1=1\gt0$. The eigenvalues are $(3\pm\sqrt5)/2\approx2.618,\ 0.382$, both positive.
Interpretation. Kernel matrices are PSD because they are Gram matrices of feature vectors, not because their entries look positive. They are PD exactly when the features at the chosen inputs are independent.
Exercise A.8c — Hard: Interpolate and interpret an RKHS norm
For $k(x,x^\prime)=1+xx^\prime$ on $\mathbb R$, fit $f(0)=1$ and $f(1)=3$ with a function in its RKHS. Compute its squared RKHS norm using both the feature coefficients and $y^\top K^{-1}y$. Why does this finite norm not give a finite uniform bound on all real x?
Review: Functions as vectors, kernels and RKHS norms
Show hint
The feature map is $(1,x)$, so functions are $f(x)=w_1+w_2x$ with squared norm $w_1^2+w_2^2$. Also $k(x,x)=1+x^2$.
Show worked solution
Plan. Use the explicit feature description of the RKHS to fit the data, recompute the norm with $y^\top K^{-1}y$, reconcile the two via the representer form, and finally bound $|f(x)|$ with the reproducing property.
Step 1 — Fit in feature coordinates. Since $\varphi(x)=(1,x)$ has independent components, functions in the RKHS are $f(x)=w^\top\varphi(x)=w_1+w_2x$ with $\|f\|_k^2=w_1^2+w_2^2$. The data give
So $f(x)=1+2x$ and $\|f\|_k^2=1^2+2^2=5$.
Step 2 — Invert the Gram matrix. From Exercise A.8b, $K=\begin{bmatrix}1&1\\1&2\end{bmatrix}$ with $\det K=1$. The $2\times2$ inverse formula (swap the diagonal, negate the off-diagonal, divide by the determinant) gives
Step 3 — Norm from the data. With $y=(1,3)$,
Step 4 — Why both routes agree. The representer form is $f=\sum_i\alpha_ik(x_i,\cdot)$:
the same function. Its weight vector is $w=-\varphi(0)+2\varphi(1)=-(1,0)+2(1,1)=(1,2)$, and $\|w\|^2=\alpha^\top K\alpha=\alpha^\top y=y^\top K^{-1}y$ because $K\alpha=y$. These are one norm calculation in two coordinate systems.
Step 5 — Pointwise bound. The reproducing property $f(x)=\langle f,k(x,\cdot)\rangle_k$ and Cauchy–Schwarz give
The right side grows like $\sqrt5\,|x|$, because the kernel diagonal $k(x,x)=1+x^2$ is unbounded on $\mathbb R$. The function itself is unbounded too: $f(x)=1+2x\to\infty$. So no finite constant bounds $|f|$ on all of $\mathbb R$, even though $\|f\|_k=\sqrt5$ is finite.
Step 6 — Restrict the domain. On $[-1,1]$, $k(x,x)\le1+1=2$, so $|f(x)|\le\sqrt5\sqrt2=\sqrt{10}\approx3.162$ uniformly.
Check. On $[-1,1]$ the actual maximum is $|f(1)|=3\le3.162$. The bound is tight where $\varphi(x)$ is parallel to $w=(1,2)$, i.e. at $x=2$: $f(2)=5$ and $\sqrt5\sqrt{1+4}=5$. At $x=10$: $f(10)=21\le\sqrt5\sqrt{101}\approx22.47$.
Interpretation. An RKHS norm bound turns into a uniform bound only when $\sup_xk(x,x)$ is finite on the domain of interest. With an unbounded kernel diagonal, the domain must be restricted first.
Interactive: Quadratic Forms, Eigenvectors & the SVD
Set the entries of $A=\begin{bmatrix}a_{11} & a_{12}\\ a_{21} & a_{22}\end{bmatrix}$. Left: $A$ maps the unit circle (grey) to an ellipse (blue); dashed teal: right singular vectors $v_1,v_2$; blue: their images $\sigma_iu_i$; purple: real eigen-directions; orange: the power iterate $x_k$ and $Ax_k$. Right: level sets $x^\top Sx=c$, $S=\tfrac12(A+A^\top)$, for $c=\pm\tfrac12,\pm1,\pm2$ (blue positive, orange negative, $c=1$ thick). The readouts use closed-form formulas evaluated in floating-point arithmetic (the determinant and eigenvalue discriminant come from the integer slider ticks, so singular matrices are recognised exactly); the level-set curves are approximated numerically on a grid.
What to look for. Walkthrough: no real eigenvectors ($\rho=2$), yet two singular directions with $\sigma_1=2\sqrt2$; the power estimate climbs to $2.83$ from below. Symmetric PD: eigen- and singular vectors coincide, the level sets are ellipses with semi-axes $1/\sqrt{\lambda_i}$, Cholesky succeeds. Indefinite: hyperbolas; Cholesky fails at pivot 2 although all entries are positive. Singular PSD: the ellipse collapses to a segment (rank 1), level sets become lines. Nilpotent: $\rho(A)=0$ but $\|A\|_2=2$, and power iteration from $(1,0)\perp v_1$ breaks down at once: $(1,0)\in\mathrm{null}(A)$, so $A^\top A(1,0)=0$ and there is no next iterate (the readout says so). Rotation: $\sigma_1=\sigma_2=1$ (every direction is a dominant one, so $v_1$ is not unique), and $S=0.6I$ is PD although $A$ is not symmetric.
From the mathematics to a real decision
Two sensor channels do not automatically give two independent pieces of information. If both channels measure almost the same combination of unknown quantities, a small reading error can become a large reconstruction error. This chapter uses a constructed displacement fixture to connect linear systems, singular values, least squares and uncertainty geometry. Every displacement and sensor error below is hypothetical; the example is a teaching model for deciding what a calculation can support.
- Read matrix rows as measurements and columns as responses to individual unknowns.
- Propagate a bounded measurement error through a linear reconstruction.
- Distinguish a unique solution, a well-conditioned solution and a minimum-length convention.
- Use residual orthogonality to check a least-squares estimate and state what it cannot verify.
A matrix is a measurement design
Let $z=(z_1,z_2)^\top$ contain two unknown fixture displacements, both in millimetres. A linear measurement model is $y=Hz+\eta$, where $y$ is the vector of sensor readings and $\eta$ is additive sensor error, also in millimetres. Each row of the dimensionless matrix $H$ describes one channel: it lists the coefficient multiplying each unknown displacement. Each column tells how all readings change when only one displacement increases by one millimetre.
To use the model, one assumes these coefficients are known and remain valid over the displacement range being studied. Calibration error in $H$ is a different uncertainty from additive error in $y$; the examples initially include only the latter. Solving the linear equations cannot establish that the measurement model itself is correct. It gives a conditional reconstruction from a stated model.
Suppose one channel measures the sum $z_1+z_2$ and another measures the difference $z_1-z_2$. Equal readings can then be explained by changes in different combinations. Adding and subtracting the channels separates these combinations. The matrix calculation is a compact record of that physical idea.
Set up. Take $H=\begin{bmatrix}1&1\\1&-1\end{bmatrix}$ and readings $y=(6,2)^\top$ millimetres. First ignore additive error to compute an estimate $\hat z$. The equations are $\hat z_1+\hat z_2=6$ and $\hat z_1-\hat z_2=2$. Adding gives $2\hat z_1=8$; subtracting gives $2\hat z_2=4$. Thus $\hat z=(4,2)^\top$ millimetres.
Check the map. Multiplication gives $H\hat z=(6,2)^\top$. Also $H^\top H=2I$, where $I$ is the two-dimensional identity. Therefore $\|Hz\|_2^2=z^\top H^\top Hz=2\|z\|_2^2$: every direction stretches by $\sqrt2$. Both singular values are $\sqrt2$, so the spectral condition number is one. There is no preferred weak direction.
Restore uncertainty. With $|\eta_i|\le0.1$, the error in the estimate is $\hat z-z=H^{-1}\eta$, since $\hat z=H^{-1}y$ and $y=Hz+\eta$. Here:
Decide. If a hypothetical assembly requires $z_1\le4.15$ millimetres, its worst permitted value is $4.1$, so this upper-limit test passes. A requirement $z_1\le4.05$ would not be certified. The error set is a rotated square, not a square with independent reconstructed errors: attaining the largest error in the first displacement forces zero error in the second at the relevant sensor-error corners.
Find the direction the measurements barely see
A system can be invertible while giving fragile estimates. Replace the difference channel by another almost-sum channel. The rows now point in nearly the same direction. Increasing $z_1$ while decreasing $z_2$ leaves the first reading unchanged and changes the second only slightly. This is a weakly observed direction: a large displacement change produces a small measurement change.
The smallest singular value quantifies the weakest stretch. For an invertible square matrix, the largest amplification through its inverse is $1/\sigma_{\min}(H)$. The condition number $\sigma_{\max}(H)/\sigma_{\min}(H)$ compares the strongest and weakest stretches; it concerns relative sensitivity in Euclidean coordinates. It is not a universal absolute error bound without a measurement error size. Units and coordinate scaling must be chosen before interpreting that comparison.
Change the design. Let $H=\begin{bmatrix}1&1\\1&1.1\end{bmatrix}$ and let the error-free readings be $(6,6.2)^\top$ millimetres. Subtraction gives $0.1z_2=0.2$, hence $z_2=2$ and $z_1=4$. The determinant $0.1$ is nonzero, so the solution is unique.
Inject a small permitted error. Perturb the readings by $\eta=(0.01,-0.01)^\top$. The new readings are $(6.01,6.19)^\top$. Their difference is $0.18$, so the reconstructed second displacement becomes $1.8$. Subtracting it from $6.01$ gives the first displacement $4.21$. The error is $(0.21,-0.2)^\top$, whose Euclidean length is $0.29$ millimetres, although each sensor changed by only $0.01$ millimetres.
Explain the sensitivity. Direct elimination gives $\Delta z_2=(\eta_2-\eta_1)/0.1$ and $\Delta z_1=11\eta_1-10\eta_2$. Opposite-sign errors are amplified by subtraction and division by the small row difference. Since this particular $H$ is symmetric positive definite, its singular values equal its positive eigenvalues:
Make a design decision. Exact solution of these equations cannot remove the sensitivity. A sensor observing a genuinely different direction, stronger sensor accuracy, or an additional justified prior constraint would change the information. Reporting more decimal places would not. Replacing $1.1$ by exactly $1$ would remove uniqueness altogether: both channels would report only the sum.
More measurements require a fitting criterion
Adding a third channel that directly measures $z_2$ gives a rectangular matrix. Noisy readings may fail to lie in its two-dimensional column space, so no displacement vector matches all of them exactly. Least squares chooses the estimate minimizing the sum of squared residuals, $\|H\hat z-y\|_2^2$. A residual is a mismatch in measurement space, not automatically a displacement error.
To derive the check without memorizing a derivative, perturb a candidate estimate by a small vector $tv$. Writing $r=H\hat z-y$, the squared residual becomes $\|r+tHv\|_2^2=\|r\|_2^2+2t v^\top H^\top r+t^2\|Hv\|_2^2$. A minimum cannot improve for either sign of sufficiently small $t$, so $H^\top r=0$. The residual is perpendicular to every possible modeled change in the readings. If $H$ has independent columns, $H^\top H$ is positive definite and this condition identifies a unique least-squares estimate.
Equal residual weights assume that squared errors in the different channels are comparable for the decision being made. If one sensor has a much different error scale, scaling or weighting the rows may be appropriate, but that is an additional modeling choice. A small residual can also coexist with a large state error along a weakly observed direction. Checking residuals and checking sensitivity answer different questions.
With only the sum measurement $z_1+z_2=6$, a pseudoinverse returns $(3,3)$. That is the solution of smallest Euclidean length, because $\|(3+t,3-t)\|_2^2=18+2t^2$. The measurement did not establish equal displacements. Repair the conclusion by reporting the full solution family or by stating the extra criterion explicitly. A convenient unique estimate is not the same as uniquely determined physical quantities.
Application practice: estimation and justified decisions
Exercise A.B1 — Easy: Check an assembly limit after reconstruction
The balanced sum/difference design has readings $(3,-1)^\top$ millimetres. Reconstruct both displacements. A component requires $z_1\le1.05$ millimetres. Can this be certified if each additive sensor error has magnitude at most $0.1$? What if the bound improves to $0.04$? Explain why using only the reconstructed central value is insufficient.
Show hint
Add the readings, then carry the two sensor errors through the same operation.
Show worked solution
1. Reconstruct the central estimate. The calibrated model is $y=Hz+\eta$ with $H=\begin{bmatrix}1&1\\1&-1\end{bmatrix}$ and readings $y=(3,-1)^\top$ millimetres. Adding the two error-free reconstruction equations gives $2\hat z_1=3+(-1)=2$; subtracting gives $2\hat z_2=3-(-1)=4$. Thus $\hat z=(1,2)^\top$ millimetres.
2. Propagate the sensor errors. Since $H^{-1}=H/2$, $\hat z-z=H\eta/2$. The first coordinate is $\hat z_1-z_1=(\eta_1+\eta_2)/2$. If each $|\eta_i|\le E$, the triangle inequality gives $|\hat z_1-z_1|\le(|\eta_1|+|\eta_2|)/2\le E$. Consequently the true displacement lies in $[1-E,1+E]$ millimetres. Equal extreme sensor errors attain both endpoints: for example $\eta_1=\eta_2=-E$ gives $z_1=1+E$.
3. Compare the entire interval with the assembly limit. With $E=0.1$, the largest compatible $z_1$ is $1.1\gt1.05$ millimetres, so the limit cannot be certified. With $E=0.04$, every compatible value obeys $z_1\le1.04\le1.05$ millimetres, so the limit is certified. These conclusions use the stated calibration and additive-error bounds. The central estimate $1$ alone does not test every displacement consistent with the readings.
Exercise A.B2 — Medium: Separate minimum length from identification
Only one error-free channel remains: $z_1+z_2=6$ millimetres. Find all real solutions and the minimum-Euclidean-length solution. If physical information additionally says $z_1,z_2\ge0$, find the full range of $z_1$. Does either calculation certify a limit $z_1\le4$?
Show hint
Parameterize the line around (3,3), then impose nonnegativity on both coordinates.
Show worked solution
1. Parameterize the measurements. The equation $z_1+z_2=6$ leaves one free coordinate. Write $z_1=3+t$; substitution forces $z_2=3-t$. Every real $t$ gives a solution, and every solution has this form.
2. Minimize the length. Squaring the Euclidean norm gives $(3+t)^2+(3-t)^2=9+6t+t^2+9-6t+t^2=18+2t^2$. This is at least $18$, with equality only for $t=0$. Thus $(3,3)$ millimetres is the unique minimum-length solution. It is a choice among measurement-compatible states, not an additional measurement of the true state.
3. Apply physical nonnegativity. The two inequalities become $3+t\ge0$ and $3-t\ge0$, respectively $t\ge-3$ and $t\le3$. Hence $t\in[-3,3]$ and $z_1=3+t$ ranges over $[0,6]$ millimetres.
4. Test certification. The state $(5,1)$ has nonnegative coordinates and sums to $6$, yet $z_1=5\gt4$. It is a counterexample under both the unrestricted measurement model and its nonnegative restriction. The minimum-length estimate satisfies $z_1\le4$, but selecting that estimate does not certify the unknown physical displacement. An additional justified restriction or measurement must rule out the counterexample.
Exercise A.B3 — Medium: Normalize quantities before taking a norm
A prediction is $y=p+(2\ \mathrm{s})v$, where position $p$ is in millimetres and velocity $v$ in millimetres per second. Define dimensionless coordinates by $p=(2\ \mathrm{mm})z_1$ and $v=(0.5\ \mathrm{mm/s})z_2$. If the normalized state error obeys $\|\Delta z\|_2\le0.1$, derive the largest possible prediction error and an attaining direction. Compare with separately bounding both normalized coordinates by $0.1$.
Show hint
In normalized coordinates the measurement row is (2,1), with output in millimetres. Apply Cauchy–Schwarz and examine equality.
Show worked solution
1. Put the physical model into dimensionless coordinates. Substitute $p=(2\,\mathrm{mm})z_1$ and $v=(0.5\,\mathrm{mm/s})z_2$ into $y=p+(2\,\mathrm{s})v$. Seconds cancel in the second term, giving $y=(2z_1+z_2)\,\mathrm{mm}$. Therefore $\Delta y=(2\Delta z_1+\Delta z_2)\,\mathrm{mm}$.
2. Bound the ball and attain the bound. With $w=(2,1)$, Cauchy–Schwarz gives $|w^\top\Delta z|\le\|w\|_2\|\Delta z\|_2\le0.1\sqrt{2^2+1^2}=0.1\sqrt5$. Thus the largest possible absolute prediction error is $0.1\sqrt5\,\mathrm{mm}\approx0.223607\,\mathrm{mm}$. Choose $\Delta z=0.1(2,1)/\sqrt5$. Its squared length is $0.01(4+1)/5=0.01$, and its output is $0.1(4+1)/\sqrt5=0.1\sqrt5$ millimetres. Negating the direction attains the negative extreme.
3. Compare separate coordinate bounds. Replacing the ball by $|\Delta z_i|\le0.1$ gives $|\Delta y|\le2(0.1)+0.1=0.3$ millimetres. The box attains this at $(0.1,0.1)$, whose Euclidean length is $0.1\sqrt2\gt0.1$. It is therefore a valid but larger uncertainty set. The normalization scales define the geometry of the original ball; adding raw squared positions and velocities would mix incompatible units.
Exercise A.B4 — Hard: Audit a third sensor using residual orthogonality
Add a direct second-displacement sensor to the near-redundant design: $H=\begin{bmatrix}1&1\\1&1.1\\0&1\end{bmatrix}$ and $y=(6,6.2,2.1)^\top$ millimetres. Find the equal-weight least-squares estimate by solving its normal equations. Check residual orthogonality, explain uniqueness, and compare with the underlying teaching state $(4,2)$ when only the third reading was perturbed by $0.1$.
Show hint
Compute the two-by-two Gram matrix and H-transpose times y. Eliminate one unknown and retain enough precision to check both residual equations.
Show worked solution
1. Form the normal equations. Equal-weight least squares minimizes $\|y-Hz\|_2^2$. Differentiating with respect to $z$ gives $H^\top Hz=H^\top y$. Taking column dot products produces
2. Solve by elimination. The equations are $2\hat z_1+2.1\hat z_2=12.2$ and $2.1\hat z_1+3.21\hat z_2=14.92$. Subtract $2.1$ times the first equation from $2$ times the second. The first-coordinate terms cancel, leaving $(6.42-4.41)\hat z_2=29.84-25.62$, so $2.01\hat z_2=4.22$. Hence $\hat z_2=422/201\approx2.09950249$. Back-substitution gives $\hat z_1=[12.2-2.1(422/201)]/2=261/67\approx3.89552239$ millimetres.
3. Check residual orthogonality exactly. Use the convention $r=y-H\hat z$. With denominator $201$, $\hat z=(783,422)/201$. Therefore $r_1=6-1205/201=1/201$, $r_2=6.2-[783+(11/10)422]/201=-1/201$, and $r_3=2.1-422/201=1/2010$, all in millimetres. The column products are $r_1+r_2=0$ and $r_1+1.1r_2+r_3=(10-11+1)/2010=0$, proving $H^\top r=0$ without rounding error.
4. Explain uniqueness. If $H\delta=0$, the third row forces $\delta_2=0$ and the first then forces $\delta_1=0$. Thus $H$ has independent columns. For any proposed change $\delta$, orthogonality gives $\|y-H(\hat z+\delta)\|_2^2=\|r-H\delta\|_2^2=\|r\|_2^2+\|H\delta\|_2^2$. This is strictly greater for every nonzero $\delta$, establishing the unique global minimum.
5. Compare with the teaching state. The state $(4,2)$ predicts $(6,6.2,2)$, so the recorded perturbation is $(0,0,0.1)$ millimetres. The estimate error is $\hat z-(4,2)=(-21,20)/201=(-7/67,20/201)$ millimetres. Its norm is $\sqrt{21^2+20^2}/201=29/201\approx0.144279$ millimetres. Least squares distributes the discrepancy across the readings; this particular perturbation does not establish a worst-case comparison between arbitrary sensor designs.
Read the geometry behind the answer
The measurement rows determine what can be distinguished. Their column rank decides uniqueness; their weakest singular direction decides sensitivity; the error set and its units decide what a reconstruction can certify. Least squares then explains what happens when measurements disagree. None of these questions is answered merely by successfully multiplying an inverse into a vector.
For recall, sketch the solution line of one sum measurement and explain what a second difference measurement changes. Reproduce the near-redundant calculation without an inverse. Explain why a residual can be zero while sensitivity is poor, and why a minimum-length estimate can satisfy a limit that the unknown true state violates. Finally, identify where deterministic sensor bounds entered the assembly decision.
Primer B turns least squares into a general optimization model and adds constraints to estimation or command selection. Gaussian-process regression in Module 3 uses related linear solves with a probabilistic interpretation. The present bounds were deterministic; assigning a probability to them requires the explicit assumptions developed in Primer C.
Exercises
Ready to use these matrix tools?
Before Primer B, redo the Easy and Medium exercises on vector norms, eigenvectors, definiteness and solves, and singular values. You should be able to explain why a symmetric PSD matrix has a nonnegative quadratic form, and why an eigenvalue is different from a singular value.
Before Module 2, check the Schur complement practice. Before Module 3, check the feature and RKHS practice. A missed calculation points to that section's local refresher; a missed assumption points to its definition or pitfall box. Next: Primer B: derivatives and optimisation.
Further Reading
| Resource | Type | Read it for |
|---|---|---|
| Introduction to Linear Algebra (Strang), 6th ed. | Textbook, Wellesley-Cambridge 2023 | Refreshing the first course: eigenvalues, positive definiteness, SVD. |
| Essence of Linear Algebra (Sanderson, 3Blue1Brown) | Video series, 2016 | Pictures: linear maps, determinants as volume, eigenvectors. |
| Linear Algebra Done Right (Axler), 4th ed. | Textbook, Springer 2024, open access | Inner-product spaces, adjoints, spectral theorem, positive operators, SVD, with proofs. |
| Introduction to Applied Linear Algebra (Boyd, Vandenberghe) | Textbook, Cambridge 2018, free PDF | Norms, distances, least squares and pseudo-inverses, computationally. |
| Convex Optimization (Boyd, Vandenberghe), App. A | Textbook, Cambridge 2004, free PDF | Dual and induced norms, the PSD cone, Schur complements including the singular case. |
| Numerical Linear Algebra (Trefethen, Bau) | Textbook, SIAM 1997 (25th-anniv. ed. 2022) | SVD, conditioning, Cholesky, power iteration, conjugate gradients. |
| Matrix Analysis (Horn, Johnson), 2nd ed. | Reference, Cambridge 2012 | Norms, Hermitian and positive definite matrices, Loewner order, inertia. |
| The Matrix Cookbook (Petersen, Pedersen) | Reference, version Nov. 2012 | Identities: Woodbury, determinant lemma, trace, Kronecker. |
| Gaussian Processes for Machine Learning (Rasmussen, Williams) | Textbook, MIT Press 2006, free PDF | Algorithm 2.1 (Cholesky GP regression), matrix identities in Appendix A. |
| Gaussian Processes and Kernel Methods: A Review on Connections and Equivalences (Kanagawa, Hennig, Sejdinovic, Sriperumbudur) | Tutorial review, arXiv 2018 | RKHS, feature maps, Mercer expansions: the bridge to Module 3. |