A material is stretched twice. At strain it produces stress ; at strain it produces stress . These are illustrative values in rescaled units, not experimental data.
If stress is proportional to strain, the first measurement suggests a stiffness of , while the second suggests . 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
Here is stress (force per cross-sectional area), is strain (relative extension), and is Young's modulus. The law predicts stress from strain once is known. Learning from measurements runs the calculation in the opposite direction.
First hold the stiffness fixed at . What must happen to the predicted stress when we double the strain? Follow the same change in the material and on the graph.
1. Stretch the material
Strain ε = 1; the law predicts stress σ = 2. The stiffness stays fixed.
2. Read the prediction
Every selected point stays on σ = 2ε. A single E constrains all predictions together.
ε = 1 → σ = 2, with E = 2.
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 predicts the pair . Whatever value we choose, the second predicted stress must be twice the first. The observed pair 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:
Before differentiating, consider the tempting choice of averaging the two individually inferred stiffnesses.
Expanding makes the distinction precise:
Thus is the unique minimiser and the remaining squared misfit is . For a third strain , the fitted model predicts stress .
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 , with input and parameters . In an idealised exact model,
In practice we write because parameters, observations and even the model's functional form may be imperfect. For input–output pairs , one possible calibration criterion is the misfit
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 and write
For example, , and produce a quadratic curve. Adding two coefficient vectors adds their predicted curves, even though adding two inputs generally does not add their outputs.
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.
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,
At the observed inputs, collect feature values into . All predicted observations are then the vector . Our Hooke example is the special case with one column, .
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.
Original coordinates
Lifted feature space
φₜ(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.
A Fourier model makes the same point:
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 . Rotate the first ruler towards the vector. Before revealing the second component, predict what has happened to the part the first ruler misses.
First coordinate α₁ = 2.000. What component would complete the vector?
When the first direction aligns with , its projection recovers the whole vector. When it is perpendicular to , 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 be or . In , the Euclidean dot product and norm are
For complex vectors we use
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 . A collection is orthonormal when its vectors have unit norm and distinct vectors are orthogonal. For real vectors, with is the signed length measured along .
Reconstruction theorem and Parseval's identity
A basis gives a unique expansion . An orthonormal basis makes its coefficients directly measurable:
Proof. Take the inner product of the expansion with . Linearity in the second argument and give
The same orthogonality eliminates all cross terms in the squared norm:
This is Parseval's identity. In the experiment it says 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 rotation: the individual squares change, but their combined area does not.
Rulers rotated 0°
4.0 + 1.0 = 5.0 units of squared length.
Rulers rotated 45°
4.5 + 0.5 = 5.0 units of squared length.
4. Turn a measurement into an operator
The coordinate experiment performs two operations: measure , then place that amount along . 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 and , define by
Its matrix is . Its range lies in the line spanned by , 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 and ,
It reads the first input coordinate and outputs twice that value in the second direction.
Follow an input 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.
1. Measure along a
Project x onto the horizontal unit direction a. Read off the scalar 2.
2. Keep one number
The inner product is a scalar, not a vector. It remembers only the chosen measurement.
3. Place it along b
Multiply b by that reading. The output is 2b = (0, 4), regardless of the discarded coordinate.
If , the special case is the orthogonal projection onto :
The residual is perpendicular to that line, since . 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:
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 , while a parameter produces with . 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 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.
1. Fit the stress–strain graph
One E sets the slope. Each vertical segment is observed stress minus predicted stress.
2. Project the observation pair
Now the axes mean stress in experiment 1 and stress in experiment 2. The shortest residual is perpendicular to the prediction line.
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?
Prediction and residual
The same squared loss
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.
To explore this view, return to the coordinate experiment and select Calibration preset. It places the first ruler along and changes the observed vector to . The perpendicular residual suggests a reason the algebraic optimum is optimal.
Which point on the line is closest to ? Decompose , where lies on the line and is perpendicular to it. For any other point on the line, is perpendicular to , so
Equality occurs only at . The closest point is therefore the orthogonal projection. Normalising gives
Thus , exactly as before, and satisfies . The irreducible squared residual is . The algebraic minimum and the geometric projection are two descriptions of the same result.
Exact systems and least squares
For a square matrix , the system has the unique solution if 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 , the observation may not belong to the range of . Least squares asks instead for
The optimal predicted vector is the projection of onto the range. Different parameters can produce that same prediction if 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 . 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 maps an input into an output space. Measuring the output against gives . Can we obtain the same number by measuring the input instead?
The adjoint is defined by
For matrices, : . The ordinary transpose is . Over the real numbers the two agree.
Here is a concrete way to read the identity. Take the shear . We can move the input forwards through and then measure, or move the measuring vector backwards through and measure the original input. Compare the two dot products, rather than expecting the two pictures to have the same lengths or angles.
1. Measure in the output space
First transform x to Ax = (3, 2). Then ⟨Ax, y⟩ = 3·2 + 2·1 = 8.
2. Measure in the input space
Leave x unchanged. Move y to A*y = (2, 3), so ⟨x, A*y⟩ = 1·2 + 2·3 = 8.
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:
For real 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 . Such matrices admit a particularly complete directional description.
Spectral theorem. A Hermitian has an orthonormal eigenbasis and real eigenvalues . With and ,
The full existence theorem is stated here without proof. Once the basis exists, the representation follows from reconstruction: expand in the , then apply to each component. Reality of each eigenvalue follows from self-adjointness, because implies for a unit eigenvector.
For example,
has with eigenvalue , and with eigenvalue . 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 is self-adjoint positive semidefinite (SPSD) if
It is self-adjoint positive definite (SPD) if the inequality is strict for every nonzero .
There are two separate requirements here. Self-adjoint says ; positive semidefinite says that the scalar test never becomes negative. It does not mean that every entry of 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 definite
Every nonzero direction has positive squared size. On the unit circle the minimum is 1.
Positive semidefinite
The vertical direction has size zero, despite being nonzero. No direction has negative size.
Indefinite
The vertical direction gives −1. One negative value is enough to rule out positive semidefiniteness.
Why is it enough to test unit vectors? Multiplying by a nonzero scalar multiplies 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,
Consequently, a Hermitian matrix is SPSD exactly when every eigenvalue is nonnegative, and SPD exactly when every eigenvalue is positive. Necessity follows by choosing ; sufficiency follows from the sum above. A zero eigenvalue is a direction that contributes no squared size.
Gram matrices
For any rectangular matrix , both and are SPSD. They are self-adjoint, and the adjoint identity gives
Moreover, is SPD exactly when 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:
Theorem. Every SPSD matrix has a unique SPSD square root satisfying .
Existence follows immediately by multiplying the displayed spectral representation. For uniqueness, any SPSD with commutes with and preserves each eigenspace of . On its -eigenspace, the nonnegative eigenvalues of must square to , so equals there.
The SPSD qualification is essential: other square roots need not be positive. For the preceding example, the principal square root is
Cholesky factorisation
For computation, a triangular factor is often more convenient than a symmetric one.
Theorem (SPD Cholesky). If is SPD, there is a unique lower-triangular with positive real diagonal such that
Equivalently, is upper triangular and . For our example,
This is a factorisation, not the principal matrix square root: in general .
Follow the edges of a unit square to see the order of operations. In , the upper-triangular factor acts first, then the lower-triangular factor . Their combined action must match the columns of .
1. Start with a unit square
The edges are e₁ and e₂. Tracking them determines the entire linear transformation.
2. Apply the upper factor L*
The first edge becomes (√2, 0); the second becomes (1/√2, √(3/2)).
3. Apply the lower factor L
Together the two factors produce A = LL*. Applying L twice would give a different result.
The pairing also explains positivity: . Because the diagonal of is positive, is invertible, so this squared length is strictly positive for nonzero . 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
satisfies . 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
- Prove directly from its action that is self-adjoint and idempotent for . What changes if is not normalised?
- Show that is SPD exactly when is injective, and formulate the corresponding condition for .
- 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.
- In the calibration example, perturb the second stress measurement by . Show that the fitted stiffness changes by . 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.