ES98A · Course contents

Week 1: From measurements to models

A material is stretched twice. At strain ε1=1\varepsilon_1=1 it produces stress σ1=2\sigma_1=2; at strain ε2=2\varepsilon_2=2 it produces stress σ2=3\sigma_2=3. These are illustrative values in rescaled units, not experimental data.

If stress is proportional to strain, the first measurement suggests a stiffness of 22, while the second suggests 1.51.5. Which should we use to predict a third measurement?

The difficulty is not that we lack a formula. We have one. The difficulty is deciding how a formula should meet imperfect observations. This question leads us from fitting a single number to the geometry of vectors, projections and matrices. Later in the module, the unknown will be an entire function; the geometry developed here will still be useful.

In this week: models and misfit, linear parameters, inner products and coordinates, outer products, least squares, adjoints and eigenvectors, positive matrices and factorisations.

1. What does it mean to learn a model?

A physical law and a disagreement

Within the linear elastic regime, Hooke's law is

σ=Eε.\sigma=E\varepsilon.

Here σ\sigma is stress (force per cross-sectional area), ε\varepsilon is strain (relative extension), and EE is Young's modulus. The law predicts stress from strain once EE is known. Learning EE from measurements runs the calculation in the opposite direction.

First hold the stiffness fixed at E=2E=2. What must happen to the predicted stress when we double the strain? Follow the same change in the material and on the graph.

Stretch twice as far; predict twice the stress

1. Stretch the material

Dashed: unstretched endPull →

Strain ε = 1; the law predicts stress σ = 2. The stiffness stays fixed.

2. Read the prediction

001224stress σstrain ε

Every selected point stays on σ = 2ε. A single E constrains all predictions together.

ε = 1 → σ = 2, with E = 2.

An ideal material with fixed E = 2. Strains are rescaled and extension is exaggerated; assume the linear elastic regime throughout. Select a strain and compare the material with its position on the line. ↗

The line makes a strong commitment: once we choose its slope, we have chosen the stress at every strain. This is why two observations can disagree with a one-parameter model.

For our two observations, choosing EE predicts the pair (E,2E)(E,2E). Whatever value we choose, the second predicted stress must be twice the first. The observed pair (2,3)(2,3) does not have that property. No parameter makes both equations exactly true.

We therefore need to say what counts as a good compromise. Suppose we penalise the two squared discrepancies equally:

Φ(E)=(2−E)2+(3−2E)2.\Phi(E)=(2-E)^2+(3-2E)^2.

Before differentiating, consider the tempting choice of averaging the two individually inferred stiffnesses.

Does averaging the two inferred stiffnesses, giving E = 1.75, minimise this sum of squared stress errors?

Expanding makes the distinction precise:

Φ(E)=5E2−16E+13=5(E−85)2+15.\Phi(E)=5E^2-16E+13 =5\left(E-\frac85\right)^2+\frac15.

Thus Eopt=8/5=1.6E^{\mathrm{opt}}=8/5=1.6 is the unique minimiser and the remaining squared misfit is 1/51/5. For a third strain ε=3\varepsilon=3, the fitted model predicts stress 4.84.8.

But neither a small misfit nor a unique optimum tells us how reliable that prediction is. Perhaps the instrument is noisy; perhaps the material is no longer in its linear regime. Choosing a loss function is also a modelling decision: equal squared errors are not automatically appropriate when observations have different precisions.

From this example to predictive modelling

Predictive modelling combines data with a principles-driven model, often through scientific computation, to predict behaviour and assess uncertainty. This module uses algebraic models and ODEs; PDEs and agent-based models extend the same questions.

Write the model as M(x;θ)\mathcal M(x;\theta), with input xx and parameters θ\theta. In an idealised exact model,

y=M(x;θ∗).y=\mathcal M(x;\theta^*).

In practice we write y≈M(x;θ)y\approx\mathcal M(x;\theta) because parameters, observations and even the model's functional form may be imperfect. For input–output pairs (xj,yj)j=1J(x_j,y_j)_{j=1}^J, one possible calibration criterion is the misfit

Φ(θ)=∑j=1J∣yj−M(xj;θ)∣2.\Phi(\theta)=\sum_{j=1}^J |y_j-\mathcal M(x_j;\theta)|^2.

The scalar example has already separated three questions: how to find a minimiser, whether it is unique, and whether the resulting prediction is trustworthy. These are different questions, and the course will develop different tools for them.

Forward uncertainty quantification asks how uncertainty in inputs or parameters affects model outputs. Inverse problems, also called inference, learning or backward UQ in this setting, ask what observations tell us about unknown parameters and their uncertainty. Optimisation supplies fitted values; probability will let us describe uncertainty; function spaces will let the unknown itself be a function.

2. A curved model can still be linear in its parameters

Why start with linear algebra if the world is not linear? Because a model can depend nonlinearly on its input while depending linearly on the quantities we are trying to learn.

Choose fixed feature functions f1,…,fnf_1,\ldots,f_n and write

M(x;θ)=∑k=1nθkfk(x).\mathcal M(x;\theta)=\sum_{k=1}^n \theta_k f_k(x).

For example, f1(x)=1f_1(x)=1, f2(x)=xf_2(x)=x and f3(x)=x2f_3(x)=x^2 produce a quadratic curve. Adding two coefficient vectors adds their predicted curves, even though adding two inputs generally does not add their outputs.

Change the features, keep linearity in the coefficients
Linear: M(x; θ) = θ₁ + θ₂x
-2-112−11x
– – θ = (1, ½)··· θ̃ = (−½, 1)━━ θ + θ̃ = (½, 1½)

Add the heights of the two patterned curves at any x: you get the height of the solid curve. Bending the graph does not break this rule.

The solid result is the pointwise sum of the dashed and dotted curves. Only the feature functions change between views; the coefficient vectors and axis scales stay fixed. The quadratic is the subfamily with zero constant term; the Fourier example uses two real features, rather than the complex notation introduced below. ↗

Switch from the straight line to the quadratic and then to the Fourier example. The shapes change, but the solid curve remains the sum of the two patterned curves at each input. The addition rule is about coefficients, not about the shape of a graph. In symbols,

M(x;θ+θ~)=M(x;θ)+M(x;θ~),\mathcal M(x;\theta+\widetilde\theta) =\mathcal M(x;\theta)+\mathcal M(x;\widetilde\theta), M(x+x~;θ)≠M(x;θ)+M(x~;θ)in general.\mathcal M(x+\widetilde x;\theta) \ne \mathcal M(x;\theta)+\mathcal M(\widetilde x;\theta) \quad\text{in general}.

At the observed inputs, collect feature values into Ajk=fk(xj)A_{jk}=f_k(x_j). All predicted observations are then the vector AθA\theta. Our Hooke example is the special case with one column, A=(1,2)TA=(1,2)^T.

A nonlinear feature can also change the geometry of a classification problem. An inner disk and an outer ring cannot be separated by a straight line in the input plane. Lift each point to a height equal to its squared radius, then look for a flat separating plane. This is an illustration of feature geometry, not an additional assumption in our regression model.

A new coordinate makes a curved boundary flat

Original coordinates

-2.302.3-2.102.1x₁x₂

Lifted feature space

-2.502.5-0.803.1x₁ − ½x₂ (projected)projected vertical coordinatezz = t

φₜ(x₁,x₂) = (x₁,x₂,t(x₁²+x₂²)), t = 0.000

Solid teal points form the disk; hollow amber points form the outer ring. At full lift, the separating plane is z=1.

Play once, pause, or scrub to inspect an intermediate state.

Ready to explore.
The fixed inner disk has radius at most 0.7; the outer ring starts at radius 1.3. Lift by z=t(x²+y²). At t=1, the plane z=1 separates these classes. The tilted right view uses a fixed oblique projection. A separator linear in the features is quadratic in the original coordinates. ↗

A Fourier model makes the same point:

M(x;θ)=∑kθkeikx,θ=(…,θ−1,θ0,θ1,…).\mathcal M(x;\theta)=\sum_k\theta_k e^{ikx}, \qquad \theta=(\ldots,\theta_{-1},\theta_0,\theta_1,\ldots).

For now, take a finite sum. Infinite Fourier expansions require convergence and a suitable coefficient space; those questions become central in Week 5.

The fitting problem is now geometric: which point in the set of model predictions is closest to the observed data vector? To answer, we need a way to measure distance and resolve a vector into directions.

3. Coordinates change; the vector does not

Imagine measuring a displacement using two perpendicular rulers. Rotating the rulers changes both readings, but not the displacement. The readings are coordinates; the underlying vector is the object they describe.

In the figure, the vector is fixed at x=(2,1)x=(2,1). Rotate the first ruler towards the vector. Before revealing the second component, predict what has happened to the part the first ruler misses.

One vector, two changing measurements
ψ₁ψ₂x01 unit

First coordinate α₁ = 2.000. What component would complete the vector?

Solid ink: fixed vector x = (2, 1). Teal: its first projection. Dashed segment: what that projection misses. Rotate the orthonormal rulers, then reveal the second component. Both axes use the same fixed scale. The calibration preset returns here later in the argument. ↗

When the first direction aligns with xx, its projection recovers the whole vector. When it is perpendicular to xx, that projection is zero. At intermediate angles, the missing part lies along the second ruler. The two pieces always reconstruct the same vector. This is the geometric content we now formalise.

Inner product, norm and orthogonality

Let K\mathbb K be R\mathbb R or C\mathbb C. In Rn\mathbb R^n, the Euclidean dot product and norm are

x⋅y=∑j=1nxjyj,∣x∣=x⋅x.x\cdot y=\sum_{j=1}^n x_jy_j, \qquad |x|=\sqrt{x\cdot x}.

For complex vectors we use

⟨x,y⟩=∑j=1nxj‾yj,∣x∣=⟨x,x⟩.\langle x,y\rangle=\sum_{j=1}^n\overline{x_j}y_j, \qquad |x|=\sqrt{\langle x,x\rangle}.

Conjugation matters: without it, a nonzero complex vector could have a zero or non-real “squared length”. Our convention is conjugate-linear in the first argument and linear in the second.

Vectors are orthogonal when ⟨x,y⟩=0\langle x,y\rangle=0. A collection is orthonormal when its vectors have unit norm and distinct vectors are orthogonal. For real vectors, ⟨ψ,x⟩\langle \psi,x\rangle with ∣ψ∣=1|\psi|=1 is the signed length measured along ψ\psi.

Reconstruction theorem and Parseval's identity

A basis ψ1,…,ψn\psi_1,\ldots,\psi_n gives a unique expansion x=∑jαjψjx=\sum_j\alpha_j\psi_j. An orthonormal basis makes its coefficients directly measurable:

αj=⟨ψj,x⟩,x=∑j=1n⟨ψj,x⟩ψj.\alpha_j=\langle\psi_j,x\rangle, \qquad x=\sum_{j=1}^n\langle\psi_j,x\rangle\psi_j.

Proof. Take the inner product of the expansion with ψi\psi_i. Linearity in the second argument and ⟨ψi,ψj⟩=δij\langle\psi_i,\psi_j\rangle=\delta_{ij} give

⟨ψi,x⟩=∑jαj⟨ψi,ψj⟩=αi.\langle\psi_i,x\rangle =\sum_j\alpha_j\langle\psi_i,\psi_j\rangle=\alpha_i.

The same orthogonality eliminates all cross terms in the squared norm:

∣x∣2=⟨∑iαiψi,∑jαjψj⟩=∑i,jαi‾αjδij=∑j∣αj∣2.|x|^2 =\left\langle\sum_i\alpha_i\psi_i,\sum_j\alpha_j\psi_j\right\rangle =\sum_{i,j}\overline{\alpha_i}\alpha_j\delta_{ij} =\sum_j|\alpha_j|^2.

This is Parseval's identity. In the experiment it says α12+α22=5\alpha_1^2+\alpha_2^2=5 at every angle. A change of orthonormal coordinates redistributes squared length without creating or destroying it. In Week 5 the finite sum becomes a convergent series; in Week 7 the same identity accounts for the variance of random functions.

We can make the conserved quantity visible as area. Compare the original rulers with a 45∘45^\circ rotation: the individual squares change, but their combined area does not.

Different coordinates, the same total area

Rulers rotated 0°

α₁² = 4.0α₂² = 1.0+

4.0 + 1.0 = 5.0 units of squared length.

Rulers rotated 45°

α₁² = 4.5α₂² = 0.5+

4.5 + 0.5 = 5.0 units of squared length.

Each square has side length |αⱼ|, so its area is αⱼ². Both panels use the same area scale. Rotating the orthonormal rulers redistributes the total 5; it does not change x = (2, 1). The square pictures illustrate the real two-dimensional case of the identity proved above. ↗

4. Turn a measurement into an operator

The coordinate experiment performs two operations: measure ⟨ψ1,x⟩\langle\psi_1,x\rangle, then place that amount along ψ1\psi_1. We can package this as a linear map. More generally, the measuring direction and the output direction need not be the same.

Definition (course outer-product convention). For a∈Kma\in\mathbb K^m and b∈Knb\in\mathbb K^n, define a⊗b:Km→Kna\otimes b:\mathbb K^m\to\mathbb K^n by

(a⊗b)x=⟨a,x⟩b,(a⊗b)ij=biaj‾.(a\otimes b)x=\langle a,x\rangle b, \qquad (a\otimes b)_{ij}=b_i\overline{a_j}.

Its matrix is ba∗ba^*. Its range lies in the line spanned by bb, so it has rank at most one, and rank exactly one when both vectors are nonzero. The order of the two vectors is worth remembering: first measure, then reconstruct.

For a=(1,0)a=(1,0) and b=(0,2)b=(0,2),

a⊗b=(0020).a\otimes b=\begin{pmatrix}0&0\\2&0\end{pmatrix}.

It reads the first input coordinate and outputs twice that value in the second direction.

Follow an input x=(2,1)x=(2,1) through these two operations. Notice the bottleneck in the middle: once we have kept just one number, the second input coordinate cannot affect the output.

One reading, one output direction

1. Measure along a

011xa2

Project x onto the horizontal unit direction a. Read off the scalar 2.

2. Keep one number

⟨a, x⟩ = 2measure → reconstruct

The inner product is a scalar, not a vector. It remembers only the chosen measurement.

3. Place it along b

0112b = (0, 4)b = (0, 2)

Multiply b by that reading. The output is 2b = (0, 4), regardless of the discarded coordinate.

Here x = (2, 1), a = (1, 0) and b = (0, 2). All inputs with first coordinate 2 produce the same output (0, 4): the second input coordinate is discarded. This illustrates why the range of a ⊗ b is at most one-dimensional. ↗

If ∣u∣=1|u|=1, the special case P=u⊗uP=u\otimes u is the orthogonal projection onto span⁡{u}\operatorname{span}\{u\}:

Px=⟨u,x⟩u,P2=P.Px=\langle u,x\rangle u,\qquad P^2=P.

The residual is perpendicular to that line, since ⟨u,x−Px⟩=⟨u,x⟩−⟨u,x⟩=0\langle u,x-Px\rangle=\langle u,x\rangle-\langle u,x\rangle=0. This is precisely the dashed segment in the rotating-rulers experiment. Unlike the outer-product example above, a projection uses the same unit direction to measure and reconstruct.

Reconstructing from every direction in an ONB gives an operator identity:

x=∑j(ψj⊗ψj)x,I=∑jψj⊗ψj.x=\sum_j(\psi_j\otimes\psi_j)x, \qquad I=\sum_j\psi_j\otimes\psi_j.

A complicated map can sometimes be understood by decomposing it into simple “measure then reconstruct” pieces. That will be the central idea of Week 2's SVD.

5. Return to the measurements: fitting is projection

Our data vector is y=(2,3)y=(2,3), while a parameter EE produces EaEa with a=(1,2)a=(1,2). The allowed predictions form a line through the origin. Notice that this line lives in observation space: its two coordinates represent two different experiments.

The next figure uses the fitted E=1.6E=1.6 from the opening calculation. On the left, we see two vertical errors in a stress–strain graph. On the right, those same errors become the two coordinates of one vector. This change of viewpoint is the step that turns curve fitting into projection.

The same fit, seen in two different spaces

1. Fit the stress–strain graph

011+0.4−0.2stressstrain

One E sets the slope. Each vertical segment is observed stress minus predicted stress.

2. Project the observation pair

011stress 2stress 1py

Now the axes mean stress in experiment 1 and stress in experiment 2. The shortest residual is perpendicular to the prediction line.

The vertical errors on the left become the coordinates of one residual vector on the right: r = (0.4, -0.2). Both views minimise the same squared error, 0.2. The right-hand line is a line of possible prediction pairs, not the stress–strain graph. ↗

Now let the stiffness move continuously towards the optimum. Follow the prediction in observation space and the loss at the same time. Which geometric event coincides with the bottom of the loss curve?

The shortest residual finds the fit

Prediction and residual

-0.503.5-0.504first observationsecond observation

The same squared loss

02.5014stiffness EΦ(E)

E=0.000, Φ(E)=13.000, (1,2)·residual=8.000

The highlighted prediction travels along the model line. Only at E=1.6 is its residual perpendicular, with squared loss 0.2.

Play once, pause, or scrub to inspect an intermediate state.

Ready to explore.
Fixed observations y=(2,3), prediction E(1,2). Move E from 0 to 1.6. The residual becomes perpendicular to the prediction line at the minimum; the second plot traces the same squared loss. ↗

To explore this view, return to the coordinate experiment and select Calibration preset. It places the first ruler along (1,2)(1,2) and changes the observed vector to (2,3)(2,3). The perpendicular residual suggests a reason the algebraic optimum is optimal.

Which point on the line is closest to yy? Decompose y=p+ry=p+r, where pp lies on the line and rr is perpendicular to it. For any other point zz on the line, p−zp-z is perpendicular to rr, so

∣y−z∣2=∣r+(p−z)∣2=∣r∣2+∣p−z∣2≥∣r∣2.|y-z|^2=|r+(p-z)|^2=|r|^2+|p-z|^2\ge |r|^2.

Equality occurs only at z=pz=p. The closest point is therefore the orthogonal projection. Normalising aa gives

p=⟨a,y⟩∣a∣2a=85(1,2)=(1.6,3.2).p=\frac{\langle a,y\rangle}{|a|^2}a =\frac85(1,2)=(1.6,3.2).

Thus Eopt=8/5E^{\mathrm{opt}}=8/5, exactly as before, and r=(0.4,−0.2)r=(0.4,-0.2) satisfies a⋅r=0a\cdot r=0. The irreducible squared residual is ∣r∣2=0.2|r|^2=0.2. The algebraic minimum and the geometric projection are two descriptions of the same result.

Exact systems and least squares

For a square matrix A∈Kn×nA\in\mathbb K^{n\times n}, the system Ax=bAx=b has the unique solution A−1bA^{-1}b if AA is invertible. Numerical algorithms such as Gaussian elimination, conjugate gradients (under appropriate assumptions) and GMRES usually solve the system without explicitly constructing the inverse.

For a rectangular A∈Km×nA\in\mathbb K^{m\times n}, the observation bb may not belong to the range of AA. Least squares asks instead for

min⁡x∈Kn∣Ax−b∣2=min⁡x∑j=1m∣(Ax)j−bj∣2.\min_{x\in\mathbb K^n}|Ax-b|^2 =\min_x\sum_{j=1}^m|(Ax)_j-b_j|^2.

The optimal predicted vector is the projection of bb onto the range. Different parameters can produce that same prediction if AA has a nontrivial kernel. Existence of a best prediction and uniqueness of its parameters are therefore separate issues.

Week 2 turns the perpendicular-residual condition into the normal equations A∗(Ax−b)=0A^*(Ax-b)=0. Before that expression can be useful, we should understand the adjoint and the directions in which a matrix acts simply.

6. Which directions make a matrix easy to understand?

The adjoint transfers a measurement

Suppose AA maps an input xx into an output space. Measuring the output against yy gives ⟨Ax,y⟩\langle Ax,y\rangle. Can we obtain the same number by measuring the input instead?

The adjoint A∗A^* is defined by

⟨Ax,y⟩=⟨x,A∗y⟩.\langle Ax,y\rangle=\langle x,A^*y\rangle.

For matrices, A∗=A‾ TA^*=\overline A^{\,T}: (A∗)ij=Aji‾(A^*)_{ij}=\overline{A_{ji}}. The ordinary transpose is (AT)ij=Aji(A^T)_{ij}=A_{ji}. Over the real numbers the two agree.

Here is a concrete way to read the identity. Take the shear A=(1101)A=\begin{pmatrix}1&1\\0&1\end{pmatrix}. We can move the input forwards through AA and then measure, or move the measuring vector backwards through A∗A^* and measure the original input. Compare the two dot products, rather than expecting the two pictures to have the same lengths or angles.

Move the vector forwards—or move the measuring vector backwards

1. Measure in the output space

011Axy

First transform x to Ax = (3, 2). Then ⟨Ax, y⟩ = 3·2 + 2·1 = 8.

2. Measure in the input space

011xA*y

Leave x unchanged. Move y to A*y = (2, 3), so ⟨x, A*y⟩ = 1·2 + 2·3 = 8.

A = ((1, 1), (0, 1)) is a shear; x = (1, 2) and y = (2, 1). Both routes produce 8. A* transfers a linear measurement to the input space; it is not generally the inverse of A. This real example uses A* = Aᵀ; the complex definition also conjugates. ↗

The identity follows by expanding the sums, and it explains why adjoints appear in fitting: they move a condition on a residual in observation space back into parameter space.

Eigenvectors and the Hermitian spectral theorem

Most directions are turned as well as stretched by a matrix. An eigenvector identifies an exception:

Av=λv,∣v∣=1.Av=\lambda v,\qquad |v|=1.

For real λ\lambda the output stays on the same line; a negative eigenvalue reverses its direction. In general eigenvalues and eigenvectors may be complex, even for a real matrix.

A square matrix is Hermitian or self-adjoint if A=A∗A=A^*. Such matrices admit a particularly complete directional description.

Spectral theorem. A Hermitian A∈Kn×nA\in\mathbb K^{n\times n} has an orthonormal eigenbasis v1,…,vnv_1,\ldots,v_n and real eigenvalues λ1,…,λn\lambda_1,\ldots,\lambda_n. With V=[v1 ⋯ vn]V=[v_1\ \cdots\ v_n] and Λ=diag⁡(λ1,…,λn)\Lambda=\operatorname{diag}(\lambda_1,\ldots,\lambda_n),

V∗V=I,A=VΛV∗=∑jλj(vj⊗vj).V^*V=I,\qquad A=V\Lambda V^* =\sum_j\lambda_j(v_j\otimes v_j).

The full existence theorem is stated here without proof. Once the basis exists, the representation follows from reconstruction: expand xx in the vjv_j, then apply AA to each component. Reality of each eigenvalue follows from self-adjointness, because ⟨v,Av⟩=⟨Av,v⟩\langle v,Av\rangle=\langle Av,v\rangle implies λ=λ‾\lambda=\overline\lambda for a unit eigenvector.

For example,

A=(2112)A=\begin{pmatrix}2&1\\1&2\end{pmatrix}

has v1=(1,1)/2v_1=(1,1)/\sqrt2 with eigenvalue 33, and v2=(1,−1)/2v_2=(1,-1)/\sqrt2 with eigenvalue 11. In these rotated coordinates the map simply multiplies one component by three and leaves the other alone. The familiar coordinate experiment now describes an operator, not only a vector.

7. Positive matrices: squared lengths in transformed coordinates

A scalar square is nonnegative. What is the corresponding idea for a matrix? Test the matrix in every direction.

Definition. A Hermitian matrix AA is self-adjoint positive semidefinite (SPSD) if

⟨Ax,x⟩≥0for all x.\langle Ax,x\rangle\ge0\quad\text{for all }x.

It is self-adjoint positive definite (SPD) if the inequality is strict for every nonzero xx.

There are two separate requirements here. Self-adjoint says A=A∗A=A^*; positive semidefinite says that the scalar test ⟨Ax,x⟩\langle Ax,x\rangle never becomes negative. It does not mean that every entry of AA is positive. And “semi” allows a nonzero vector to have zero value in this test.

To see the distinction, sweep a unit direction around the plane. For diagonal matrices, changing just the second diagonal entry lets us compare a positive direction, a flat direction and a negative direction without changing the axes or the test.

Positive means every direction—not every matrix entry

Positive definite

A = diag(2, 1)20-10π/2πθ

Every nonzero direction has positive squared size. On the unit circle the minimum is 1.

Positive semidefinite

A = diag(2, 0)20-10π/2πθ

The vertical direction has size zero, despite being nonzero. No direction has negative size.

Indefinite

A = diag(2, -1)20-10π/2πθ

The vertical direction gives −1. One negative value is enough to rule out positive semidefiniteness.

All three real diagonal matrices are self-adjoint. For unit x = (cos θ, sin θ), the plotted quantity is q(θ) = ⟨Ax, x⟩ = 2 cos²θ + λ₂ sin²θ. Angles 0 to π cover every unoriented line in the plane. The same vertical scale makes strict positivity, a zero direction, and a negative direction directly comparable. ↗

Why is it enough to test unit vectors? Multiplying xx by a nonzero scalar multiplies ⟨Ax,x⟩\langle Ax,x\rangle by its squared modulus, so it cannot change the sign. The plots suggest that the diagonal entries control the answer. The spectral theorem makes this reasoning available for every Hermitian matrix, by finding coordinates in which it is diagonal.

In an orthonormal eigenbasis,

⟨Ax,x⟩=∑jλj∣⟨vj,x⟩∣2.\langle Ax,x\rangle=\sum_j\lambda_j|\langle v_j,x\rangle|^2.

Consequently, a Hermitian matrix is SPSD exactly when every eigenvalue is nonnegative, and SPD exactly when every eigenvalue is positive. Necessity follows by choosing x=vjx=v_j; sufficiency follows from the sum above. A zero eigenvalue is a direction that contributes no squared size.

Gram matrices

For any rectangular matrix BB, both B∗BB^*B and BB∗BB^* are SPSD. They are self-adjoint, and the adjoint identity gives

⟨B∗Bx,x⟩=∣Bx∣2≥0,⟨BB∗y,y⟩=∣B∗y∣2≥0.\langle B^*Bx,x\rangle=|Bx|^2\ge0, \qquad \langle BB^*y,y\rangle=|B^*y|^2\ge0.

Moreover, B∗BB^*B is SPD exactly when BB has trivial kernel. This will explain the uniqueness condition in Week 2's least-squares equations. Later, covariance matrices will encode nonnegative variances in every direction using the same positivity structure.

Matrix square roots

For a nonnegative scalar, taking a square root halves the exponent. For an SPSD matrix, do this in its eigenbasis:

A1/2=Vdiag⁡(λ1,…,λn)V∗.A^{1/2}=V\operatorname{diag}(\sqrt{\lambda_1},\ldots,\sqrt{\lambda_n})V^*.

Theorem. Every SPSD matrix AA has a unique SPSD square root B=A1/2B=A^{1/2} satisfying B2=AB^2=A.

Existence follows immediately by multiplying the displayed spectral representation. For uniqueness, any SPSD BB with B2=AB^2=A commutes with AA and preserves each eigenspace of AA. On its λ\lambda-eigenspace, the nonnegative eigenvalues of BB must square to λ\lambda, so BB equals λI\sqrt\lambda I there.

The SPSD qualification is essential: other square roots need not be positive. For the preceding example, the principal square root is

A1/2=12(3+13−13−13+1).A^{1/2}=\frac12 \begin{pmatrix}\sqrt3+1&\sqrt3-1\\\sqrt3-1&\sqrt3+1\end{pmatrix}.

Cholesky factorisation

For computation, a triangular factor is often more convenient than a symmetric one.

Theorem (SPD Cholesky). If AA is SPD, there is a unique lower-triangular LL with positive real diagonal such that

A=LL∗.A=LL^*.

Equivalently, R=L∗R=L^* is upper triangular and A=R∗RA=R^*R. For our example,

L=(201/23/2),LL∗=(2112).L=\begin{pmatrix}\sqrt2&0\\1/\sqrt2&\sqrt{3/2}\end{pmatrix}, \qquad LL^*=\begin{pmatrix}2&1\\1&2\end{pmatrix}.

This is a factorisation, not the principal matrix square root: in general L2≠AL^2\ne A.

Follow the edges of a unit square to see the order of operations. In LL∗xLL^*x, the upper-triangular factor L∗L^* acts first, then the lower-triangular factor LL. Their combined action must match the columns of AA.

Read LL* from right to left

1. Start with a unit square

0111st2nd

The edges are e₁ and e₂. Tracking them determines the entire linear transformation.

2. Apply the upper factor L*

0111st2nd

The first edge becomes (√2, 0); the second becomes (1/√2, √(3/2)).

3. Apply the lower factor L

0111st2nd

Together the two factors produce A = LL*. Applying L twice would give a different result.

The solid first edge and dashed second edge track the two basis vectors; all panels use the same coordinate scale. First apply L*, then L. The final edges are (2, 1) and (1, 2), the columns of A. The parallelogram is a transformed unit square, not a probability contour or a plot of the quadratic form. ↗

The pairing also explains positivity: ⟨LL∗x,x⟩=∣L∗x∣2\langle LL^*x,x\rangle=|L^*x|^2. Because the diagonal of LL is positive, L∗L^* is invertible, so this squared length is strictly positive for nonzero xx. The principal square root gives another such pairing, but with the same self-adjoint factor used twice.

For an SPSD matrix a triangular factor with nonnegative diagonal exists, but uniqueness can fail. For instance, every real matrix

L=(00ab),a2+b2=1,b≥0,L=\begin{pmatrix}0&0\\a&b\end{pmatrix}, \qquad a^2+b^2=1,\quad b\ge0,

satisfies LL∗=diag⁡(0,1)LL^*=\operatorname{diag}(0,1). The original notes asserted uniqueness for all SPSD matrices and paired a lower-triangular factor with the opposite product convention; the statement above corrects those qualifications.

Exercises and the next question

  1. Prove directly from its action that u⊗uu\otimes u is self-adjoint and idempotent for ∣u∣=1|u|=1. What changes if uu is not normalised?
  2. Show that B∗BB^*B is SPD exactly when BB is injective, and formulate the corresponding condition for BB∗BB^*.
  3. Verify the two factorisations of the example matrix by multiplication. Explain why its principal square root is unique but unrestricted square roots need not be.
  4. In the calibration example, perturb the second stress measurement by δ\delta. Show that the fitted stiffness changes by 2δ/52\delta/5. What if both strain measurements were much smaller?

We began with two inconsistent observations. Distance made the disagreement measurable; projection identified the best prediction; bases and outer products explained how to measure and reconstruct it; spectral factorisation described how different directions can be scaled.

A general forward map need not be square or Hermitian. It can map between different spaces, and recovering a weakly measured direction can amplify noise. Week 2 develops the SVD to separate those input and output directions.