Chapter 1 · Conditioning and backward error
Distinguish an inaccurate measurement from an inaccurate solve by tracing how each changes the answer to a small equilibrium problem.
From first principles
Derive the relative error in a linear solve
Suppose measured data \(b\) determine unknowns through \(Ax=b\), with \(A\) square and nonsingular. Keep the coefficients fixed and change only the measured data by \(\delta b\). Subtracting the two equations removes the unperturbed solution exactly,
Choose a vector norm and its induced matrix norm, defined as the largest stretch of a unit vector. Applying the induced norm first to the perturbation and then to the original data gives
For nonzero \(b\) and \(x\), combine these two inequalities to express both errors as fractions,
The product is the normwise condition number. It concerns the problem even when the solver is exact. For a computed solution one can instead insert its measured residual as the data perturbation. The norm bound allows the most sensitive possible orientation of that perturbation, so a particular residual can give a considerably smaller error.
Background · Condition number
For an invertible square matrix choose a compatible norm. Conditioning describes data sensitivity, while stability refers to the algorithm processing the data.
Open full-size diagram
Derivation and applications
Bound each recovered coordinate using instrument tolerances
Sensors often have different tolerances expressed in different physical units. A perturbation ball based on an overall norm discards this information. Assume \(A\) is known and invertible, and let the calibrated uncertainty of reading \(j\) be an independent interval \(|\delta b_j|\leq t_j\). Here independent means all sign combinations are admissible, without a probabilistic assumption. Writing the solution perturbation row by row gives
The triangle inequality provides an upper bound. It is also attainable for a specified coordinate: choose the perturbation signs to agree with the signs of that row. Thus the smallest symmetric enclosing interval for that coordinate is
One can evaluate the same quantity for a reported linear output \(z=c^Tx\) without forming the whole inverse. Solve one transposed system \(A^Tw=c\); then the output is \(w^Tb\) and its extreme uncertainty follows from the same sign argument,
The maximizing perturbations for different coordinates may conflict. A vector of separate coordinate bounds therefore describes an enclosing box; its corners need not be reachable simultaneously. Calibration information tying two errors to the same bias would change the admissible set and can substantially alter the bound.
Worked example
Bound a difference from two calibrated sensors
Take readings \(b_1=x_1+x_2\) and \(b_2=x_1-x_2\), with tolerances \(0.020\) and \(0.080\) in common units. Reconstructing \(x_2=(b_1-b_2)/2\) gives worst error \(0.050\), attained when the two readings move in opposite directions. For \(x_1+x_2=b_1\) the error bound is only \(0.020\). Adding the two individual coordinate bounds would yield \(0.100\) and miss their shared dependence on the data.
Second application
Choose the more effective recalibration
A second reconstruction reports \(z=0.1b_1+4b_2\), with tolerances \(0.50\) and \(0.050\). Its worst error is \(0.250\). Halving the tolerance of the first sensor reduces it to \(0.225\), while halving the second reduces it to \(0.150\). The second recalibration yields a fourfold larger reduction despite its smaller raw tolerance.
Start from this chapter. A small residual controls solution error only through the inverse operator. Compare iterative and direct solutions on identical nodes before changing mesh size.
OneSimulation laboratory · Separate algebraic error from mesh error
Determine which perturbations a machine can represent
A computed residual is assembled from rounded operations. To interpret a small residual we need a scale for each rounding. In a normalized binary system with \(p\) significant bits, including the leading one, positive numbers in \([2^e,2^{e+1})\) have the form \(2^e(1+k\,2^{1-p})\). Increasing the integer \(k\) by one advances by \(2^{e+1-p}\). Thus absolute spacing grows with the size of the number. At a power of two, the neighbours on the two sides even have different spacings.
Rounding to nearest incurs at most half a spacing. Dividing by the smallest magnitude \(2^e\) in that interval gives the relative bound \(u=2^{-p}\), called unit roundoff. For a normal result of suitable magnitude one can write \(\operatorname{fl}(z)=z(1+\delta)\), \(|\delta|\leq u\). In binary64, \(p=53\). The distance from one to its larger neighbour is \(2^{-52}\), twice the unit roundoff. Subnormal numbers maintain a constant absolute spacing towards zero. The uniform relative estimate above does not extend through zero or to overflows.
Suppose an instrument adds the increments \(2^{-53}\) twice to a unit baseline. The exact result is \(1+2^{-52}\). With round-to-nearest, ties-to-even, \(1+2^{-53}\) is halfway between one and its successor. The lower endpoint has even trailing significand, so it rounds to one. Adding the second increment separately hits the same tie again. Grouping the increments first produces the representable \(2^{-52}\). Adding this to one then advances one spacing. Identical mathematical data can therefore yield different rounded sums.
Now take \(1+2^{-52}\) and subtract one. The difference \(2^{-52}\) is represented exactly, even though it is tiny relative to the original numbers. Cancellation becomes damaging when nearby operands already contain error relative to their difference. Recording the precision, order of accumulation and scale of the data lets us distinguish this effect from sensitivity of the underlying linear system.
Practise on sheet 1 · Predict a dot product in a tiny floating-point system. Further reading · Heidelberg University · R. Herzog, Einführung in die Numerik · Chapter 2, §§5–6 · Zahldarstellung und Rechnerarithmetik · KIT · P. E. Bradley, Numerische Mathematik · §§1.1–1.5 · Gleitkomma-Arithmetik · RWTH Aachen · A. Reusken, Numerische Analysis I · §§2.2.1 and 2.3 · Zahlendarstellungen, Stabilität eines Algorithmus.
Two questions about a reported solution
Suppose you determine two unknown forces by balancing their components in two directions. If the directions are almost parallel, the second measurement repeats much of the first. A machine can solve both written equations very accurately while the inferred forces vary considerably from trial to trial. To understand this, separate the map from data to physical answer from the algorithm used to evaluate that map. Conditioning describes the map locally near the supplied data. Stability describes the calculation that produced an answer from those data.
Let \(A\) be a nonsingular real matrix, let \(Ax=b\) and suppose that only the right-hand side changes. Subtract \(Ax=b\) from \(A(x+\delta x)=b+\delta b\). The result \(A\delta x=\delta b\) says that \(A^{-1}\) maps the measurement disturbance into the answer. In a consistent norm,
To compare percentages rather than units, use \(\|b\|\leq\|A\|\|x\|\) and divide through by \(\|x\|\). For nonzero \(b\) this gives
The product is the condition number in the specified norm. Rotating the disturbance relative to the singular vectors changes the actual amplification, so a worst-case bound alone cannot tell which measurement caused trouble.
Background · How can changing units change a condition number?
Suppose two independent instruments measure a length and a force. In chosen reference units the measurement matrix is the identity. If the first instrument reports the same length in millimetres rather than metres, its numerical output is multiplied by a thousand. Measuring input and output perturbations with unweighted Euclidean norms then produces a condition number of 1000. The physical readings have exactly the same precision as before.
Represent the instrument uncertainties by standard deviations \(s_i\), and scale each output by its own \(s_i\). Under a change of units, both the first measurement and its uncertainty acquire the factor 1000. Their ratio stays fixed. A physically meaningful sensitivity analysis also scales the unknowns when their units differ. If \(D_y,D_x\) contain the respective reference scales, the operator to examine is
Report those scales next to a condition number. An apparently large change in conditioning can then be traced to sensor precision, physical coupling, or simply the coordinates used to report them.
Resolve the sensitive direction
Consider \(A=\left(\begin{smallmatrix}1&1\\1&1.001\end{smallmatrix}\right)\) and \(b=(2,2.001)^T\). The exact answer is \((1,1)^T\). Subtract the first measurement from the second. The difference, 0.001, is exactly 0.001 times the second unknown. If the second measurement increases by 0.0001, its inferred value increases to 1.1. The first unknown must fall to 0.9 to preserve the first measurement. Neither individual equilibrium equation looks unstable by itself. It is their near redundancy that makes the difference sensitive.
The infinity norm makes the scale explicit. The largest absolute row sum of \(A\) is 2.001. Its inverse is \(1000\left(\begin{smallmatrix}1.001&-1\\-1&1\end{smallmatrix}\right)\), whose largest row sum is 2001. The relative data change is \(0.0001/2.001\) while the relative solution change is 0.1. Multiplying the data change by the condition number gives about 0.200, a valid upper bound. Had the two measurements increased equally, their difference would have stayed fixed and the same amplification would not occur.
Ask which equations the machine solved
For a computed vector \(\hat x\), form \(r=b-A\hat x\). In exact arithmetic \(\hat x\) solves \(A\hat x=b-r\) exactly. Consequently \(\|r\|/\|b\|\) is a relative backward error when only \(b\) may change. In our example the vector \((0.9,1.1)^T\), tested against the original right-hand side, has a small residual in the second row. It is both an accurate answer to a nearby set of measurements and a poor estimate of the original forces.
If the rows carry different physical units, an unscaled residual can let one equation dominate the judgement. Scale each balance by a stated characteristic magnitude or report the residuals separately. Recompute them from the original data when possible. Feeding the same rounded intermediate quantities back into a consistency check may merely confirm the internal arithmetic. For a sensitive inverse map, improving the accuracy of the input or measuring an independent direction can accomplish more than tightening the solver tolerance.
Allow uncertainty in the coefficients
If directions as well as forces are measured, the perturbed equations are
Keeping first-order terms gives
Uncertainty in a coefficient therefore contributes an effective disturbance proportional to the magnitude of the state it multiplies. Reporting only uncertainty in the measured right-hand side can underestimate the final error.
For a scalar calibration \(a x=b\), logarithmic differentiation gives
If both measurements are 1% too large with the same sign, their errors cancel exactly in the ratio. Opposite 1% changes give \(1.01/0.99-1\simeq2.02\%\). Componentwise measurement correlations affect typical errors even though a norm bound has to allow the worst admissible combination. In force reconstruction this is a reason to keep calibration information with the measured balances.
Compute a condition number for a particular observable
Suppose a linear solve is used only to predict \(q=c^Tx\), rather than every component of the state. Let \(A\) be fixed and nonsingular. Perturb the load by \(\delta b\); the output changes by \(c^TA^{-1}\delta b\). Solve the dual system \(A^Tz=c\). Then the exact change is \(z^T\delta b\), and Cauchy–Schwarz gives
Equality is possible by choosing a load error parallel to \(z\). The absolute condition number of this observable with respect to this load norm is consequently \(\|z\|_2\). It can be much smaller than the worst amplification over all outputs.
The error model matters to the result. If each source instead has its own bounded relative uncertainty \(|\delta b_i|\le\epsilon |b_i|\), the worst change is \(\epsilon\sum_i|z_i b_i|\). The bound is attained by choosing the signs of the perturbations to make every term reinforce the same output change. For independent mean-zero source errors with covariances collected in \(\Sigma\), the variance is \(z^T\Sigma z\), generally smaller than a worst-case bound. A worst-case condition number and a statistical standard deviation answer different questions even when evaluated using exactly the same dual solution.
Which of two coupled readings can be predicted?
Take \(A=\left(\begin{smallmatrix}1&1\\1&1.02\end{smallmatrix}\right)\) and load \(b=(2,2.02)^T\). Subtracting the equations gives \(0.02x_2=0.02\), and back-substitution gives
For a prediction of the sum \(q_s=x_1+x_2\), the dual vector is \(z_s=(1,0)^T\): the first equation already reports that sum. For the difference \(q_d=x_1-x_2\), subtract twice the inferred \(x_2\) from the first equation. This gives \(q_d=101b_1-100b_2\), so \(z_d=(101,-100)^T\). These two physically simple outputs depend on the same pair of source readings in strikingly different ways.
With each reading uncertain by at most 0.001 in absolute units, the sum can change by at most 0.001. The difference can change by as much as 0.201 when the errors have opposite signs. With a single common offset of 0.001 in both readings, however, the difference changes by only 0.001 because the two large terms nearly cancel. The nominal difference is zero, so relative error in that output is undefined. An absolute tolerance or a physically chosen reference amplitude provides a meaningful accuracy requirement.
A designer considering improved load cells should therefore ask whether calibration drift is shared or independent and whether the useful output is a sum or a difference. Reporting just the matrix condition number gives no way to recover either piece of information. If the coefficients of \(A\) are uncertain as well, the effective right-hand side also contains the term \(-\delta A\,x\) to first order. Its direction can be entirely different from plausible measurement errors in \(b\).
A direct numerical perturbation illustrates the worst bounded case. Increasing \(b_1\) by 0.001 and decreasing \(b_2\) by 0.001 gives \(x_2=0.90\) and \(x_1=1.101\). The output difference has changed by 0.201 exactly, demonstrating that the sign choice in the componentwise bound is achievable.
Rotate a residual without changing its norm
Let \(A=\operatorname{diag}(1,s)\) and take a unit residual \(r=(\cos\theta,\sin\theta)\). Compute the correction solving \(A e=r\). Its size depends on alignment even though the residual norm remains exactly one.

Read values from the plot
| Angle from first left singular direction (degrees) | Small singular value 0.5 | Small singular value 0.1 | Small singular value 0.02 |
|---|---|---|---|
| 0 | 1 | 1 | 1 |
| 45 | 1.5811 | 7.1063 | 35.362 |
| 90 | 2 | 10 | 50 |
| 135 | 1.5811 | 7.1063 | 35.362 |
| 180 | 1 | 1 | 1 |
Change parameters · Rotate a residual without changing its norm
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Study the full derivation
When stable eigenvalues allow large transient growth · Matrix computations and spectral accuracy
Two damped states exchange energy in only one direction. Its eigenvalues predict ultimate decay, while a short-time response can grow by a large factor. Compute the matrix exponential, its gain and a resolvent-based sensitivity check.
Chapter 2 · Elimination, pivoting and factorisation
Build an LU factorisation by hand, reuse it for a second load and identify when an innocent-looking elimination step loses useful digits.
From first principles
Make one coefficient vanish without changing the solution
Consider a pair of linear balances \(ax+by=f\) and \(cx+dy=g\). Every solution of both also satisfies their linear combinations. Conversely, adding a multiple of one equation to another is reversible by subtracting the same multiple. For \(a\ne0\), choose the multiplier \(m=c/a\) so that subtracting \(m\) times the first equation from the second removes \(x\),
The same two operations can be stored as a matrix factorization. The lower triangle records the multiplier and the upper triangle records the remaining coefficients,
The second pivot \(d-mb\) must also be nonzero for a unique solution. Further right-hand sides can reuse both factors because neither depends on \(f\) or \(g\). When the first pivot is zero one can try exchanging rows. Exchanging rows to obtain a larger pivot can also reduce rounding errors in the multiplier.
Derivation and applications
Eliminate a variable from a symmetric quadratic energy
For a symmetric stiffness matrix the elimination pivot has a mechanical meaning. Consider the quadratic energy of two displacement coordinates \(u,v\), with stiffnesses \(a,d\), coupling \(c\), and applied loads \(f,g\). Stationarity with respect to each displacement gives the two linear balance equations. Assume the first stiffness \(a>0\),
At a prescribed \(v\) the energy is minimized at \(u=(f-cv)/a\). Complete the square in \(u\) before solving the remaining balance. The reduced energy retains both the coupling-induced stiffness change and the force transmitted from the eliminated coordinate,
The second elimination pivot is the curvature \(s=d-c^2/a\). For a stable equilibrium with a unique response one needs \(s>0\). The same result follows by expanding the symmetric factorization
Small \(s\) means one combined motion changes the energy very little. A large resulting displacement can therefore be a property of the model even if the elimination is performed accurately.
Worked example
Compute the effective load after eliminating a support
Let \(a=4\), \(c=-2\), \(d=3\) in \(\mathrm{N/m}\), with loads \(f=2\) and \(g=1\,\mathrm N\). The retained stiffness is
Its effective load is \(1-(-2)(2)/4=2\,\mathrm N\), so \(v=1\,\mathrm m\) and \(u=(2+2)/4=1\,\mathrm m\). Substitution gives original loads \(4-2=2\) and \(-2+3=1\).
Second application
Diagnose loss of stability without computing eigenvalues
With \(a=9\), \(d=4\), and \(c=6\) the second pivot vanishes. The trial motion \(u=-2v/3\) has zero quadratic energy for every \(v\). Changing only \(c\) to \(6.3\) gives
Minimizing over \(u\) at \(v=2\) and zero load now yields \(E=s v^2/2=-0.82\), demonstrating an unstable direction in the supposed stiffness model.
Start from this chapter. Use the direct factorisation as a fixed-mesh reference. Compare it with a converged iterative solve, then check why the peak temperature itself moves on a different mesh.
OneSimulation laboratory · Separate algebraic error from mesh error
How large can the last column grow?
A test matrix can be easy to describe and still produce surprisingly large intermediate values during elimination. Build an \(n\)-by-\(n\) matrix with ones on the diagonal and in its last column, minus ones strictly below the diagonal outside that column, and zeros everywhere else. Every input coefficient has magnitude at most one. Choose ordinary partial pivoting with the first candidate retained on ties. Every active diagonal pivot in the first \(n-1\) columns equals one and the entries below it equal minus one. There is no tiny pivot and the elimination multipliers all equal minus one.
Follow the last column instead. In the first elimination stage every lower row gains the pivot row. Its last entry changes from one to two. At the next stage every remaining row gains a pivot row whose last entry now equals two. The surviving last entries become four. An induction gives a final pivot of magnitude \(2^{n-1}\): the growth factor is exponential even though each multiplier is bounded. For six rows the last column of the upper triangular factor reads \(1,2,4,8,16,32\).
Open full-size diagramThe plotted condition number is the ratio of the largest and smallest singular values in Euclidean norm. It quantifies the possible relative amplification of perturbations in the original system. The growth factor instead anticipates how large the numbers in intermediate elimination stages can become compared with the input. Standard backward-error estimates contain the absolute sizes of those factors because roundoff is incurred in the intermediate arithmetic. A large growth factor weakens such a guarantee. It does not by itself establish a large solution error for every right-hand side.
In fact all the operations exposed above are small integer additions, sign changes and powers of two. They are exactly representable at the modest dimensions used by this notebook. A demonstration that simply solves this one exact test and prints a small residual would therefore miss the point of the construction. Reverse the row order and repeat the measurement. The singular values of the matrix remain the same, because a row permutation preserves Euclidean norm. Intermediate growth can change dramatically through a different sequence of tied pivot choices.
For a five-row matrix, a solver reports largest intermediate coefficient 16. Another researcher claims this proves that rounding must have lost four binary digits in every solution. Which part of the claim follows?
Work through the solution
The factor 16 is correct for the stated tie convention: each of four elimination stages doubles the surviving last entry. Four binary bits describe the ratio of scales. No automatic loss of four actual solution bits follows. Test a perturbed matrix and a specific right-hand side, and report forward error against a reliable reference together with a scaled residual. The exact integer example may incur no rounding in elimination at all.
Eliminate an unknown without changing the solution
Gaussian elimination replaces one equation by itself minus a multiple of another. In exact arithmetic this is reversible: add the same multiple back. In the first column choose a nonzero pivot \(a_{11}\) and form multipliers \(l_{i1}=a_{i1}/a_{11}\) for the rows below it. Subtract \(l_{i1}\) times row one from row \(i\). All lower entries in column one vanish, and the remaining unknowns satisfy a smaller system. Applying the same operations in the same order to the load vector is essential.
Repeating the argument produces an upper triangular matrix \(U\). The inverse row additions can be collected into a unit lower triangular matrix \(L\) containing the multipliers. If rows have been permuted, the relation is \(PA=LU\), where \(P\) records those exchanges. To solve for a new right-hand side, first solve \(Ly=Pb\) by forward substitution, then \(Ux=y\) by backward substitution. The factorisation depends on the matrix alone. This is valuable in static analysis when the material and supports stay fixed and only the applied loads change.
Factor once and load twice
Consider \(A=\left(\begin{smallmatrix}2&1&0\\1&3&1\\0&1&2\end{smallmatrix}\right)\). Subtract half the first row from the second to get \((0,2.5,1)\). Subtract 0.4 times the new second row from the third to get \((0,0,1.6)\). Thus \(U\) has diagonal \(2,2.5,1.6\) with ones immediately above, and \(L\) has multipliers 0.5 and 0.4 immediately below its unit diagonal. This matrix needs no pivot exchange. Multiplying the two factors recovers the original entries and gives a quick arithmetic check.
For the load \(b=(1,2,3)^T\), forward substitution yields
Back substitution starts with \(x_3=2.4/1.6=1.5\), then gives
A second load \(b=(0,1,0)^T\) gives
Both calculations are short once the triangular factors are available.
Eliminate a chain in two linear-time sweeps
In a chain of nearest-neighbour balances, row \(i\) contains only a left coefficient \(a_i\), diagonal \(d_i\), and right coefficient \(c_i\). Subtracting a multiple of the preceding, already reduced row removes the left coefficient and updates just one diagonal and one load. Write the reduced pivot and load as \(p_i,g_i\). The first pair is \(p_1=d_1,\ g_1=b_1\). Thereafter the multiplier, pivot and load satisfy
The last equation gives
Proceed backwards with \(x_i=(g_i-c_ix_{i+1})/p_i\). This is the Thomas algorithm. Each row costs a fixed number of operations and only three coefficient diagonals need storage. On repeated load cases the pivots and multipliers depend only on the original coefficient matrix and can be retained. Symmetric positive definiteness guarantees positive pivots here. An arbitrary nonsingular tridiagonal matrix can still have a zero leading pivot and require pivoting.
A four-node diffusion chain
With conductance one between successive nodes and fixed end values 1 and 2, the four internal balances have diagonal two, neighbours minus one and load \((1,0,0,2)^T\). The reduced pivots are \(2,3/2,4/3,5/4\). The corresponding loads are \(1,1/2,1/3,9/4\). The last unknown is
One step back gives \((1/3+9/5)/(4/3)=8/5\), then \(7/5\) and \(6/5\). Each of the five temperature differences is one fifth, as conservation without an interior source requires. A dense factorisation would return the same field but would obscure why a million-node chain is computationally tractable.
Practise on sheet 1 · Reuse chain factors after a load change. Further reading · University of Limerick · MS6021 Scientific Computation, W. T. Lee · Tridiagonal Matrices: Thomas Algorithm, sections I–II, Stage 1 and Stage 2.
Why exchange rows?
Consider \(10^{-5}x+y=1\) and \(x+y=2\). The exact solution is \(x=1/(1-10^{-5})\), \(y=2-x\). Eliminating with the first coefficient gives multiplier \(10^5\). The reduced equation contains the difference between numbers of size \(10^5\). In arithmetic rounded to three significant digits, both the new coefficient and right-hand side round to \(-1.00\times10^5\). Back substitution gives \(y=1\), then \(x=0\). Substitution in the second original equation exposes a residual of one.
Swap the rows first. The multiplier is now \(10^{-5}\), and the reduced equation rounds to \(y=1.00\). Back substitution in the first pivot equation gives \(x=1.00\), close to the exact answer. Partial pivoting chooses the largest absolute available coefficient in the pivot column, bounding the magnitudes of the multipliers by one. It usually limits numerical growth, though it cannot remove sensitivity already present in the original matrix.
For a dense matrix of size \(n\), the triangular factorisation takes order \(n^3\) arithmetic operations and substitutions take order \(n^2\) per load. Sparse discretisations can be much cheaper, but eliminating an unknown may create new nonzero entries between its neighbours. This fill depends on ordering. Ordering for small fill and pivoting for accuracy answer different questions, and production solvers may need both.
Use symmetry when the physics supplies it
For a symmetric positive definite stiffness matrix, Cholesky factorisation represents \(A=CC^T\) with a lower triangular \(C\) and positive real diagonal. The first diagonal entry is \(\sqrt{a_{11}}\). Entries below it are fixed by the first column of the product, and subtracting that column’s outer product leaves a smaller positive definite Schur complement. Positivity follows by minimising the full quadratic energy over the eliminated variable for every fixed nonzero remaining vector.
For \(A=\left(\begin{smallmatrix}4&2\\2&5\end{smallmatrix}\right)\), the first column of \(C\) is \((2,1)^T\). The remaining diagonal is
A zero or negative candidate under the square root signals that the positive definite assumption or numerical precision needs inspection. Unrestrained mechanical assemblies can have rigid modes of zero energy. Supplying appropriate physical constraints addresses that singularity directly instead of treating it as a pivot-ordering problem.
Trace element growth during pivoted elimination
Partial pivoting chooses the largest available entry in magnitude within the active column. Each multiplier then has magnitude at most one, an important control on an individual elimination step. It does not bound the size of all updated entries by their original size. The trailing update subtracts a multiplier times the pivot row from another row, and two terms of similar magnitude may add. Repeated reinforcement can build large intermediate entries even when each column choice satisfies the pivot rule.
Measure this effect by the growth factor, the largest magnitude encountered during elimination divided by the largest initial matrix entry. Roundoff in a factorisation is tied to the magnitude of the computed factors, so a large growth factor can weaken a backward-error guarantee. The factor describes a potential loss mechanism. A particular solve can still be exact when every operation happens to be exactly representable, and a large forward error can arise for quite different reasons if the underlying problem is ill-conditioned. These distinctions matter when interpreting numerical experiments designed to stress an algorithm.
Construct a matrix where the final column doubles
Use the four rows \((1,0,0,1)\), \((-1,1,0,1)\), \((-1,-1,1,1)\), and \((-1,-1,-1,1)\). Every initial entry has magnitude at most one. Choose the first available row on tied pivots. Eliminating the first column adds row one to all three lower rows, so their final entries become 2. Eliminating column two adds the second active row to the next two rows, changing their final entries to 4. Eliminating column three adds the third pivot row to the last, producing the final pivot 8. No multiplier exceeded one. The triangular factor has last column \((1,2,4,8)^T\) and the observed growth factor is eight.
The construction extends directly to size \(n\), with an all-ones last column, unit diagonal before that column, and minus ones below the diagonal. After \(j\) stages each remaining row has last entry \(2^j\), as follows inductively by adding two equal entries during the next elimination. The resulting growth factor is \(2^{n-1}\) for this tie rule. Thus even a rule that prevents division by a small pivot relative to its column admits exponential worst-case growth. Selecting a different row on a tie can change the numerical path without changing the physical system.
For a concrete back-substitution test select exact state \({\bf1}\). Multiplication gives load \((2,1,0,-2)^T\). Applying the same row operations transforms it to \((2,3,5,8)^T\). Back substitution gives \(x_4=1\), \(x_3=5-4=1\), \(x_2=3-2=1\) and \(x_1=2-1=1\). Binary arithmetic represents these small integers exactly. A residual check therefore need not reveal anything unusual in this case even while the monitored growth factor exposes an unfavourable factorisation path.
The comparison with no growth is especially clear for a diagonal matrix with entries \((1,1,1,8)\). Its last pivot is also eight, but its largest original entry was already eight and its growth factor is one. A large absolute pivot alone cannot identify element growth; the ratio must refer to the size of the input.
How large can intermediate elimination entries become?
Apply partial pivoting, keeping the first candidate in a tie. The test matrix has ones on the diagonal and final column, minus ones below the diagonal, and zero elsewhere. Record the largest absolute intermediate entry divided by the largest original entry.

Read values from the plot
| Matrix dimension | Wilkinson example | 1D Poisson tridiagonal |
|---|---|---|
| 2 | 2 | 1 |
| 5 | 16 | 1 |
| 8 | 128 | 1 |
| 12 | 2048 | 1 |
| 15 | 16384 | 1 |
Change parameters · How large can intermediate elimination entries become?
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Problem sheet 1 · Measurements and elimination
Use explicit perturbations, row exchanges and reusable factors to diagnose errors in small linear balances.
Two scales in a force measurement
A sensor system has \(A=\operatorname{diag}(2,0.02)\) and reports \(b=(2,0.02)^T\). Find the exact unknowns and \(\kappa_2(A)\). Compare two additive disturbances of magnitude 0.002, one entirely in the first measurement and one entirely in the second. Finally, explain which sensor needs the tighter absolute calibration.
Worked solution
Division by each diagonal entry gives
The singular values are 2 and 0.02, so \(\kappa_2=100\). The first disturbance changes the solution by \((0.001,0)^T\), whereas the second gives \((0,0.1)^T\). The second direction therefore produces a hundred times more absolute force error for the same measurement error.
For equal admissible absolute errors in the two forces, the second measurement needs a hundred times smaller absolute uncertainty. Rescaling its output by a factor of 100 makes the two matrix rows comparable but also rescales its uncertainty by 100. It cannot turn the original sensor into a more precise one.
Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Compare a componentwise and a global test
Take \(A=\operatorname{diag}(1000,1)\), \(b=(1000,1)^T\) and \(\hat x=(1,0.98)^T\). Compute the infinity-norm relative residual and the componentwise relative residual in each equation. If the instrumentation specification allows 0.5% relative error separately in each reading, does the approximation meet it?
Worked solution
The predicted measurements are \((1000,0.98)^T\), giving residual \((0,0.02)^T\). The global infinity-norm ratio is
In the separate equations the ratios are zero and \(0.02/1=0.02\).
The second equation misses its 0.5% specification by a factor of four. Global normalisation uses the much larger first equation to set the denominator. One remedy is to divide each equation by its nonzero measurement uncertainty and judge the largest resulting scaled residual.
Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Pivot and reuse
Factor \(A=\left(\begin{smallmatrix}0&2\\3&1\end{smallmatrix}\right)\) with a row permutation. Solve for \(b=(4,5)^T\) and for \(c=(2,1)^T\) using that factorisation. Why does the zero leading entry indicate neither singularity nor lack of a unique solution?
Worked solution
Exchange rows with \(P=\left(\begin{smallmatrix}0&1\\1&0\end{smallmatrix}\right)\). The permuted matrix is already upper triangular, so \(L=I\) and \(U=\left(\begin{smallmatrix}3&1\\0&2\end{smallmatrix}\right)\). For \(Pb=(5,4)^T\), back substitution gives \(x_2=2\), \(x_1=1\). For \(Pc=(1,2)^T\), it gives \(x_2=1\), \(x_1=0\).
The determinant is \(-6\), so the matrix is nonsingular. A zero at one candidate pivot location merely prevents that ordering of elimination. Applying the row permutation to both the matrix and every new load preserves the original problem.
Try this calculation. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Reuse chain factors after a load change
A three-node chain has diagonal \((4,3,2)\), both off-diagonals equal to \(-1\), and load \((2,4,0)^T\). Compute its pivots and solution. Without refactoring, determine the extra response to a unit load on the last node. Explain which step fails for a nonsingular chain with first row \((0,1)\) and second row \((1,2)\).
Worked solution
The pivots are
The reduced loads are
Back substitution gives
The incremental load transforms to \((0,0,1)\). Back substitution through the same factors gives increments \(11/18,\ 2/9,\ 1/18\) in reverse node order. They are positive throughout the connected chain. In the final matrix the first pivot is zero, although its determinant is −1. A row exchange can solve it. The unpivoted recurrence cannot divide by its first pivot.
Try this calculation. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Revisit chapter 2 · Eliminate a chain in two linear-time sweeps.
Predict a dot product in a tiny floating-point system
Use four significant binary bits, normalized numbers, round-to-nearest ties-to-even and a sufficiently wide exponent range. Form the dot product \((1,1,1)\cdot(8,0.5,0.5)\) by adding terms from left to right and then by adding the two smallest terms first. Compute the spacing just above 8. Would accumulating all terms exactly and rounding only the final answer change either result?
Worked solution
Above \(8=2^3\) the spacing is
Both 8 and 9 are representable. The intermediate 8.5 is halfway between them and rounds to the even significand of \(8=(1.000)_2\,2^3\). Left-to-right accumulation therefore returns 8 after both additions.
The sum of the two half-units is exactly one. Grouping them gives 8+1 = 9, equal to the exact dot product. A single final rounding also gives 9. The products with one are exact here. All of the discrepancy enters through the intermediate additions. A componentwise explanation can identify the two lost half-units even when the input vector is perfectly well conditioned for this sum.
Try this calculation. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Revisit chapter 1 · Determine which perturbations a machine can represent.
Notebook practice · How large can the last column grow?
Chapter 3 · Least squares and orthogonal factorisation
Fit a straight line to inconsistent observations, derive its residual conditions and explain why an orthogonal factorisation can preserve accuracy better than the normal equations.
From first principles
Derive the orthogonality condition for a fit
With more observations than unknown coefficients, the linear prediction \(Ax\) can miss the observed vector \(b\). Suppose squared residuals carry equal weight and choose coefficients to minimize \(\|b-Ax\|_2^2\). Try any change \(x\mapsto x+t d\), where the direction \(d\) is fixed but the scalar \(t\) can have either sign. Expand with \(r=b-Ax\),
At a minimum the linear term must vanish in every direction, so \(A^Tr=0\). This says the residual is perpendicular to every vector the model can generate. Rearranging gives the normal equations,
If \(A\) has independent columns then the quadratic term is positive for every nonzero direction and the minimizer is unique. A thin QR factorization with orthonormal columns \(Q\) and triangular \(R\) yields the equivalent equation \(Rx=Q^Tb\) and avoids explicitly forming products that can worsen numerical conditioning.
Background · Orthogonal projector
Columns of Q must be orthonormal in the stated real inner product. Least squares removes the component of the data orthogonal to the fitted range.
Derivation and applications
Impose one exact calibration condition on a noisy fit
Some data describe noisy readings while another relationship is an exact conservation or calibration requirement. Model noisy data by \(Ax\simeq b\) with independent equal-variance errors, but require \(c^Tx=d\) exactly. Assume \(A\) has full column rank and \(c\ne0\). Write \(H=A^TA\), and let \(x_0\) denote the ordinary least-squares solution. Expanding around \(x_0\) removes the cross term because the residual there is orthogonal to every column of \(A\),
Thus the constrained fit is the closest feasible point in the metric determined by \(H\). Introduce a multiplier \(\lambda\) for the exact condition in half the squared objective. Setting its derivatives to zero and solving the first equation gives
Applying the constraint determines the multiplier and the increase in squared residual,
The denominator is positive. In computation the expression \(H^{-1}c\) denotes a solve, preferably using existing QR factors. An already satisfied constraint leaves the fit unchanged. Directions weakly constrained by the measured data can accommodate an exact calibration with little increase in residual.
Worked example
Reconcile two fitted quantities with an exact total
An ordinary fit gives \(x_0=(2,5)^T\) with \(H=\operatorname{diag}(4,1)\). The correct total is \(x_1+x_2=6\). Now \(H^{-1}c=(0.25,1)^T\), the denominator is \(1.25\), and \(\lambda=0.8\). The adjusted pair is \((1.8,4.2)\). Its extra squared residual is \(4(0.2)^2+(0.8)^2=0.80\), with the less precisely measured second coordinate absorbing most of the correction.
Second application
Enforce a zero offset in a calibration line
Three equally weighted readings at \(t=0,1,2\) are \(1,3,5\). The free fit is \(1+2t\). A separate exact zero calibration demands an intercept of zero. Along that feasible line the slope obeys \((0^2+1^2+2^2)m=0+3+10\), giving \(m=2.6\). The three residuals \(1,0.4,-0.2\) have squared norm \(1.20\), a directly observable cost of the added calibration condition.
Replace exact consistency by an optimisation problem
Three thermometers at different positions need not lie on a common straight temperature profile. Let the rows of \(A\) contain the values of candidate basis functions at those positions and let \(b\) contain the observations. With more independent measurements than unknown coefficients, \(Ax=b\) may have no solution. A least-squares fit chooses \(x\) to minimise \(\|b-Ax\|_2^2\). Equal unweighted terms assume the deviations are comparable in units and importance. If one instrument is much noisier than another, that assumption deserves review before interpreting a fitted slope.
Take any coefficient perturbation \(sd\). Expanding the squared mismatch gives \(\|b-Ax\|^2-2s\,d^TA^T(b-Ax)+s^2\|Ad\|^2\). At a minimum the coefficient of \(s\) must vanish for every \(d\). Hence \(A^TAx=A^Tb\). This is also sufficient: when the linear term vanishes, every perturbation adds a nonnegative square. Geometrically the residual is perpendicular to the column space of \(A\). Full column rank makes the minimiser unique, since no nonzero coefficient perturbation then leaves the fitted values unchanged.
Background · When is a fitted residual independent of the fitted coefficients?
Assume the design matrix has full column rank and the observation errors have covariance \(\sigma^2 I\). Write the parameter error as \(A^+\epsilon\) and the residual as \((I-P)\epsilon\), with \(P=AA^+\). Their cross-covariance is
The last equality follows because \(I-P\) maps every vector into the orthogonal complement of the columns of \(A\), where \(A^+\) vanishes. For Gaussian errors the two quantities are jointly Gaussian, so zero cross-covariance also gives independence. With non-Gaussian noise their projections may still be statistically dependent. Orthogonality is always an algebraic property of the least-squares fit; independence needs an assumption about how errors were generated.
Fit three imperfect readings
Take positions \(t=-1,0,1\) and deviations from a baseline temperature of \(1,2,5\) K. Fit \(b(t)\simeq c+mt\), using a constant and a linear column. Their dot product is zero because the positions sum to zero. Their squared lengths are three and two. Multiplying the observation vector by each column gives 8 and 4, so the normal equations are diagonal and yield \(c=8/3\) K and \(m=2\) K per position unit.
The predicted values are \(2/3,8/3,14/3\) K. The residual \(b-Ax=(1/3,-2/3,1/3)^T\) has zero sum and zero dot product with \((-1,0,1)^T\), as required. Changing the intercept cannot lower the sum of squares because the positive and negative residuals already balance; changing the slope has the analogous weighted balance. The squared residual norm is \(2/3\) K². This measures fit to these readings. It does not tell whether a line will predict temperatures well outside the sampled interval.
Remove redundant precision loss
If \(A\) has full column rank and singular values \(\sigma_i\), then \(A^TA\) has eigenvalues \(\sigma_i^2\). Consequently
When two model columns are nearly parallel, forming the products explicitly can lose significant information about their small difference. For example, a straight-line fit on positions clustered around a very large offset has nearly proportional constant and position columns. Centering and scaling positions improves the parameterisation and gives an intercept with a local physical interpretation.
Alternatively, factor \(A=QR\) with \(Q\) having orthonormal columns and \(R\) upper triangular. Decompose the residual into its orthogonal parts inside and outside the column space:
The second term is independent of the fit. Solve \(Rx=Q^Tb\) by back substitution. Householder reflectors build this factorisation using length-preserving transformations. In the three-temperature example, dividing the constant column by \(\sqrt3\) and the position column by \(\sqrt2\) already produces \(Q\). The transformed data are \(8/\sqrt3\) and \(4/\sqrt2\). Dividing by the diagonal of \(R\) recovers exactly the same fit. When the columns are nearly dependent, inspect the rank explicitly, using column pivoting or singular values, before giving a physical interpretation to individual coefficients.
Include measurement weights explicitly
If an instrument gives independent errors with standard deviations \(s_i\), divide row \(i\) of both \(A\) and \(b\) by \(s_i\). The sum of squares now measures squared differences in units of each sensor’s own standard deviation. For two readings 0 and 10 with standard deviations 1 and 3, a constant fit minimises \(c^2+(10-c)^2/9\). Differentiation gives \(c=1\), versus the unweighted mean of 5. A reliable low reading exerts more influence on the weighted result.
This weighting still assumes independence and an appropriate error description. If both readings share an uncertain offset, repeated observations can reduce independent fluctuations without removing the offset. Near a rank deficiency, a small weighted residual likewise cannot establish separate physical identifiability of the fitted coefficients. Examine uncertainty or singular directions in the parameter map as well as the final mismatch.
Derive a prediction after withholding one observation
Let \(A\) have full column rank and use equal independent data variances. The fitted vector is \(\hat y=Hy\) with \(H=A(A^TA)^{-1}A^T\); implement the projection with a stable factorisation. Suppose row \(i\) is withheld and the reduced design stays full rank. Its new prediction at that location, \(\hat y_i^{(-i)}\), can be obtained without refitting the entire data set. Replace \(y_i\) in the full data by this predicted value. The model fitted to the reduced observations now also satisfies the full normal equations because the added row has precisely zero residual at that fit.
Apply the original hat matrix to the modified vector. Its \(i\)-th fitted value is \(\hat y_i+h_{ii}(\hat y_i^{(-i)}-y_i)\), which must equal \(\hat y_i^{(-i)}\). Rearranging gives
This relation shows how leverage can mask an error inside the training data. If \(h_{ii}=1\), the denominator vanishes because that observation alone identifies some parameter combination. Withholding it then requires a different rank convention or additional modelling information.
Predict the end of a calibration line from its other readings
Fit \(y=a+bt\) to \((t,y)=(0,0),(1,1),(2,4)\). The mean time is one and the mean response is \(5/3\). The slope from centred data is \([(-1)(-5/3)+(1)(7/3)]/[1+1]=2\), giving intercept \(-1/3\). The fitted values are \((-1/3,5/3,11/3)\) and residuals are \((1/3,-2/3,1/3)\). Taken individually, either endpoint looks better fitted than the midpoint. But each endpoint also has disproportionate influence on the slope used to fit itself.
For a straight line the intercept and centred-time columns are orthogonal, so \(h_{ii}=1/3+(t_i-1)^2/2\). The endpoint leverages are \(5/6\), the central leverage is \(1/3\), and their sum is two, the number of fitted parameters. The leave-one-out residuals are consequently \(2,-1,2\). Verify the last directly: the first two readings define the line \(y=t\); it predicts 2 at the final time, while the held-out observation is 4. For the central reading the two endpoints define \(y=2t\), predicting 2 instead of 1.
The scientific question determines whether this test is relevant. Dropping an endpoint forces extrapolation, whereas dropping the midpoint tests interpolation between two retained settings. Averaging these three squared errors mixes two distinct prediction tasks. If future measurements will be taken only inside the calibrated interval, a separate evaluation there is more informative. Serially correlated measurements also invalidate the interpretation of neighbouring held-out readings as independent validation, although the algebraic leave-one-out identity for a fixed design remains valid.
For these three observations the sum of squared training residuals is
The sum after leaving each observation out in turn is \(4+1+4=9\). The discrepancy arises even with an exactly implemented fitting routine. Each training prediction has already used the observation against which it is compared. The difference becomes acute near the boundary because that observation has supplied much of the information about its own fitted value.
Estimate a fitted line beyond its calibration interval
Six independent sensors of equal variance calibrate an intercept and slope. For each proposed location use the row \(c=(1,x)\). The standard error of the fitted mean is \(\sigma\|R^{-\mathsf T}c\|\) from the QR factorisation of the design.

Read values from the plot
| Prediction location | Calibration −1 to 1 | Calibration −0.25 to 0.25 |
|---|---|---|
| −2 | 1.263 | 4.7983 |
| −1 | 0.72375 | 2.4251 |
| 0 | 0.40825 | 0.40825 |
| 1 | 0.72375 | 2.4251 |
| 2 | 1.263 | 4.7983 |
Change parameters · Estimate a fitted line beyond its calibration interval
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Study the full derivation
Refitting a sensor as observations arrive or disappear · Matrix computations and spectral accuracy
A calibration line receives one new observation at a time. Update its least-squares factorisation using rotations, quantify the influence of a deleted observation and detect when removing a sample destroys identifiability.
Chapter 4 · Stationary iterations and smoothing
Derive two iterative solvers by splitting a matrix, and decide from their error modes whether repeated updates improve an approximation.
From first principles
Turn a balance into a repeatable correction
Suppose a large linear system \(Ax=b\) is difficult to solve, but a nearby matrix \(M\) is easy to invert. At a trial value \(x_k\), compute the imbalance \(r_k=b-Ax_k\). Estimate the correction by solving \(M d_k=r_k\), then add it to the trial value,
For the true solution \(x_*\) the residual vanishes. Subtract this fixed solution from the update and define \(e_k=x_k-x_*\). The algorithm propagates its remaining error through one fixed matrix,
A sufficient test for convergence is an induced norm of the iteration matrix below one. More generally, in finite dimension convergence for every starting error requires all eigenvalues to have magnitude below one. Taking \(M\) as the diagonal of \(A\) gives Jacobi iteration when all diagonal entries are nonzero. Its cheap solves are worthwhile only if the resulting errors decay at a useful rate.
Derivation and applications
Balance the slow and fast modes of a fixed relaxation step
Suppose the linear operator \(A\) is real symmetric positive definite and estimates \(\ell,u\) bound its eigenvalues, with \(0<\ell\le u\). Consider a scalar relaxation \(x_{k+1}=x_k+\omega(b-Ax_k)\). Because \(A\) has an orthonormal eigenbasis, each error component evolves independently. For an eigenvector belonging to \(\lambda\), its scalar error changes according to
The largest possible amplification over the spectral interval occurs at an endpoint. Indeed the absolute value of an affine function is convex. Thus choosing a single step for every component asks for the smallest possible value of
Below the optimum the low-frequency endpoint with smaller eigenvalue decays too slowly; above it the high-eigenvalue endpoint overshoots too far. Equalizing their absolute values with opposite signs gives the best fixed step and its worst-case bound,
For coincident endpoints a single step solves the problem. When the ratio \(u/\ell\) is very large, even the optimal scalar choice leaves \(q_*\) near unity. The result bounds the Euclidean norm directly because the eigenvectors are orthogonal. For a nonsymmetric matrix, eigenvalue endpoints alone do not establish this norm bound.
Worked example
Set the step and predict an iteration budget
A model has spectrum in \([2,8]\). Choose \(\omega=0.2\); then the endpoint error factors are \(+0.6\) and \(-0.6\). To guarantee reduction by a factor of 1000 requires \(k\ge\ln(0.001)/\ln(0.6)=13.52\), hence 14 steps. An error entirely in the mode \(\lambda=5\) vanishes after the first update, showing why actual runs can beat the guarantee.
Second application
Diagnose divergence from a missed fast mode
A second solver uses \(\omega=0.25\) on a system initially believed to have largest eigenvalue 6. A newly resolved mode has \(\lambda=9\), giving amplification \(1-0.25(9)=-1.25\). Its error reverses sign and grows by a factor \(1.25^4=2.44\) in four steps. With a verified interval \([1,9]\) the corrected fixed step is \(0.2\), yielding a contraction bound \(0.8\).
Split a difficult solve into easy solves
A direct factorisation may consume substantial memory on a fine mesh. One alternative repeatedly solves with a matrix \(M\) that is easy to invert. Write \(A=M-N\). Starting at \(x^{(0)}\), solve \(Mx^{(k+1)}=Nx^{(k)}+b\). This update can also be written as a correction \(x^{(k+1)}=x^{(k)}+M^{-1}(b-Ax^{(k)})\). The exact solution is a fixed point. A convenient choice of \(M\) is useful only if these cheap corrections move arbitrary starting guesses toward that point.
Subtract the update from the exact fixed-point equation. The error propagates as \(e^{(k+1)}=Ge^{(k)}\), where \(G=M^{-1}N=I-M^{-1}A\). If \(G\) is diagonalizable, expansion of the initial error in its eigenvectors gives a factor \(\lambda_i^k\) per mode after \(k\) steps. The spectral radius below one gives convergence from every initial vector. A mode with magnitude close to one decays slowly. For a nonnormal matrix the eigenvectors may be nearly parallel, so several early error norms can rise even when the ultimate decay is assured.
Update a two-node network
Let \(A=\left(\begin{smallmatrix}2&-1\\-1&2\end{smallmatrix}\right)\) and \(b=(1,1)^T\), with exact solution \((1,1)^T\). Jacobi uses \(M=\operatorname{diag}(A)\). The updates are
Starting at zero gives \((0.5,0.5)\), then \((0.75,0.75)\). Here the initial error lies in the symmetric eigenvector, with factor \(+0.5\). An initial antisymmetric error would change sign each step with factor \(-0.5\). Both shrink at the same magnitude despite different histories.
Gauss–Seidel includes the lower triangular part of \(A\) in \(M\). It uses the just-computed \(x_1^{new}\) in the second equation. From zero, the first sweep gives \((0.5,0.75)\) and the next gives \((0.875,0.9375)\). The error propagation matrix for this ordering is \(\left(\begin{smallmatrix}0&1/2\\0&1/4\end{smallmatrix}\right)\), whose eigenvalues are zero and one quarter. A sweep uses recent information, but introduces a sequential dependence that plain Jacobi avoids.
Why a good smoother can be a poor solver
On a uniform one-dimensional Dirichlet grid with \(N\) intervals, each Jacobi correction for the Poisson equation replaces the error by its neighbours’ average. Substitute the sine-shaped error \(e_i=\sin(j\pi i/N)\). The addition identity shows that its amplification is \(\cos(j\pi/N)\). Low-frequency modes vary gently between neighbours, so averaging barely changes them. As the grid is refined the slowest factor tends to one. An iteration count measured on a coarse problem therefore gives little indication of fine-grid cost.
Weighted Jacobi mixes one ordinary Jacobi sweep with the old iterate. The factor becomes \(1-\omega+\omega\cos(j\pi/N)\). Choosing \(\omega=2/3\) sends a very oscillatory mode with cosine near minus one to approximately minus one third. The unweighted scheme would retain almost all of its magnitude with alternating sign. For a smooth mode with cosine near one, both updates do little. A multigrid method exploits this distinction: several weighted sweeps remove much of the local oscillation, and a coarser representation corrects the remaining long-scale error. Always evaluate a smoother by its effect on selected frequencies and a standalone solver by the slowest remaining mode.

Estimate the cost before extrapolating a timing
For the slowest sine error on a grid of \(N\) intervals,
To reduce this component by a factor of ten, solve \(\cos(\pi/N)^k\leq0.1\) using logarithms. For large \(N\) this gives
Doubling the number of intervals therefore roughly quadruples the sweep count for ordinary Jacobi. The work in a one-dimensional sweep also doubles. A timing extrapolated solely from the cost of one sweep misses this additional factor of four.
This estimate starts with an error containing the first sine mode. If a benchmark uses a carefully chosen high-frequency error, a weighted Jacobi run may look much faster. The two measurements describe different aspects of the iteration. Repeating the comparison with both a smooth and a rapidly alternating initial error makes that dependence observable in a short experiment.
Convergence can begin with a large increase
Write an affine stationary iteration as \(x_{k+1}=Tx_k+c\). Subtracting its fixed-point equation shows that \(e_k=T^ke_0\) for the error in either consistently chosen sign convention. Every initial error decays in finite dimension exactly when the spectral radius of \(T\) is smaller than one. Diagonalising a normal \(T\) then gives
For a nonnormal matrix its eigenvectors need not be orthogonal and this norm identity fails. A shrinking asymptotic factor can coexist with substantial early error growth.
Consider \(T=rI+N\) with \(N^2=0\) and \(0<r<1\). Since \(I\) and \(N\) commute, the binomial expansion leaves \(T^k=r^kI+kr^{k-1}N\). The second term eventually vanishes because exponential decay dominates a polynomial factor. Initially it can be large if the off-diagonal coupling in \(N\) is large. This is a precise way to distinguish eventual convergence from contractivity in a specified physical norm. Monitoring only the eigenvalue magnitude hides the size of short-term excursions experienced by the components.
A coupled recurrence that delivers the wrong early verdict
Take \(r=1/2,\ N=\left(\begin{smallmatrix}0&8\\0&0\end{smallmatrix}\right)\), and start from error \(e_0=(0,1)^T\). The exact formula gives \(e_1=(8,1/2)^T\), \(e_2=(8,1/4)^T\), \(e_3=(6,1/8)^T\), and \(e_4=(4,1/16)^T\). An investigator who compares the first error norm with its initial value would conclude that the procedure is unstable. Yet both eigenvalues are one half and the formula assures eventual decay. At ten steps the first component is
This slow recovery after a rapid early amplification is a property of the coupling.
A second experiment starts from \(e_0=(1,0)^T\). The nilpotent part annihilates that direction and the first component decays as \(2^{-k}\) from the very beginning. Thus observing a successful trajectory from just one initial condition can also conceal the largest early amplification. In a simulation that uses this solve inside another algorithm, those intermediate excursions may violate physical admissibility even if the mathematical linear system would eventually be solved to high accuracy.
Scaling the first coordinate by a factor of sixteen reduces the numerical off-diagonal entry in the scaled iteration from eight to one half. The infinity norm of that scaled matrix is then one; a slightly stronger scaling makes it strictly contractive. This does not change any eigenvalue or physical trajectory. It changes how coordinate errors are measured. An engineer should specify whether the chosen scaled tolerance actually controls both components to their required physical accuracies before using contractivity in that norm as a practical stopping guarantee.
A related diagnostic is to distinguish the one-step map norm from its spectral radius numerically. Here applying \(T\) to the unit vector \(e_2\) gives length \(\sqrt{64+1/4}>8\), so its two-norm is at least eight. No calculation of eigenvalues can give a comparable lower bound on this one-step gain in a nonnormal problem. Computing a largest singular value would measure exactly that worst initial norm amplification.
Change parameters · Stationary iterations and smoothing
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Problem sheet 2 · Fitting and relaxation
Use orthogonality to judge a fit and spectral factors to predict what successive relaxation sweeps remove.
Reweight an unreliable reading
Fit a constant to the readings 1, 2 and 8. First minimise the unweighted sum of squared deviations. Next suppose the third reading has standard deviation twice that of the others, with independent zero-mean errors. Write the weighted objective, find its minimiser, and explain the change.
Worked solution
For equal weights, differentiating \(\sum(y_i-c)^2\) gives \(3c=11\), so \(c=11/3\). With independent errors, weighting by inverse variance gives relative weights \(1,1,1/4\). Differentiate \((1-c)^2+(2-c)^2+(8-c)^2/4\) to get \(2.25c=5\), or \(c=20/9\).
The high reading has less leverage because its prescribed uncertainty is larger. The weighted residual sum vanishes at the answer: \(\sum w_i(y_i-c)=0\). This argument depends on the uncertainty model, and a common calibration offset cannot be removed by treating measurements as independent.
Try this calculation. Change one observation’s uncertainty and recompute the weighted projection. More than one fitted coefficient requires the additional basis columns specified in this exercise.
Rotate into a better fitting basis
For sample positions \(s=999,1000,1001\), consider columns \(1\) and \(s\). Compute their dot product. Replace the second column by \(s-1000\), compute the new two-by-two Gram matrix, and express the original intercept and slope for a centred fit \(5+0.2(s-1000)\). Which intercept most directly represents the experiment?
Worked solution
The original column dot product is 3000. The centred positions sum to zero and have squared norm two. The new Gram matrix is diagonal with entries 3 and 2, so the fitted mean and trend separate in the normal equations.
Expanding gives intercept \(5-200=-195\) and slope 0.2. The centred intercept is 5 at a measured position. The original intercept extrapolates roughly a thousand position units from the data, so a small slope error can change it considerably.
Try this calculation. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Calculate a smoothing factor
On an eight-interval Dirichlet grid take Jacobi error modes \(j=1\) and \(j=7\). Find both amplification factors for ordinary Jacobi and for weighted Jacobi with weight \(2/3\). Predict the magnitude of the high-frequency component after three weighted sweeps if its initial amplitude is one.
Worked solution
Ordinary Jacobi gives
The weighted factors are
Three weighted sweeps leave magnitude \(0.28259^3\simeq0.0226\) of the high-frequency error. The smooth error retains \(0.94925^3\simeq0.855\) of its amplitude. A coarse-grid correction should therefore target the smooth component.
Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Chapter 5 · Krylov subspaces and preconditioning
Derive the first CG steps from a minimum-energy principle and determine what is gained by changing the metric in which a linear system is solved.
From first principles
Derive the first Krylov correction from an energy minimum
For symmetric positive definite \(A\), the unique solution of \(Ax=b\) minimizes a quadratic energy. For any trial state \(x\), moving along direction \(p\) by a scalar \(\alpha\) changes that energy according to
where \(r=b-Ax\) is the residual. Every nonzero direction has \(p^TAp>0\), so setting the derivative in \(\alpha\) to zero gives the unique line minimum. The residual at the updated state is then perpendicular to the search direction,
Starting with \(p=r\) searches the first Krylov space spanned by the initial residual. Expanding that space to include \(Ar,A^2r,\ldots\) permits a better energy minimum at each step. Conjugate gradients chooses directions mutually orthogonal under the \(A\)-weighted inner product so that later line searches preserve the minima already achieved in earlier directions.
Derivation and applications
Determine the decrease delivered by a preconditioned search direction
A preconditioner changes the scale and orientation of the direction used to correct a linear system. To see how that affects the objective, take symmetric positive definite \(A\) and preconditioner \(M\), with residual \(r=b-Ax\). Solve \(Mz=r\) to choose a direction. For nonzero \(r\), the product \(r^Tz=r^TM^{-1}r\) is positive, so a small positive step along \(z\) reduces the quadratic energy \(E=\tfrac12x^TAx-b^Tx\).
The minimum along this direction is at \(\alpha_*=(r^Tz)/(z^TAz)\). Substitution gives the exact energy decrease. If \(x_*\) solves the original system, the full energy difference to the solution is also a quadratic form,
Their ratio is a squared cosine. Let \(u=A^{-1/2}r\) and \(v=A^{1/2}z\); their ordinary dot product is \(r^Tz\). The first search removes the fraction
A direction proportional to the exact correction removes all the error. A positive scalar multiple of \(M\) changes the step length inversely to the direction length, preserving the updated point. These facts concern one search and also apply to the first step of preconditioned conjugate gradients.
Worked example
Compare two directions on the same system
Take \(A=\operatorname{diag}(1,9)\), \(r=(1,3)^T\) and initial state zero. The available energy decrease is
Without preconditioning \(z=r\), so the first step removes \(10^2/[2(1+81)]=0.610\). With \(M=\operatorname{diag}(1,3)\), \(z=(1,1)^T\); it removes \(4^2/[2(1+9)]=0.800\). Both updates solve the same physical balances.
Second application
Rescale an exact preconditioner
In a second problem \(A=\operatorname{diag}(2,5)\), \(r=(4,10)^T\) and the available solver uses \(M=2A\). Its direction is \((1,1)^T\). The minimizing step is \((4+10)/(2+5)=2\), giving correction \((2,2)^T=A^{-1}r\). Judging a preconditioner by whether the step length is close to unity would reject this exact one-step correction.
Start from this chapter. Relax the CG residual tolerance on a fixed grid. Observe the departure from the direct solution, then compare with the shift caused by spatial refinement at tight tolerance.
OneSimulation laboratory · Separate algebraic error from mesh error
A geometrical interpretation of positive definiteness
Assume \(A=A^T\) and \(v^TAv>0\) for all nonzero \(v\). The algebraic solution \(x_\star\) is the unique minimiser of \(J(x)=x^TAx/2-b^Tx\). Indeed, completing the square gives
For a structural stiffness matrix this has the interpretation of excess elastic potential energy. The negative gradient at an approximation is the residual \(r=b-Ax\). Even in a purely algebraic application this energy geometry explains which approximation CG selects.
In a chosen search direction \(p\), minimise \(J(x+\alpha p)\) by differentiation. The optimal step is
Two successive minimisations should not undo each other. If \(p_i^TAp_j=0\) for distinct directions, minimisation along \(p_j\) preserves minimisation along \(p_i\). Such directions are called conjugate. CG generates them from successive residuals and matrix-vector products. Starting with \(p_0=r_0\), the exact-arithmetic recurrences are \(\alpha_k=(r_k^Tr_k)/(p_k^TAp_k)\), \(r_{k+1}=r_k-\alpha_kAp_k\),
Work through a two-dimensional example
Take \(A=\operatorname{diag}(1,4)\), \(b=(1,1)^T\), and \(x_0=0\). Then \(p_0=(1,1)^T\), \(Ap_0=(1,4)^T\) and \(\alpha_0=2/5=0.4\). The first approximation is \((0.4,0.4)^T\); its residual is \((0.6,-0.6)^T\). That residual is perpendicular to the old search direction because the line minimum has already been reached. The update coefficient is \(\beta_0=0.72/2=0.36\), giving \(p_1=(0.96,-0.24)^T\).
Check the conjugacy directly:
Now \(p_1^TAp_1=1.152\), so
The second approximation is \((1,0.25)^T\), which solves the system. A repeated steepest descent restart would search along the new residual, lose conjugacy, and generally need more than two steps. In floating-point arithmetic, residual orthogonality gradually deteriorates. A fresh residual computed from the final vector is a valuable check.
Improve the geometry of the search
At iteration \(k\), candidates lie in \(x_0+\operatorname{span}\{r_0,Ar_0,\ldots,A^{k-1}r_0\}\). The error can be written \(p_k(A)e_0\) for a polynomial with \(p_k(0)=1\). If the operator has only a few distinct eigenvalues, a low-degree polynomial can vanish on them all. More generally, many eigenvalues in a tight cluster can be reduced together. This explains why the condition number gives only a worst-case convergence estimate.
A positive definite preconditioner \(M\) corresponds to solving with \(M^{-1/2}AM^{-1/2}\). For the diagonal example, \(M=\operatorname{diag}(A)\) makes the transformed operator the identity, so one step suffices. For a full matrix, the same choice corrects scales but may leave strong coupling untouched. Applying an approximate inverse also costs time and memory. Compare total solve time, setup cost and physical error over representative loads before choosing a preconditioner. The heated cube experiment reports how changing the tolerance alters the same temperature observable on a fixed mesh. Compare direct and iterative heat balances.
Read an energy-norm convergence estimate
For symmetric positive definite \(A\), a classical CG estimate is \(\|e_k\|_A/\|e_0\|_A\leq2[(\sqrt\kappa-1)/(\sqrt\kappa+1)]^k\). To see the square root appear, minimise the largest magnitude of an error polynomial over the entire eigenvalue interval \([\lambda_{\min},\lambda_{\max}]\), with its value fixed at one at zero. Shifting a Chebyshev polynomial onto that interval produces the stated decay. Treating every point of the interval as a possible eigenvalue makes this a deliberately pessimistic estimate when the actual eigenvalues form tight clusters.
For \(\kappa=100\), the factor is \(9/11\). The bound first guarantees a reduction below \(10^{-3}\) after 38 iterations. If effective preconditioning reduces the condition number to 4, the factor becomes \(1/3\) and seven iterations suffice for the same guarantee. The comparison gives a budget for the search iterations only. An expensive preconditioner can erase that saving when it is set up for a single small load case. For repeated loads, setup can be spread over many solves, changing the economics without changing the convergence analysis.
Relate the stopping norm to energy
For a symmetric positive definite system the energy error squared equals \(r^TA^{-1}r\), since \(r=Ae\). Consequently residuals with the same Euclidean length may have different physical significance. With \(A=\operatorname{diag}(1,100)\), residuals \((1,0)^T\) and \((0,1)^T\) both have length one, but their energy errors are 1 and 0.1. A tolerance derived from an energy specification should account for this spectral weighting.
Turn a known spectral interval into a polynomial guarantee
Let \(A\) be symmetric positive definite with spectrum in \([a,b]\), \(0<a<b\). After \(k\) conjugate-gradient steps from \(x_0\), every available state error has the form \(p(A)e_0\), where \(p\) has degree at most \(k\) and \(p(0)=1\). The constraint at zero follows because the correction is an element of the Krylov space generated by the initial residual \(Ae_0\). Expressing \(e_0\) in orthonormal eigenvectors shows that the squared energy error is \(\sum_i\lambda_i |p(\lambda_i)|^2 |e_{0,i}|^2\). Bounding the maximum of the polynomial over the entire spectral interval gives a guarantee independent of the initial error.
Map \([a,b]\) to \([-1,1]\) through \(s=(a+b-2\lambda)/(b-a)\). The degree-\(k\) Chebyshev polynomial \(T_k(s)\) has magnitude at most one there, while at \(\lambda=0\) its argument \(s_0=(a+b)/(b-a)\) exceeds one. Thus \(p(\lambda)=T_k(s)/T_k(s_0)\) is an admissible trial polynomial with worst amplitude \(1/T_k(s_0)\). Since CG minimises the energy norm over all trial corrections, it performs at least as well as this explicit choice. Positive definiteness is used twice: it defines the energy norm and keeps zero outside the proposed spectral interval.
Compare an interval bound with the actual finite spectrum
Suppose the only eigenvalues are 1, 2 and 4. For two steps take \(T_2(s)=2s^2-1\), \(s_0=5/3\). Then \(T_2(s_0)=41/9\), so the worst relative energy error is at most \(9/41\approx0.2195\) for the trial polynomial and hence for CG. At the spectral endpoints the polynomial equals \(9/41\). At \(\lambda=2\), however, \(s=1/3\) and the factor is \(-7/41\). Each mode has acquired a small amplitude even though the signs differ. The actual energy error depends on how much of the initial energy lay in each mode.
For three steps the spectral interval still has infinitely many possible points. But the actual three eigenvalues permit the polynomial \((1-\lambda)(1-\lambda/2)(1-\lambda/4)\), which equals one at zero and vanishes on the entire spectrum. CG can therefore reach the exact solution on this finite example in at most three steps in exact arithmetic. Repeated eigenvalues do not increase this bound. The interval guarantee loses this information by preparing for every point between the smallest and largest eigenvalues, including values absent from the matrix.
A strong preconditioner can produce a narrow spectral cluster plus a few outliers. A helpful interpretation is to spend a small number of polynomial roots suppressing the outliers and use the rest to approximate zero across the cluster. The number of distinct eigendirections and the distribution of initial energy then complement a simple condition-number estimate. Finite precision can spoil exact finite termination, particularly when supposedly eliminated components reappear through roundoff.
If \(A\) is instead indefinite, a polynomial residual argument may still be meaningful for a different Krylov solver, but the quantity \(e^TAe\) can vanish for nonzero error or become negative. The preceding minimisation proof then loses the positive measure of approximation on which it depends. Checking symmetry alone is insufficient to apply it.
Same condition number, different Krylov histories
Solve two positive diagonal systems from zero with identical right-hand sides. Both have extreme eigenvalues 1 and 100. Plot the error in \(\|e\|_A=\sqrt{e^\mathsf{T}Ae}\), using the known diagonal inverse as a reference.

Read values from the plot
| Conjugate-gradient iterations | Two distinct eigenvalues | Twenty logarithmically spaced |
|---|---|---|
| 0 | 1 | 1 |
| 4 | 1e−15 | 0.54871 |
| 8 | 1e−15 | 0.22333 |
| 12 | 1e−15 | 0.057405 |
| 16 | 1e−15 | 0.0058119 |
Change parameters · Same condition number, different Krylov histories
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Chapter 6 · Eigenvalues, modes and spectral gaps
Estimate a dominant vibration or diffusion mode, explain the role of eigenvalue separation and use a residual to check a computed eigenpair.
From first principles
Watch a power iteration select a mode
Start with a real symmetric matrix \(A\) and express a trial vector \(v_0\) in its orthonormal eigenvectors \(u_j\). Order the eigenvalues so \(|\lambda_1|>|\lambda_2|\ge\cdots\) and suppose the starting component \(c_1\) is nonzero. Applying \(A\) repeatedly multiplies each component by its own eigenvalue,
Normalizing after each application keeps vector lengths manageable without changing the relative size of the components. The largest competing component therefore shrinks relative to the first at a geometric rate. A scalar estimate of the eigenvalue comes from projecting the action back onto the trial vector,
For an exact eigenvector the quotient equals its eigenvalue. Equal leading magnitudes can prevent selection of a single direction. A negative leading eigenvalue can make the displayed vector alternate sign even while its one-dimensional direction converges.
Derivation and applications
Derive the eigenvalue shift produced by weak coupling
Two individually measured modes can move apart in frequency or stiffness when they are coupled. Model a real symmetric operator in an orthonormal basis by diagonal values \(\alpha,\beta\) and off-diagonal coupling \(g\). All three numbers must have the same units. A nonzero eigenvector exists only when the determinant of the shifted matrix vanishes,
Set \(m=(\alpha+\beta)/2\) and \(d=(\alpha-\beta)/2\). The quadratic becomes \((\lambda-m)^2=d^2+g^2\), so the two eigenvalues and their separation are
Even when the uncoupled values coincide, a nonzero coupling leaves a gap \(2|g|\). For well-separated diagonal entries, assume \(\alpha>\beta\) and expand the square root for \(|g|\ll\alpha-\beta\). The largest eigenvalue has the shift
The rationalized form gives an accurate small shift without subtracting almost equal eigenvalues. The eigenvalue sum remains exactly \(\alpha+\beta\) because the trace is unchanged. A mass-normalized vibration model typically returns squared angular frequencies, so any measured ordinary frequencies must first be converted to the variables of the operator.
Worked example
Predict a shift away from a crossing
With \(\alpha=10\), \(\beta=6\) and \(g=0.5\), the upper shift is \(0.25/(\sqrt{4.25}+2)=0.0616\); the leading approximation is \(0.0625\). The lower eigenvalue is \(5.9384\) and the upper is \(10.0616\). The opposite signs of the shifts preserve the trace of 16.
Second application
Recover coupling and detuning from a measured gap
A second two-mode system has eigenvalues 19 and 25, giving a mean of 22 and half-gap of 3. An independent uncoupled calibration gives \(|\alpha-\beta|=4\), so \(d^2=4\). The inferred coupling magnitude is
The eigenvalues do not determine the sign of \(g\), which also changes when one basis vector is reversed.
OneSimulation laboratory
Predict grid error from the wavelength
Can a solver satisfy every discrete balance to roundoff and still overpredict the field? Consider a unit square with zero values on all four sides and a uniform diffusion coefficient. Prescribe the continuous field \(u=\sin(ax)\sin(ay)\) with \(a=m\pi\) and integer \(m\). Differentiating it twice in each direction gives the source \(f=2a^2u\) for \(-\nabla^2u=f\). This constructs a known solution before any numerical calculation.
Predict the grid’s response. For an evenly spaced line with interval \(h=1/N\), add the two neighbouring values of a sampled sine using the angle addition rule. The negative second difference in one direction becomes a multiple of the original sample:
The square contributes the same factor twice. Its discrete eigenvalue is \(\lambda_h=8\sin^2(ah/2)/h^2\). Since the source was constructed with the continuous eigenvalue, the grid solution is \(u_h=(2a^2/\lambda_h)u\) at the nodes. Expanding the sine gives the amplitude ratio \(1+(ah)^2/12+O((ah)^4)\). At a fixed mode, halving the mesh spacing should reduce the leading amplitude error fourfold.

Read the comparison. For mode 2, refinement from 24 to 48 cells per side changes the largest nodal error from 0.005731 to 0.001429. The ratio is 4.01. Compare modes at a common mesh size to see why a smooth but shorter-wavelength field can be harder to resolve. The prediction evaluates the maximum on the actual nodes because some grids miss the continuous peaks.
Try a different wavelength. Choose mode 4 on 16, 32 and 64 cells. Compare the output with mode 2 on 8, 16 and 32 cells. These pairs have the same number of cells per half-wave. Predict which error values carry over.
Further reading · Gilbert Strang, Difference matrices and eigenvalues, §5.5 (PDF).
Download the OneSimulation model (Python). Set up the local runtime, then run the downloaded file:
python poisson-mode.py --mode 4 --cells 16 32 64What an eigenproblem measures
In an undamped mechanical model \(M\ddot u+Ku=0\), insert \(u=v\cos(\omega t)\). Nonzero amplitudes require
The normal frequencies are square roots of generalised eigenvalues and the mode shapes are determined only up to scale and sign. For symmetric positive definite \(M\), substituting \(w=M^{1/2}v\) gives the ordinary symmetric operator \(M^{-1/2}KM^{-1/2}\). This step explains why mass weighting matters when comparing shapes from two different meshes.
For an ordinary symmetric matrix \(A\) with orthonormal eigenvectors, a normalised trial vector \(v=\sum c_i u_i\) has Rayleigh quotient \(\rho=v^TAv=\sum_i\lambda_i c_i^2\). Hence it lies between the smallest and largest eigenvalues. Near an isolated mode its value can be much more accurate than the vector direction: shifting a small amount of amplitude into another orthogonal mode changes the quotient by a term proportional to the square of that amplitude.
Select a mode by repeated application
The power iteration repeatedly forms \(Av_k\) and normalises it. Before normalisation,
If one eigenvalue has strictly largest magnitude and the initial vector overlaps its eigenspace, the ratio of any competing component to the leading one gains a factor \((\lambda_i/\lambda_1)^k\). Normalisation avoids overflow while preserving those ratios. A negative leading eigenvalue can cause sign changes between successive normalised vectors. Comparing their raw difference then misrepresents convergence.
For \(A=\operatorname{diag}(4,2)\) and a starting vector proportional to \((1,1)^T\), the ratio of the second component to the first is \(1/2\) after one multiplication and \(1/4\) after two. A vector proportional to \((4,1)^T\) has Rayleigh quotient \((4\cdot16+2)/17=66/17=3.88235\). After four steps the ratio is \(1/16\), and the quotient is
Check that the quotient error decreases roughly fourfold per additional step, although the directional error decreases only twofold.
Use shifts to find another part of the spectrum
Power iteration selects magnitude. To find a mode near a target \(\sigma\), apply the inverse of \(A-\sigma I\) implicitly by solving a linear system each iteration. The eigenvectors are the same and the eigenvalues are \(1/(\lambda_i-\sigma)\). For eigenvalues 2 and 4 with \(\sigma=2.1\), the transformed magnitudes are 10 and about 0.526. The eigenvalue near 2 dominates for a suitable starter. A fixed shift permits factor reuse, but choosing it exactly equal to an eigenvalue makes the shifted solve singular.
Test a candidate pair by forming \(r=Av-\rho v\) with \(\|v\|_2=1\). In the orthonormal basis,
At least one eigenvalue must lie within \(\|r\|\) of \(\rho\). This is a numerical certificate for a symmetric problem. To certify a particular eigenvector, the gap to neighbouring eigenvalues also matters. At a repeated eigenvalue every normalised linear combination of its modes is valid. Comparing subspaces or projecting one span onto the other is then more meaningful than matching individual component signs.
Follow the whole spectrum by QR iteration
To find several eigenvalues of a small dense operator, factor \(A_k-\mu I=QR\) and form \(A_{k+1}=RQ+\mu I\). Orthogonality gives \(A_{k+1}=Q^TA_kQ\), an exact similarity. Hence every step preserves eigenvalues, trace and determinant while changing the coordinates used to represent the operator. This use of QR is different from solving a triangular least-squares system. Repeated unshifted steps amount to an orthogonalised power iteration on multiple directions. A shift near a separated eigenvalue can make the last coordinate nearly invariant and accelerate its separation.
For a symmetric matrix a preliminary sequence of orthogonal similarities reduces it to tridiagonal form. When the coupling between the last two coordinates is negligible relative to the desired accuracy, setting that coupling and its transpose to zero separates a scalar eigenproblem. This removal is called deflation. If the off-diagonal magnitude is \(e\), setting the pair to zero is a symmetric perturbation of spectral norm \(|e|\), giving a direct measure for that decision. For a general real nonsymmetric matrix, the converged result can also contain real two-by-two blocks representing complex eigenvalue pairs.
A shifted step with a check on the trailing mode
Take \(A=\left(\begin{smallmatrix}4&1\\1&2\end{smallmatrix}\right)\) and \(\mu=2\). Normalising the first shifted column gives \((2,1)^T/\sqrt5\). Complete the orthogonal basis with \((-1,2)^T/\sqrt5\). Multiplying \(Q^TAQ\) gives diagonal \((22/5,8/5)\) and off-diagonal \(-1/5\). The trace remains six and the determinant remains seven. The last-coordinate Rayleigh estimate, initially two, is now 1.6 compared with the exact lower eigenvalue \(3-\sqrt2\approx1.586\). The residual of this coordinate has fallen from one to 0.2. A subsequent shift can use the improved estimate. Preserving eigenvalues alone would never certify that a coordinate is ready for deflation.
Practise on sheet 3 · Compare two shifts on the same symmetric operator. Further reading · ETH Zürich · Lecture Notes on Solving Large Scale Eigenvalue Problems · §4.1 The basic QR algorithm and Algorithm 4.4, The Hessenberg QR algorithm with Rayleigh quotient shift.
Which boundary modes are physical?
An elastic assembly suspended in free space admits rigid translations, and in three dimensions also rigid rotations when its geometry allows them. In a correctly assembled model these motions cost zero strain energy, so the stiffness matrix has a nullspace and some generalised eigenvalues are zero. Attempting unshifted inverse iteration on that stiffness matrix cannot locate a lowest positive vibration by simply inverting the operator. One can instead constrain rigid motions consistently or project into the mass-orthogonal complement of their span.
For a two-mass system with unit masses and a unit spring connecting them,
Translation \((1,1)^T\) has zero squared frequency; opposite displacement \((1,-1)^T\) has squared frequency two. Grounding the first mass eliminates translation but changes the second mode to an oscillator with frequency one. Projection leaves the original free-system vibration at \(\sqrt2\). These are physically different comparisons; the treatment of a nullspace determines which frequency an eigenvalue calculation is actually reporting.
Convert an eigenpair residual into an angle bound
Given a real symmetric matrix \(A\), a unit-vector approximation \(v\) and a scalar \(\theta\), write its residual \(r=Av-\theta v\). Expand \(v=\sum_j c_jq_j\) in an orthonormal eigenbasis. The squared residual is \(\sum_j(\lambda_j-\theta)^2|c_j|^2\). This identity always implies that at least one eigenvalue lies within \(\|r\|\) of \(\theta\). It does not by itself show whether the reported vector represents one particular physical mode. Two almost coincident eigenvalues can produce a tiny residual for many different mixtures of their eigenvectors.
To bound leakage out of a target eigenspace, let \(\gamma\) be a lower bound on the distance from \(\theta\) to every eigenvalue outside that space. The squared residual is at least \(\gamma^2\sum_{\rm outside}|c_j|^2\). Consequently the sine of the angle between \(v\) and the target space is at most \(\|r\|/\gamma\). This result assumes a symmetric or Hermitian operator under the chosen inner product. For a mass-weighted mechanical problem, transform to mass-normal coordinates or perform the argument in the proper mass inner product. An ordinary Euclidean angle between unscaled coordinates may have little relevance to vibrational energy.
Resolve a cluster more reliably than either member
Take \(A=\operatorname{diag}(10,10.02,30)\), and \(v=(1,1,0)^T/\sqrt2\). Its Rayleigh quotient is 10.01. Multiplication gives \(r=(-0.01,0.01,0)^T/\sqrt2\), of length 0.01. Relative to the cluster near ten this residual is small, yet the angle from the first coordinate eigenvector is 45 degrees. Using only the other low eigenvalue as a separation gives \(\gamma=0.01\), so the bound on that individual angle has sine at most one and provides no useful orientation guarantee.
Now take the target as the entire first two-dimensional subspace. Its gap from the reported quotient to the outside eigenvalue is
The same residual implies leakage no greater than \(0.01/19.99\approx0.000500\). In fact the true leakage of this particular vector is exactly zero. If the measured eigenvalues are squared angular frequencies, the two low modes have nearly the same frequency but can mix strongly under a small asymmetric manufacturing perturbation. Their combined subspace may remain very stable and may therefore be the more sensible object to compare with measurements.
A laboratory comparison can project independent excitation patterns onto the computed cluster and compare the total energy in that cluster. Such a result is invariant under rotations of its basis, which a simple table of pairwise eigenvector differences is not. If the gap to the rest of the spectrum closes as well, the subspace estimate becomes weak. Measuring the residual alone cannot repair that missing separation information.
For example the sum of squared projections of the excitation \((1,0,0)^T\) onto the first two computed orthonormal modes is one for any orthonormal basis of the exact low cluster. Individual projections can range between zero and one as the basis rotates. A test based on cluster projection assesses the reproducible quantity without requiring a uniquely labelled first mode.
Watch the QR iteration resolve two close eigenvalues
Rotate each diagonal matrix with eigenvalues \(1,\rho\) by 0.6 radians, then factor \(A_k=Q_kR_k\) and form \(A_{k+1}=R_kQ_k\). Each step is an orthogonal similarity. Dividing the off-diagonal by the gap lets all three matrices start with the same normalized mixing.

Read values from the plot
| Unshifted QR iterations | Eigenvalue ratio 0.35 | Eigenvalue ratio 0.65 | Eigenvalue ratio 0.85 |
|---|---|---|---|
| 0 | 0.46602 | 0.46602 | 0.46602 |
| 5 | 0.0035932 | 0.078883 | 0.27794 |
| 10 | 1.8872e−5 | 0.0092096 | 0.13229 |
| 15 | 9.9121e−8 | 0.0010687 | 0.05955 |
| 20 | 5.206e−10 | 0.000124 | 0.026498 |
Change parameters · Watch the QR iteration resolve two close eigenvalues
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Study the full derivation
When stable eigenvalues allow large transient growth · Matrix computations and spectral accuracy
Two damped states exchange energy in only one direction. Its eigenvalues predict ultimate decay, while a short-time response can grow by a large factor. Compute the matrix exponential, its gain and a resolvent-based sensitivity check.
Problem sheet 3 · Search directions and modes
Use trial directions, preconditioners and shifted inverses to control which components of a discrete model survive an iteration.
One exact line minimisation
For \(A=\operatorname{diag}(2,8)\), \(b=(2,2)^T\) and \(x_0=0\), find the first CG step and residual. Verify residual orthogonality and determine the final exact solution without performing another matrix-vector product.
Worked solution
With \(p_0=(2,2)^T\), \(p_0^Tr_0=8\) and \(p_0^TAp_0=40\), so \(\alpha_0=0.2\). Then \(x_1=(0.4,0.4)^T\) and \(r_1=(1.2,-1.2)^T\). Its dot product with \(p_0\) is zero, as minimisation along that direction requires.
The exact solution follows by division: \(x_\star=(1,0.25)^T\). One remaining conjugate search direction suffices because two distinct eigenvalues occur. From this starting vector both eigendirections are present.
Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Select a preconditioner
Let \(A=\left(\begin{smallmatrix}100&5\\5&1\end{smallmatrix}\right)\). Show that it is positive definite. With the diagonal preconditioner \(M=\operatorname{diag}(100,1)\), form the symmetric transformed matrix and find its condition number. Is diagonal scaling an exact inverse in this case?
Worked solution
The leading minors are 100 and 75, both positive. Multiplying left and right by \(\operatorname{diag}(0.1,1)\) gives \(\left(\begin{smallmatrix}1&0.5\\0.5&1\end{smallmatrix}\right)\). Its symmetric and antisymmetric modes have eigenvalues 1.5 and 0.5, giving condition number 3.
The scaling removes the difference between diagonal stiffnesses while retaining the off-diagonal coupling. The transformed matrix is distinct from the identity; a general right-hand side can therefore require two CG steps in exact arithmetic.
Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Locate a vibration mode
A mass-normalised operator has eigenvalues 9, 16 and 25 s⁻². Which natural angular frequencies do they represent? With shift \(15\ \mathrm{s^{-2}}\), give the transformed eigenvalues for inverse iteration and identify the selected mode for a generic initial vector. Finally, specify the units and meaning of a unit-vector Rayleigh residual of 0.01 s⁻².
Worked solution
Taking square roots gives angular frequencies 3, 4 and 5 rad/s. The transformed eigenvalues are \(1/(9-15)=-1/6\), \(1/(16-15)=1\) and \(1/(25-15)=1/10\) in s². The middle mode has the largest magnitude and dominates if it has nonzero initial overlap.
For a symmetric operator at least one squared frequency lies within 0.01 s⁻² of the Rayleigh quotient. Near \(16\ \mathrm{s^{-2}}\), the corresponding frequency uncertainty is about \(0.01/(2\cdot4)=0.00125\) rad/s, from differentiating the square root. This last expression is a local linear estimate.
Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Compare two shifts on the same symmetric operator
For \(A=\left(\begin{smallmatrix}2&1\\1&2\end{smallmatrix}\right)\), compute one unshifted QR step using a positively oriented orthogonal basis. Then use shift one and choose any orthonormal completion if the shifted matrix loses rank. Explain why a singular shifted matrix causes no division by an eigenvalue in this method.
Worked solution
The first unshifted column gives
Their Rayleigh values are \(14/5\) and \(6/5\), and \(q_2^TAq_1=3/5\). The trailing coordinate still has residual 0.6.
With shift one the first shifted column is \((1,1)^T\). Its normalised direction and the perpendicular direction are already the two eigenvectors. The updated matrix is diagonal with entries 3 and 1, so deflation is exact. A zero last pivot in the QR factor is allowed because the algorithm multiplies factors and never solves with the singular matrix \(A-I\).
Explore the related calculation with adjustable inputs. Compare unshifted spectral convergence as the gap narrows; the explicit shifted QR identity in this exercise supplies the separate exact shift check.
Revisit chapter 6 · Follow the whole spectrum by QR iteration.
Bound the effect of stopping a linear solve early
On the common ten-cell mesh the direct and loose-tolerance CG peak temperatures are 0.05708900 and 0.05620782 K. The maximum pointwise difference over all nodes is reported as \(8.8\times10^{-4}\) K to two significant figures. Derive a bound for the difference between maxima even if the two peak nodes differ. Evaluate it here. Does it bound the continuum error?
Work through the solution
For any nodes \(i\),
Maximise both sides, then interchange \(u,v\), to obtain
The two listed peaks differ by 0.00088118 K, consistent with the rounded all-node bound. The argument compares solutions sampled on one mesh. It cannot bound the continuous peak error because neither discretisation nor off-node sampling is included.
Chapter 7 · Householder reflections and practical QR
Build one reflection explicitly, use it to triangularise a rectangular system and locate the residual in transformed coordinates.
From first principles
Construct a reflection that zeros a column tail
A reflection reverses the component of a vector perpendicular to a chosen plane and leaves the component in the plane fixed. If a nonzero vector \(v\) is normal to the plane, the perpendicular projection of \(x\) is \(v(v^Tx)/(v^Tv)\). Subtracting twice that projection defines
The reflection preserves lengths because the parallel and perpendicular components remain orthogonal. To reduce a column \(x\), target an axis vector \(y=\alpha e_1\) of equal length, so \(|\alpha|=\|x\|_2\). Set \(v=x-y\). Expanding the dot products gives \(2v^Tx=v^Tv\) because \(x\) and \(y\) have equal norm. Consequently
Choosing \(\alpha\) opposite in sign to \(x_1\) avoids cancellation in \(v_1\). Reflecting only the unprocessed rows of each successive column yields an upper triangular factor while preserving previously generated zeros. An already zero column needs no transformation.
Derivation and applications
Recover the least-squares residual from Householder coordinates
A QR solver can report how much an orthogonal transformation sends into rows below a triangular factor. That part has a precise measurement interpretation. Assume a real matrix \(A\) with \(m>n\) and independent columns. Apply the same sequence of Householder transformations to the augmented matrix \([A\ b]\). Their product \(Q^T\) is orthogonal. Partition its result into an upper block with \(n\) rows and a lower block,
Because orthogonal transformations preserve the Euclidean norm, the squared residual of any trial vector decomposes into the sum of two nonnegative terms. Only the first can be changed by the fit,
The optimal \(x\) solves \(Rx=c\), leaving residual norm \(\|d\|_2\). In exact arithmetic the original-coordinate residual is obtained by reversing the transforms on a vector whose upper block is zero,
The lower coordinates are combinations of observations. Their individual values depend on the particular reflections, whereas their squared norm is invariant. Retaining that norm directly avoids subtracting two large nearly equal squared norms when the fit is excellent. If some triangular pivots are numerically negligible, ranking the columns and checking the model’s effective rank become necessary before interpreting all \(n\) fitted coefficients.
Worked example
Inspect residuals after fitting a constant
Fit \(A=(1,1)^T\) to readings \(b=(8,10)^T\). Rotate to the orthonormal directions \((1,1)/\sqrt2\) and \((-1,1)/\sqrt2\). The transformed data are \(18/\sqrt2\) and \(2/\sqrt2\), while the transformed model is \((\sqrt2,0)^T x\). The fit gives \(x=9\), residual norm \(\sqrt2\), and original residual \((-1,1)^T\). Its sum is zero as the constant column requires.
Second application
Compare the numerical consequences of subtracting squared norms
Suppose transformed coordinates of another fit have \(\|c\|=10^8\) and \(\|d\|=0.1\). Computing \(\|b\|^2-\|c\|^2\) would subtract two values near \(10^{16}\) to recover \(0.01\). Binary64 spacing near \(10^{16}\) is 2, so the small addition can disappear entirely. Keeping the transformed tail returns residual norm \(0.1\) directly, subject to normal transformation errors.
Eliminate a column without stretching it
An orthogonal transformation applied simultaneously to the data matrix and right-hand side leaves every Euclidean residual length unchanged. A Householder reflector is \(H=I-2vv^T/(v^Tv)\) for a nonzero vector \(v\). Decompose any vector into components parallel and perpendicular to \(v\). The parallel component changes sign and the perpendicular component stays fixed, proving both length preservation and \(H^2=I\). Implementation requires just a dot product and a scaled vector subtraction rather than a dense matrix.
To make the entries below the first element of a column \(x\) vanish, choose \(v=x-\alpha e_1\) where \(|\alpha|=\|x\|_2\). A short calculation gives \(v^Tv=2(\|x\|^2-\alpha x_1)\) and \(v^Tx=\|x\|^2-\alpha x_1\), hence
Choose \(\alpha\) with sign opposite to \(x_1\) to avoid subtracting nearly equal positive numbers when computing \(v_1\). A zero column requires a separate decision about rank.
Follow the data into the triangular system
For \(x=(3,4)^T\), use \(\alpha=-5\) and \(v=(8,4)^T\). The reflection matrix is \(\left(\begin{smallmatrix}-.6&-.8\\-.8&.6\end{smallmatrix}\right)\). Take a one-column least-squares problem with measurements \(b=(4,3)^T\). Multiplication sends \(x\) to \((-5,0)^T\) and \(b\) to \((-4.8,-1.4)^T\). The optimum coefficient matches the first transformed measurement, giving \(c=0.96\). The second transformed measurement remains a residual of magnitude 1.4. Back in physical coordinates the predicted vector is \((2.88,3.84)\), with residual \((1.12,-0.84)\) and the same length.
For several columns, apply the first reflector to the entire remaining block. Construct the next reflector only on rows below the first pivot, protecting the already triangular part. Saving the reflector vectors permits application of \(Q\) or \(Q^T\) later without explicitly forming either full matrix. Additional right-hand sides can then use the same orthogonal transformations and triangular solve.
Detect when a coefficient is poorly determined
If a new column is nearly in the span of earlier columns, little of it survives below the preceding pivots. A small trailing diagonal of \(R\) signals potential coefficient sensitivity, but its scale depends on column units and order. An instrument model with one parameter measured in micro-units can naturally have a small column. Scale the columns according to the intended range of the corresponding parameters before interpreting a near-zero diagonal.
Column-pivoted QR selects a remaining column with a large unrepresented component at each stage. It can help reveal effective rank and identify an independent set of measurements or basis functions. A numerical rank decision still needs a tolerance tied to data uncertainty or floating-point arithmetic. Reporting a fitted coefficient to ten digits after discarding an almost invisible direction would conceal the limitation that the factorisation has revealed.
Check a nearly aligned column
Consider \(x=(1,10^{-8})^T\). Its norm differs from one by only about \(5\times10^{-17}\), below the spacing between one and the next larger double precision number. Computing the exact difference \(x_1-\|x\|\) as that subtraction may therefore give zero. Choosing the target with opposite sign makes the first entry of the reflector vector about two and the remaining small entry is retained. This calculation explains the sign convention geometrically: two opposite points on a sphere provide valid reflection targets, and only one directs the subtraction away from severe cancellation.
Update a triangular fit when observations arrive sequentially
A Householder QR factorisation is efficient when the entire design matrix is available. Suppose instead that a new row arrives after the original observations have been reduced to an upper triangular factor \(R\), a transformed data vector \(z\), and an accumulated residual sum of squares \(S\). The original least-squares objective equals \(\|Rx-z\|^2+S\). Appending measurement row \(a^T\) and value \(b\) adds \((a^Tx-b)^2\). Stacking \(a^T\) below \(R\) produces a matrix that is triangular except for one row. Orthogonal plane rotations can restore triangular form by eliminating each incoming entry in turn.
To remove a pair \((r,s)^T\), let \(\rho=\sqrt{r^2+s^2}\), \(c=r/\rho,\ d=s/\rho\). Multiplication by the rotation with rows \((c,d)\) and \((-d,c)\) gives \((\rho,0)^T\). Apply precisely the same two-row operation to all remaining columns and to the transformed data. Its final bottom data entry has no corresponding design column, so its square adds to \(S\). If \(r=s=0\) there is nothing to eliminate. A numerical implementation obtains the length with a scaled hypotenuse evaluation to avoid overflow from squaring a large observation.
Insert a point into an existing two-parameter fit
Suppose the existing transformed problem has \(R=I,\ z=(1,2)^T,\ S=0\). A new sensor reports \(x_1+x_2=5\). The best prior estimate was \((1,2)^T\), which predicts three and therefore disagrees with the incoming reading by two. To reconcile all observations, stack the new row \((1,1\mid5)\) below \((1,0\mid1)\) and \((0,1\mid2)\). Rotate the first and last rows with \(c=d=1/\sqrt2\). The first becomes \((\sqrt2,1/\sqrt2\mid6/\sqrt2)\); the last becomes \((0,1/\sqrt2\mid4/\sqrt2)\).
The second rotation combines leading entries \(1\) and \(1/\sqrt2\), yielding \(\rho=\sqrt{3/2}\), \(c=\sqrt{2/3}\), \(d=1/\sqrt3\). Its surviving right-hand side is
Thus the second-coordinate estimate is
Back substitution in the first row gives
The final bottom data entry is \(-2/\sqrt3+4/\sqrt3=2/\sqrt3\), contributing \(4/3\) to the residual sum of squares.
Verify directly: the three residual magnitudes are all \(2/3\), so their squared sum is \(4/3\). The new reading moved both coordinates equally because their original transformed information was identical and its row is symmetric. No historical measurement needed to be reread. Conversely deleting an earlier reading can expose rank deficiency and is a different numerical operation; simply running the same update with a negated data value would add another squared term rather than remove information.
When a stream contains different measurement variances, divide each arriving row and its right-hand side by its independently known standard deviation before applying the rotations. The accumulated \(S\) then measures squared standardised discrepancies. If the new reading shares an error with earlier readings, dividing its row alone is insufficient. One must first account for the conditional error and correlated design contribution or refactor a suitable joint whitening transformation. This is a measurement-model limitation, even when the rotations themselves remain perfectly orthogonal.
Repeated readings of a common reference are one practical source of precisely this kind of dependence.
Change parameters · Explore the worked calculation
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Study the full derivation
Refitting a sensor as observations arrive or disappear · Matrix computations and spectral accuracy
A calibration line receives one new observation at a time. Update its least-squares factorisation using rotations, quantify the influence of a deleted observation and detect when removing a sample destroys identifiability.
Chapter 8 · Singular values and minimum-norm solutions
Resolve a linear measurement into independent directions, compute its pseudoinverse and predict the effect of truncating a weakly observed component.
From first principles
Count what a rectangular measurement can recover
For a real matrix \(A\), the squared output length in a unit input direction \(v\) is \(v^TA^TAv\). Since \(A^TA\) is symmetric and nonnegative, it has orthonormal eigenvectors \(v_j\) with eigenvalues \(\sigma_j^2\ge0\). Each positive eigenvalue defines a unit output direction \(u_j=Av_j/\sigma_j\). Distinct orthogonal input eigenvectors then have orthogonal output directions because
Resolve an input into these vectors and the null space. A component along \(v_j\) is amplified by \(\sigma_j\), while every null component disappears. For measured data \(b\), matching the observed output components gives
Adding any null vector produces the same prediction but increases the squared norm by its own squared length. This proves the minimum-norm choice. Data perpendicular to all the \(u_j\) remain as a least-squares residual, and noise along a small positive singular value can be amplified substantially.
Background · Singular value
Input and output directions can live in different spaces. A small positive singular value can cause large inverse amplification.
Derivation and applications
Find the smallest reconstruction in physically scaled coordinates
The minimum-norm solution of an underdetermined fit depends on which units and physical scale define the norm. Consider exact independent constraints \(Ax=b\) with fewer rows than columns, and let \(W\) be a symmetric positive definite matrix of penalties. Minimize \(\tfrac12 x^TWx\) among all feasible states. A reference value could first be subtracted if zero represents an inappropriate baseline. Factor \(W=L^TL\) and express the optimization in the scaled variable \(y=Lx\),
Thus the usual minimum-norm singular-value solution applies to the scaled matrix. An alternative derivation introduces a multiplier \(\lambda\). Differentiating \(\tfrac12x^TWx-\lambda^T(Ax-b)\) gives
Substituting in the constraints yields
The reduced matrix is positive definite for independent constraint rows. For any feasible perturbation \(h\) with \(Ah=0\), the cross term in the objective vanishes:
This establishes uniqueness and explains the role of the weighting. Directions that data leave unresolved are assigned by a stated metric. Changing units while transforming both \(A\) and the metric consistently preserves the physical result.
Worked example
Distribute a measured total with unequal motion costs
A balance gives \(x_1+x_2=10\) and the squared cost is \(x_1^2+4x_2^2\). Stationarity requires \(x_1=4x_2\), yielding \((8,2)\) at cost \(80\). The unweighted minimum-norm pair \((5,5)\) satisfies the balance but has weighted cost \(125\). There is no change in agreement with the measurement.
Second application
Check invariance under a change of coordinate units
Write a second balance \(u+v=6\) and equal physical cost \(u^2+v^2\). If \(w=100v\), the new row is \((1,0.01)\) and the cost is \(u^2+0.0001w^2\). The weighted solution is \(u=3,w=300\), recovering \(v=3\). Applying an unweighted norm to the rescaled coordinates instead gives \(u=6/(1.0001)\simeq5.9994\), exposing a unit-dependent extra assumption.
Find directions that a rectangular map measures separately
For real \(A\), the matrix \(A^TA\) is symmetric positive semidefinite since \(v^TA^TAv=\|Av\|^2\). Choose orthonormal eigenvectors \(v_i\) with positive eigenvalues \(\sigma_i^2\) and define \(u_i=Av_i/\sigma_i\). Dotting two such vectors shows that the \(u_i\) are orthonormal. Completing both bases gives the singular value decomposition \(A=U\Sigma V^T\). Each \(\sigma_i\) is a gain from one parameter direction into a corresponding output direction. Zero singular values indicate directions that no observation in this model can distinguish.
To minimise \(\|Ax-b\|_2\), express both vectors in these orthogonal bases. For each positive singular value the residual component vanishes by taking \(v_i^Tx=u_i^Tb/\sigma_i\). Output components outside the range remain unavoidable, while input components in the nullspace can take any value without changing the fit. Setting those free components to zero gives the minimum-norm least-squares answer. This derivation identifies the pseudoinverse without assuming either a square matrix or a unique exact solution.
Distinguish an unobserved coordinate from an error
Suppose two instruments read \(b_1=x_1+x_2\) and \(b_2=0.02x_3\), giving readings 4 and 0.06. One singular value is \(\sqrt2\), corresponding to the mean direction of \(x_1,x_2\); another is 0.02 along \(x_3\). The difference \(x_1-x_2\) is unobserved. The minimum-norm exact fit is \((2,2,3)^T\), and every \((2+s,2-s,3)^T\) has identical data. More precision on the mean measurement cannot determine the hidden difference.
A noise change of +0.01 in the second reading raises the reconstructed third parameter by 0.5. If the admissible parameter scale is one, this is a substantial perturbation. Truncating the 0.02 singular direction instead sets \(x_3=0\). Then the residual grows from zero to the entire second reading, but its noise no longer controls the fitted third coordinate. The decision trades bias against uncertainty; it does not prove that the true third parameter is zero.
Assess a reduced measurement model
Keeping the largest \(k\) singular components produces \(A_k=\sum_{i\leq k}\sigma_i u_iv_i^T\). In the spectral norm its error is \(\sigma_{k+1}\): expansion in the right singular basis gives this upper bound, and applying the difference to \(v_{k+1}\) attains it. Any rank-\(k\) alternative must annihilate some unit vector in the span of the first \(k+1\) right singular vectors, on which the original map has norm at least \(\sigma_{k+1}\). Hence no lower-rank replacement improves the worst-case absolute output error.
That best-approximation result concerns forward predictions in a specified norm. Inverting small singular values magnifies noise, so a good low-rank approximation for forward use does not automatically determine the appropriate inverse for parameter recovery. Work with physically scaled parameters and noise-weighted observations before deciding which singular components are meaningful.
Choose an output before discarding a direction
Suppose an instrument observes \(x_1\) accurately and \(0.001x_2\) with uncertainty 0.01. The second variable alone has uncertainty of order ten. The output \(x_1\), however, has no projection onto the poorly observed direction. Its uncertainty receives no contribution from that amplification. Conversely the output \(x_1+x_2\) inherits the full uncertainty. This distinction can change whether a rank decision is acceptable. The spectrum describes the data acquisition matrix, while the projection of the chosen observable onto right singular vectors determines which losses of information affect the reported result.
Prove that truncation is optimal in two matrix norms
When compressing a dense linear map \(A\), decide which discrepancy is being minimised over all approximations of rank at most \(k\). Its spectral norm measures the largest output error over unit inputs. For any rank-\(k\) map \(B\), consider the span of the first \(k+1\) right singular vectors of \(A\). Its dimension exceeds the rank of the restriction of \(B\), so there exists a unit vector \(w\) in this span satisfying \(Bw=0\). Therefore \(\|(A-B)w\|=\|Aw\|\ge\sigma_{k+1}\). Retaining the first \(k\) singular pairs attains this lower bound, as its discarded part has largest singular value exactly \(\sigma_{k+1}\).
For the Frobenius norm, project each column of \(A\) into the column space of a candidate \(B\). Orthogonal projection is the closest approximation with columns in that space. If its projector is \(P\), the captured squared norm is \(\sum_j\sigma_j^2\|Pu_j\|^2\). The weights \(\|Pu_j\|^2\) lie between zero and one and sum to at most \(k\). The largest possible weighted sum assigns weight one to the \(k\) largest squared singular values. Hence the optimal discarded Frobenius norm is \((\sum_{j>k}\sigma_j^2)^{1/2}\). Both arguments require the norm and coordinate scaling just stated. Entrywise maximum error or application-specific weighted errors generally have different optimisers.
Decide how many responses a reduced map must reproduce
Suppose the four singular values of a unit-scaled instrument model are 8, 3, 2 and 1. A rank-two approximation has best possible worst-case gain error two and Frobenius error \(\sqrt{2^2+1^2}=\sqrt5\). Its relative squared Frobenius loss is \(5/(64+9+4+1)=5/78\), approximately 6.41 percent. Describing this as a loss of just 6.41 percent can be misleading if the experiment deliberately excites the third singular direction. For that unit input, the exact output has length two and the compressed output is zero, giving complete loss of the signal of interest.
Suppose instead inputs have equal independent unit variance in all four right singular coordinates. Then the expected squared error in the output is the sum of the discarded squared gains, exactly five. If the third coordinate is excited with variance one hundred while the others retain variance one, the error from truncating that coordinate alone becomes 400. Under that different usage distribution the meaningful objective is \(\|(A-B)C^{1/2}\|_F\), where \(C\) is the input covariance.
In these diagonal coordinates the weighted gains become \(8,3,20,1\). The best rank-two design for expected output error now retains directions three and one, and the discarded expected squared error becomes
The ranking changed because the physical question changed. It did not change the optimality theorem for the unweighted matrix; it changed which matrix correctly represents the intended error measure.
When an input covariance is singular, some directions are never excited under the stated design. The weighted objective can be indifferent to large errors in just those directions. A later change of operating regime may activate them, so a reduced model qualified for one input ensemble should retain the conditions under which its ranking was derived.
Decide whether a low-rank approximation is worthwhile
The best rank-\(k\) approximation discards the tail of the singular spectrum. Its relative Frobenius error is the square root of discarded squared singular values divided by total squared singular values, with the square root applied to the complete ratio.

Read values from the plot
| Retained singular directions | Geometric decay | Algebraic decay | Flat spectrum |
|---|---|---|---|
| 0 | 1 | 1 | 1 |
| 5 | 0.16807 | 0.28817 | 0.86603 |
| 10 | 0.028236 | 0.17049 | 0.70711 |
| 14 | 0.0067351 | 0.11241 | 0.54772 |
| 19 | 0.00081404 | 0.039576 | 0.22361 |
Change parameters · Decide whether a low-rank approximation is worthwhile
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Study the full derivation
How a random sketch finds a dominant subspace · Matrix computations and spectral accuracy
An instrument returns a matrix too large to factor densely but cheap enough to multiply by a few vectors. Build a low-rank approximation by probing its range, explain what a random draw can miss and design a residual check using fresh probes.
Problem sheet 4 · Orthogonal factorizations
Use geometric reflections and singular directions to separate independent information from redundant measurements.
Build a reflection
A column has leading entries \(x=(3,4)^T\). Using the target \((-5,0)^T\), construct the reflector, apply it to \(y=(0,5)^T\), and check preservation of the angle between the columns.
Worked solution
Take \(v=x+5e_1=(8,4)^T\). Then
It sends \(x\) to \((-5,0)^T\) and \(y\) to \((-4,3)^T\).
Both lengths stay five. The original dot product is 20 and the transformed dot product is also 20, so the cosine is \(20/25=0.8\). Retaining the reflector vector suffices to apply the same transformation to another load.
Try this calculation. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Detect a missing direction
A measurement matrix has rows \((1,1)\) and \((2,2)\). Compute its singular values. For observations \(b=(3,6)^T\), find every exact solution and the one of smallest Euclidean norm.
Worked solution
The Gram matrix has both rows equal to \((5,5)\), so its eigenvalues are 10 and 0. The singular values are \(\sqrt{10}\) and zero. The null direction is \((1,-1)\).
The independent measurement requires \(x_1+x_2=3\). Write \(x=(1.5+t,1.5-t)^T\); its squared length is \(4.5+2t^2\), minimised at \(t=0\). Doubling a measurement supplies no independent information about \(t\).
Try this calculation. Explore the continuum of parameter pairs with the same observed sum, and see how a chosen norm selects one pair.
Decide whether to truncate
Let \(A=\operatorname{diag}(4,0.02)\) and observe \(b=(4,0.03)^T\) with a possible second-component error of 0.02. Find the unregularised estimate, propagate the uncertainty, and compare with a truncated SVD retaining singular values above 0.1.
Worked solution
Direct inversion gives \((1,1.5)^T\); an observational error of 0.02 in the second component propagates to an uncertainty of one unit in \(x_2\). The interval of consistent values is \([0.5,2.5]\).
Truncating gives \((1,0)^T\) and residual norm 0.03. Truncation suppresses noise amplification but also discards the second-coordinate signal. The predicted second measurement is now outside the stated uncertainty range, which is evidence against this cutoff for these data.
Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Chapter 9 · Graph structure and fill-in
Predict which entries appear when an unknown is eliminated and use graph ordering to compare storage for two equivalent factorisations.
From first principles
Derive fill-in from one sparse elimination step
Represent a symmetric matrix as a graph with one vertex per unknown and edges at its nonzero off-diagonal entries. Reorder the first pivot to the top and write its diagonal entry as \(a\ne0\), with couplings \(c\) to the remaining vertices and a trailing block \(B\). Solving the pivot equation for its unknown gives
Insert this expression into the remaining equations. The matrix update at a pair of remaining vertices is
If both \(i\) and \(j\) touch the pivot, a new entry can appear even when \(B_{ij}=0\). This is fill-in. A symbolic elimination graph therefore joins all remaining neighbours before removing the pivot. Exact numerical cancellation can remove a predicted entry, so the graph describes the general pattern. Choosing vertices with fewer or better-connected neighbours can reduce fill and factorization work.
Derivation and applications
Reduce a conducting star and preserve boundary currents
In a resistor network, symbolic fill has an observable magnitude. Consider one interior node of potential \(u\) connected to boundary nodes with prescribed potentials \(v_i\) through positive conductances \(g_i\). Assume ideal linear resistors and no independent current injected at the interior node. Charge conservation there requires the sum of currents into it to vanish. With \(G=\sum_i g_i\), the interior voltage is the conductance-weighted average
The boundary current entering the star at terminal \(i\) is \(I_i=g_i(v_i-u)\). Substitute the reconstructed \(u\), then collect potential differences relative to the other terminals. The reduced graph contains a physical branch between every pair of formerly separate neighbours,
Summing the currents gives zero by pairwise cancellation. Multiplying the currents by the corresponding terminal voltages and summing gives the dissipated power, which must agree before and after elimination,
The two graphs can have very different numbers of branches while producing identical boundary measurements. An interior current source would additionally transfer a load vector to the terminals and cannot be dropped in a pure graph reduction.
Worked example
Reduce a three-terminal network
With conductances \(1,2,3\,\mathrm S\), the new pairwise conductances are \(1/3,1/2,1\,\mathrm S\) for pairs \(12,13,23\). For terminal voltages \(1,0,0\,\mathrm V\), the original centre sits at \(1/6\,\mathrm V\). Current from the first terminal is \(5/6\,\mathrm A\), equal to \((1/3+1/2)\times1\,\mathrm A\) in the reduced graph. Both dissipate \(5/6\,\mathrm W\).
Second application
Price the fill of a high-degree node
A centre joined to ten isolated boundary nodes by identical \(5\,\mathrm S\) branches produces \(10\times9/2=45\) reduced branches of \(25/50=0.5\,\mathrm S\). Driving one terminal to \(2\,\mathrm V\) with the other nine grounded gives current \(9(0.5)(2)=9\,\mathrm A\). The unreduced centre is at \(0.2\,\mathrm V\), giving \(5(2-0.2)=9\,\mathrm A\) by an independent balance.
Interpret matrix entries as connections
For a symmetric sparse stiffness matrix, put one graph vertex at each unknown and an edge between distinct vertices whose corresponding entry is nonzero. A spring, diffusion face or shared element typically couples nearby unknowns, so the assembled matrix has far fewer entries than a dense array. Gaussian elimination changes this graph. Partition a pivot \(a\), its column below the pivot \(v\) and the trailing block \(B\). Eliminating the pivot replaces \(B\) by the Schur complement \(B-vv^T/a\). For every pair of nonzero entries of \(v\), the outer product can create a coupling between their vertices.
Thus the remaining neighbours of the eliminated vertex can become a clique. These added entries are called fill. Some may cancel for particular coefficients, but symbolic analysis usually retains every position that can be nonzero. It predicts a storage pattern before numerical values are known and can often be reused when material properties or loads change on the same mesh.
Compare two orders on a star
Take four unknowns arranged as a centre joined to three leaves, with no direct leaf-to-leaf connections. Give each diagonal value 4 and each centre-to-leaf coupling −1. Eliminating the centre first subtracts \(1/4\) from every leaf diagonal and creates three off-diagonals of \(-1/4\) connecting the three pairs of leaves. Although those leaves were initially independent when the centre was specified, eliminating it lets a disturbance at one leaf affect every other.
Instead eliminate one leaf at a time. Each has only one remaining neighbour, so its elimination modifies only the central diagonal and creates no off-diagonal fill. Three eliminations lower the central diagonal from 4 to \(4-3/4=3.25\). The two factorizations give the same physical answer in exact arithmetic, but their intermediate matrices require different storage and work. Relabelling the equations and unknowns together preserves symmetry and changes which order the eliminator encounters.
Use separators on a mesh
A one-dimensional chain eliminated from an end retains its narrow bandwidth. Eliminating interior vertices in an inconvenient order can create distant couplings relative to the original numbering. In a two-dimensional mesh even a careful sweep can leave a long front of mutually coupled vertices. Nested dissection separates the graph into smaller disconnected regions by setting aside a separator, factors the interiors independently and processes that separator later.
There is a practical trade between the cost of constructing an ordering and the savings in repeated factorisations. For a fixed matrix shape with many load cases this overhead can be amortised. For unsymmetric or indefinite systems numerical pivoting may alter the predicted pattern to maintain accuracy. Record both the number of nonzeros in the original operator and the number stored in the factors. Quoting the former alone can severely underestimate memory requirements, particularly for a three-dimensional mesh whose separators contain many more nodes than a one-dimensional chain.
Count the work created by a mesh separator
Ordering influences more than the final number of nonzeros. In a two-dimensional \(m\)-by-\(m\) grid with nearest-neighbour couplings, remove a cross of order \(m\) unknowns and factor the resulting quadrants before the cross. Eliminating each interior communicates among the adjacent separator variables. In a generic factorisation their remaining block is dense: eliminating a separator of size proportional to \(m\) then costs order \(m^3\) arithmetic operations and stores order \(m^2\) factor entries. The cost of finding the ordering is separate from this symbolic estimate.
Repeat the argument recursively on the four quadrants of side approximately \(m/2\). At level \(j\) there are about \(4^j\) independent subdomains with separator side \(m/2^j\). Total dense-block storage for this level is proportional to \(4^j(m/2^j)^2=m^2\). There are order \(\log m\) levels, yielding storage \(O(m^2\log m)\). Arithmetic at that level is proportional to \(4^j(m/2^j)^3=m^3/2^j\); summing a geometric series gives \(O(m^3)\). In terms of the total unknown count \(N\simeq m^2\), these are \(O(N\log N)\) storage and \(O(N^{3/2})\) arithmetic.
Compare memory growth on a sequence of grids
To see why the two resource estimates differ, use an idealised separator count with top separator length 64 and seven levels through length one. Ignore constants and store the square of each separator length. The root contributes \(64^2=4096\) units; the four children of length 32 contribute \(4\cdot32^2=4096\) as well. Seven levels therefore contribute 28,672 units. For work counted as the cube of each length, the root contributes 262,144 units and its children 131,072. Summing all seven contributions gives
Refining each spatial direction by a factor of two produces top length 128 and eight levels. Storage becomes \(8\cdot128^2=131072\), about 4.57 times as much. Work becomes \(128^3(2-1/128)=4177920\), about 8.03 times as much. The unknown count grew by four. A budget estimate assuming linear growth in both memory and factorisation time would miss the dominant cost early in this idealised sequence. The constants are structural units, not predictions in bytes or seconds.
These estimates assume balanced geometric partitions, bounded local connectivity and a factorisation that does not introduce unexpected pivot exchanges. Strong global couplings can destroy small separators; in three dimensions the separator of an \(m^3\) grid is a surface of order \(m^2\) unknowns. Substituting surface size into the same argument immediately predicts much heavier top-level work. Before extrapolating timings, inspect actual separator sizes and factor nonzeros for the physical mesh family at hand.
The same symbolic factorisation can often serve many load cases on an unchanged mesh. After numerical factors have been computed, each new pair of triangular substitutions has work proportional to the stored factor entries rather than the cubic separator work. A memory increase can therefore affect every repeated solve even when the one-time factorisation cost is amortised over many sources.
Predict the cost of moving from a sheet to a solid
For a three-dimensional \(m\)-by-\(m\)-by-\(m\) grid, divide a cube into eight smaller cubes separated by coordinate planes. An idealised top separator has order \(m^2\) unknowns rather than order \(m\). At level \(j\) the separator storage is proportional to \(8^j(m/2^j)^4=m^4/2^j\), and separator arithmetic to \(8^j(m/2^j)^6=m^6/8^j\). Both level sums are geometrically dominated by the largest separators. In terms of \(N=m^3\) unknowns the resulting estimates are \(O(N^{4/3})\) storage and \(O(N^2)\) factorisation work. The logarithmic storage factor of the two-dimensional sheet has given way to a different power of system size.
Doubling resolution along each axis multiplies \(N\) by eight, asymptotic factor storage by roughly sixteen, and factor arithmetic by roughly sixty-four. Suppose the factors of a current three-dimensional problem occupy 3 GB and take 90 seconds to compute. Applying these scalings gives about 48 GB and 96 minutes after such refinement, subject to ordering and machine efficiency. By contrast, applying the existing factors to each extra load scales primarily with factor entries. If memory is limited, the predicted top separator may rule out the planned direct factorisation before the nominal total number of input matrix entries does. An iterative alternative should then be compared at the actual required tolerance and with the cost of its preconditioner included.
Change parameters · Explore the worked calculation
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Study the full derivation
Solve a singular network without inventing a ground current · Matrix computations and spectral accuracy
A floating resistor network has unique voltage drops but no absolute voltage reference. Derive its nullspace, test charge balance, and distinguish adding a computational gauge from changing the physical boundary conditions.
Chapter 10 · Arnoldi iteration and GMRES
Construct an orthonormal basis for a nonsymmetric operator and use a small least-squares problem to choose an approximation.
From first principles
Project a large operator onto successive Krylov directions
For \(Ax=b\), start with residual \(r_0=b-Ax_0\ne0\). Choose the first basis vector as \(v_1=r_0/\beta\), where \(\beta=\|r_0\|_2\). Repeated matrix products generate a search space, but their columns can become nearly parallel. At step \(j\), remove previously resolved components of \(Av_j\) before normalizing the remainder,
If \(h_{j+1,j}>0\), take \(v_{j+1}=w/h_{j+1,j}\). The resulting Arnoldi identity \(AV_k=V_{k+1}\bar H_k\) expresses each large product using a small upper-Hessenberg matrix. A correction \(V_ky\) gives the residual norm
Orthonormality justifies the equality. GMRES solves the smaller least-squares problem to minimize the actual residual over this search space. When the new norm is zero the subspace is already invariant, and no further independent direction is available through another ordinary Arnoldi step.
Background · Krylov subspace
The starting vector determines which parts of the spectrum are visible. Orthogonalisation avoids storing nearly dependent raw powers.
Derivation and applications
Calculate exactly when the first GMRES step stalls
For one Krylov step the only available correction is a multiple of the initial residual \(r=b-Ax\). The resulting change in the residual is parallel to \(Ar\). Assume a real nonsingular \(A\) and \(r\ne0\), which guarantees \(Ar\ne0\). To choose the coefficient \(\alpha\), expand the squared residual norm,
The derivative vanishes at the coefficient of the orthogonal projection of \(r\) onto \(Ar\). Hence the new residual is perpendicular to the direction in which it was allowed to change,
Let \(\theta\) denote the angle between \(r\) and \(Ar\). At the minimum the squared length removed is exactly the squared length of that projection. The remaining fraction of residual is
Thus equal or opposite directions allow an exact one-step solve, while perpendicular directions deliver no change. This is purely geometric and applies without symmetry. It also clarifies why restarting after one step can be costly: later basis vectors could expose a direction inaccessible on the first line.
Worked example
Compute the residual reduction for a shear
Use \(A=\left(\begin{smallmatrix}1&2\\0&1\end{smallmatrix}\right)\) and \(r=(0,1)^T\). Then \(Ar=(2,1)^T\), \(\alpha_*=1/5\), and \(r_{\rm new}=(-0.4,0.8)^T\). Its norm is
The dot product with \(Ar\) is \(-0.8+0.8=0\), an independent check that the selected coefficient minimizes the residual along this line.
Second application
Detect stagnation despite a nonsingular operator
Take \(A=\operatorname{diag}(2,-1)\) and \(r=(1,\sqrt2)^T\). The dot product \(r^TAr=2-2=0\) forces the first coefficient to zero. A second direction completes a two-dimensional space because \(Ar=(2,-\sqrt2)^T\) is independent of \(r\). In fact \(A^{-1}r=(0.5,-\sqrt2)^T=-0.5r+0.5Ar\). The two-direction correction solves the problem exactly although a one-step restart would repeat the same state.
A residual as a polynomial
Consider a square nonsingular matrix and an initial residual \(r_0=b-Ax_0\). A correction in the span of \(r_0,Ar_0,\ldots,A^{k-1}r_0\) is a polynomial in \(A\) applied to \(r_0\). After subtracting the action of \(A\), the new residual is \(p_k(A)r_0\) with \(p_k(0)=1\). This constraint matters because the zero polynomial would certify convergence before the calculation began. Generalised minimal residual iteration, or GMRES, minimises the Euclidean norm over all such residuals. The spaces are nested, so the exact-arithmetic residual norms cannot increase during a cycle.
Replacing large products by small coordinates
Start with \(v_1=r_0/\beta\), where \(\beta=\|r_0\|_2\). For each new direction form \(w=Av_j\), subtract its projections onto the existing orthonormal columns, and normalise what remains. Each projection coefficient occupies one row of column \(j\) of a small matrix. The final normalising length occupies its first subdiagonal. This Arnoldi construction gives
If the length vanishes, the current subspace is invariant and no further normalisation is possible.
The second equality uses orthonormality. Solve this small rectangular least-squares problem, for example by updating triangular factors using plane rotations. The resulting residual is orthogonal to the range of \(AV_k\). Repeated projection may be necessary when rounding spoils orthogonality. A freshly calculated physical residual can test the small model's estimate before reporting convergence.
One eigenvalue and two directions
Take \(A=\left(\begin{smallmatrix}1&4\\0&1\end{smallmatrix}\right)\), \(x_0=0\), \(b=e_2\). The first correction is \(\alpha e_2\), so the squared residual is \(16\alpha^2+(1-\alpha)^2\). Differentiation gives \(\alpha=1/17\) and length \(4/\sqrt{17}\), about 0.9701. Almost the entire initial residual survives despite every eigenvalue being one. The second direction comes from the component of \(Ae_2\) perpendicular to \(e_2\), namely \(4e_1\). With both directions available the exact solution \((-4,1)^T\) is accessible, and its residual vanishes.
For a diagonal matrix equal to the identity, a single step would suffice for every right-hand side. Here a nonzero off-diagonal entry couples two coordinates and the minimal polynomial is \((z-1)^2\). Counting distinct eigenvalues alone misses that coupling.
Paying for a long memory
Each new direction needs storage and projections against earlier directions. Restarting after a fixed number releases memory, but discards those directions. A new cycle still starts from the best current iterate. It lacks the previous cycle's simultaneous freedom to alter its old coefficients. Record matrix-vector products and the residual after each restart when comparing costs. On the example, two directions retained together already achieve the exact answer, providing a direct check on a proposed implementation.
Read a preconditioned residual
Left preconditioning with \(M^{-1}\) makes GMRES minimise \(\|M^{-1}(b-Ax)\|\) instead. If \(M=\operatorname{diag}(1,1000)\), a physical residual \((0,1)^T\) has preconditioned norm 0.001. A small number in the stopping display could therefore leave the second physical balance comparatively inaccurate. Right preconditioning solves \(AM^{-1}y=b\), then forms \(x=M^{-1}y\); for exact preconditioner actions its minimisation still uses the original residual. Compare work and physically meaningful residuals when assessing either choice, especially if the equations use different units.
How restarting can erase a necessary direction
GMRES minimises the full residual norm over its current correction space. A one-step restart retains only the first correction direction generated from the new residual. If that direction makes no angle with the gradient of the residual objective in the appropriate sense, progress can cease even for an invertible, perfectly conditioned matrix. To see the geometry, suppose the current residual is \(r\). The one-dimensional trial residual is \(r-\alpha Ar\). Minimising its squared norm for real arithmetic yields
Thus no reduction occurs when \(Ar\) is perpendicular to \(r\). Restarting immediately recreates precisely the same subproblem.
Unrestarted GMRES can still add \(Ar\) and further powers to its Krylov space. In exact arithmetic it can therefore escape one-step stagnation. This distinction matters for storage allocation: reducing the basis length can change the convergence mechanism itself. Merely multiplying the allowed number of restart cycles cannot recover directions if every cycle begins and ends with the same residual. Conversely increasing the restart length helps only if the additional space contains directions that produce a lower residual.
Compare restart lengths for a quarter-turn operator
Set \(A=\left(\begin{smallmatrix}0&-1\\1&0\end{smallmatrix}\right)\) and \(b=(1,0)^T\), beginning at zero. Its transpose times itself is the identity, so its two-norm condition number is one. Yet \(Ab=(0,1)^T\) is perpendicular to the initial residual \(b\). The residual after trial step \(\alpha b\) is \((1,-\alpha)^T\), whose squared length is \(1+\alpha^2\). The best step is exactly zero. GMRES restarted every step thus leaves the residual norm at one forever.
With a two-vector basis use corrections \(x=\alpha b+\beta Ab=(\alpha,\beta)^T\). The residual is \((1+\beta,-\alpha)^T\), which vanishes for \(\alpha=0,\beta=-1\). The exact solution is reached. In polynomial language no degree-one real polynomial satisfying \(p(0)=1\) can vanish at both eigenvalues \(+i,-i\). The degree-two choice \(p(z)=1+z^2\) does so because \(A^2=-I\). Both formulations explain the same measurement without attributing the failure to singularity or loss of precision.
For a nonsingular real skew-symmetric matrix the one-step numerator vanishes for every real \(r\), since a scalar \(r^TAr\) equals its own negative after transposition. This family therefore offers a repeatable stress test for short-restart implementations. A preconditioner or a shift that alters the search geometry can change the result, but any claimed gain should be checked using the residual of the original equations and a comparable count of matrix-vector products.
There is also a simple residual recomputation check at convergence: for the two-step state \((0,-1)^T\), multiplying by the original matrix gives \((1,0)^T\) exactly. If a code reports the same state after one iteration, it has either used a different search direction or mislabelled its iteration count. Exposing the current basis length alongside the total matrix-vector count makes a restart experiment easier to reproduce.
For complex arithmetic, use the real or complex least-squares minimisation appropriate to the actual correction space; the perpendicularity argument above assumes real data.
Change parameters · Explore the worked calculation
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Study the full derivation
When stable eigenvalues allow large transient growth · Matrix computations and spectral accuracy
Two damped states exchange energy in only one direction. Its eigenvalues predict ultimate decay, while a short-time response can grow by a large factor. Compute the matrix exponential, its gain and a resolvent-based sensitivity check.
Problem sheet 5 · Graphs and search spaces
Predict elimination fill and compute minimum-residual updates for two systems with identical eigenvalues.
Choose an elimination order
A four-vertex star has centre 1, joined only to leaves 2, 3 and 4. Its symmetric positive definite matrix has generic nonzero edge weights. Count newly introduced edges if the centre goes first. Give an ordering avoiding fill and explain why it works.
Worked solution
Eliminating 1 connects each pair of its surviving neighbours. The three unordered pairs are (2,3), (2,4) and (3,4), none previously present. They occupy three new positions in one triangular factor's remaining graph.
In order (2,3,4,1) each eliminated leaf has a single surviving neighbour. There is no pair to connect, so no fill occurs. Positive definiteness ensures diagonal pivots exist without changing this structural ordering.
Explore the related calculation with adjustable inputs. Inspect the effective couplings obtained by eliminating an interior variable. The same substitution generates the Schur operator in the stated constrained system.
Two minimum-residual steps
Take \(A=\left(\begin{smallmatrix}1&2\\0&1\end{smallmatrix}\right)\), \(b=e_2\) and \(x_0=0\). Compute the first GMRES iterate and its residual norm. Show that the second unrestarted step can give zero residual.
Worked solution
Along \(x=\alpha e_2\) the squared residual is \(4\alpha^2+(1-\alpha)^2\). Its derivative is \(10\alpha-2\), so \(x_1=e_2/5\) and \(r_1=(-2/5,4/5)^T\). Its norm is \(2/\sqrt5\).
The directions \(e_2,Ae_2=(2,1)^T\) span the plane. Their combination can realise \(x_\star=(-2,1)^T\); multiplication gives
Thus the second minimum is exactly zero.
Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Does the load matter?
Reuse the preceding matrix with \(b=e_1\). Determine the Krylov dimension and first residual. Generalise your result to loads \((c,0)^T\), and explain the discrepancy with the previous problem.
Worked solution
Now \(Ae_1=e_1\), so every power of \(A\) produces the same direction. Choosing \(x=e_1\) solves the system in one step. For \(c\ne0\), the dimension is one and \(x=ce_1\) already solves it. A zero load has zero initial residual.
The earlier load occupied the generalised eigenvector direction, so \(Ae_2\) added an independent component. Matrix size and eigenvalues agree in both tests, but the minimal polynomial relative to the starting residual changes.
Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Chapter 11 · Iterative refinement and backward error
Recover accuracy from an approximate factorisation and determine when a small residual genuinely certifies a linear solve.
From first principles
Derive a correction using the observed imbalance
For a computed solution \(\widehat x\) of \(Ax=b\), evaluate \(r=b-A\widehat x\). Assume \(A\) is nonsingular. Subtract the equation for \(\widehat x\) from the exact equation to identify the missing correction,
If the matrix factors are already available, a correction solve uses those factors at much lower cost than a fresh factorization. In floating point suppose the solve acts like an exact solve with a matrix \(M\) close to \(A\). Ignoring rounding in the residual and final addition for the moment, the update gives
where \(e_k=x_k-x_*\). A norm of the error propagation matrix below one gives a contraction. Accurate residual evaluation matters because its own rounding error becomes new correction data. A tiny change in the iterate can mean either that the equations are satisfied or that small corrections are being rounded away. The scaled residual distinguishes these cases.
Background · Residual
A small residual tests the computed equation. Converting it into an error estimate needs information on the inverse or the troublesome singular directions.
Derivation and applications
Show why a componentwise backward error survives a change of units
Equations and unknowns often have very different numerical scales. A componentwise backward error measures how much each coefficient and measured load must change relative to its own magnitude to make a computed state exact. For fixed \(\widehat x\), ask for perturbations satisfying \((A+\Delta A)\widehat x=b+\Delta b\) with \(|\Delta A|\le\eta|A|\) and \(|\Delta b|\le\eta|b|\), entrywise. The residual then obeys
Each row can attain any imbalance between these two extremes by choosing signs for its coefficient and load perturbations and scaling them together. Therefore the smallest admissible common relative tolerance is
A zero denominator means that row has zero imbalance for the specified state; assign its ratio zero. Now change equation units with a positive diagonal \(D\) and coordinate scales with another positive diagonal \(S\). Use \(A'=DAS,\ b'=Db,\ \widehat x'=S^{-1}\widehat x\). Direct substitution gives
Every row ratio is unchanged. The plain norm of a residual can instead change by orders of magnitude under exactly the same re-expression. A small componentwise error means a nearby model fits; the forward uncertainty also depends on the conditioning of that model.
Worked example
Compare two differently scaled balances
For \(A=\operatorname{diag}(2,1000)\), \(b=(2,1000)^T\), and \(\widehat x=(1.01,0.999)^T\), the residual is \((-0.020,1)^T\). Row ratios are
The first equation sets the backward error despite the larger absolute residual in the second.
Second application
Change coordinate and equation units simultaneously
For a scalar balance \(3x=12\), test \(\widehat x=3.9\). Its backward error is
Express \(x=100x'\) and multiply the equation by \(0.01\). The transformed equation is \(3x'=0.12\), with \(\widehat x'=0.039\), residual \(0.003\), and denominator \(0.237\). Their ratio again gives \(0.01266\), verifying invariance directly.
A correction equation
Suppose a large matrix has already been factored at modest precision. Let \(x\) be the resulting approximation and recompute \(r=b-Ax\) using the original coefficients. The exact missing correction solves \(Ad=r\). Reusing the approximate factors is cheap because the expensive elimination has finished. If their effective matrix is \(M\), one refinement step solves \(Md=r\) and updates \(x\leftarrow x+d\). Forming the residual from the factors themselves could erase the very discrepancy being measured.
With \(e=x_\star-x\), the residual equals \(Ae\) in exact arithmetic. Substitution yields
Thus a sufficient convergence condition in a chosen induced norm is \(\|I-M^{-1}A\|<1\). The size of the initial error affects how many corrections are needed, while the quality of the approximate inverse controls the contraction. The availability of more accurate residual arithmetic matters once cancellation in \(b-Ax\) competes with the true defect.
Diagonal model for imperfect factors
Take \(A=\operatorname{diag}(3,7)\), \(b=(3,7)^T\), and use \(M=\operatorname{diag}(3,8)\) throughout. The first approximate solve gives
Its residual is \((0,0.875)^T\), and the inexpensive correction is \((0,0.109375)^T\). Hence the second component becomes 0.984375. The corresponding errors in that coordinate decrease from \(1/8\) to \(1/64\). Each further update divides the error by eight because \(1-7/8=1/8\). The exact first component stays fixed.
If the incorrect factor were 3 instead of 8 in the second equation, its error multiplier would be \(1-7/3=-4/3\). Iterating would alternate across the solution with increasing amplitude. Extra residual accuracy could reveal that failure promptly but could never turn this correction matrix into a contraction.
Asking which equation was solved
A backward error asks for the smallest perturbation of the input for which the computed vector is exact. For relative, componentwise changes to both coefficients and load, \(|\Delta A|\leq\eta|A|\) and \(|\Delta b|\leq\eta|b|\), the rowwise correction must absorb \(r_i\). The triangle inequality bounds its capacity by \(\eta(|A||x|+|b|)_i\). Choosing perturbation signs independently within each row attains this capacity, giving
A row with zero denominator and zero residual contributes zero. In the example's second row the initial backward error is \(0.875/(7\cdot0.875+7)=1/15\), even though its forward error is one eighth of the true component. After one correction the denominator is 13.890625 and the residual is 0.109375. The resulting backward error is \(1/127\). Uniformly changing that row's units leaves both ratios unchanged.
A stopping decision
Record the residual obtained using the original data and monitor the size of each accepted correction. Once the residual is comparable to accumulated rounding in its evaluation, more corrections may stagnate. A small backward error then certifies compatibility with nearly identical equations. Converting it to a forward accuracy statement also needs sensitivity information about those equations and the particular output of interest.
Separate data accuracy from solve accuracy
Suppose the second load in the diagonal example was measured as \(7.00\pm0.07\). Even an exact linear solve then gives a second coordinate known only to about 0.01. The initial solve error of 0.125 matters relative to that scale. Two corrections already reduce this error to about 0.00195. Further corrections improve the numerical solution of the nominal input but cannot resolve variation in the measured load. Stating both uncertainties clarifies the practical value of the last digits.
Track residual error through the correction equation
Let the approximate correction solve use a nonsingular matrix \(M\). Suppose residual evaluation returns \(\hat r=Ae+\delta r\), where \(\delta r\) includes accumulated rounding, and the state update has an additional absolute error \(\delta x\). One correction yields \(e_{\rm new}=(I-M^{-1}A)e-M^{-1}\delta r-\delta x\) if \(e=x_\star-x\). A contraction \(\|I-M^{-1}A\|\le q<1\) shrinks the first term, but every iteration injects new errors. If their combined effect is bounded by \(d\), induction gives
This inequality separates an initial geometric improvement from a possible long-run floor. A residual-evaluation bound must use scales of the terms being subtracted, such as \(|b|+|A||x|\), rather than the size of the tiny mathematical residual alone. Also distinguish errors in evaluating the residual from the final rounding of \(x+d\): very small corrections may be accurate but cannot change a stored state if they fall below its local spacing. Computing residuals in higher precision helps only when that residual error is a limiting contribution.
Resolve a correction lost in a cancellation
Consider the decimal thought experiment \(1000x_1+x_2=1001,\ x_1+x_2=2\), whose exact state is \((1,1)^T\). Store the candidate \((1.00,0.990)^T\) and evaluate terms using three significant decimal digits with rounding to nearest. Even if the original input coefficients and load are kept exactly, evaluating the first row naively makes \(1000+0.990\) round to \(1.00\times10^3\); the rounded representation of the right-hand side 1001 is also \(1.00\times10^3\). A residual assembled entirely in that low precision therefore sees a first component of zero. The second component, \(2-1.99=0.01\), remains visible.
Computing the residual using the original data with adequate precision gives \((0.01,0.01)^T\). Subtracting these two correction equations yields \(999d_1=0\), hence \(d_1=0,\ d_2=0.01\), recovering the exact state in one exact correction solve. If instead the low-precision residual \((0,0.01)^T\) is used with the same exact correction matrix, subtraction yields \(999d_1=-0.01\), giving \(d_1\approx-0.00001001,\ d_2\approx0.01001001\). Part of the estimated correction is now allocated to a coordinate that was already exact.
The example uses an exact correction solve to isolate the residual effect. Low-precision factors introduce a separate perturbation. If 1001 had first been irreversibly stored as 1000 in the only surviving copy of the problem, later high-precision arithmetic could not restore the intended equation. Preserving the original coefficients and loads is therefore part of the method whenever refinement is expected to recover accuracy relative to higher-precision input data.
One can estimate which digit was lost without rerunning the solve. The absolute first-row summands have total magnitude about one thousand, while their desired residual is one hundredth. The computation is extracting a quantity roughly one hundred thousand times smaller than its large terms. By comparison the corresponding factor in the second row is only a few hundred. Precision can therefore be inadequate in one equation long before it limits the others.
Change parameters · Explore the worked calculation
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Chapter 12 · Eliminating constraints with Schur complements
Eliminate auxiliary variables, recover constraint forces and account for the sign and conditioning of a reduced system.
From first principles
Eliminate one block of unknowns before solving the rest
A coupled model can have different types of unknowns, such as internal and boundary displacements. Write its linear system in block form with a nonsingular first block \(K\). The first row expresses one group in terms of the other,
Substitute into the remaining balance \(Bu+Dv=g\). Collect all terms that still depend on \(v\) to obtain a smaller system and a recovery step,
The new coefficient matrix is the Schur complement of \(K\). The term in the right-hand side is needed even when no external load acts directly on the retained variables. In practice, notation such as \(K^{-1}C\) denotes solves with columns of \(C\) or an operator action; explicit inversion is unnecessary. If the full matrix and \(K\) are both nonsingular, so is the Schur complement. Very small reduced eigenvalues can signal a weakly constrained remaining quantity.
Background · Schur complement
Eliminate the first block of a partitioned system by solving with A. Forming an explicit inverse is unnecessary and may discard useful structure.
Derivation and applications
Update a solved system after adding one spring or penalty
Suppose factors of a symmetric positive definite matrix \(A\) already exist and a small model change adds one positive stiffness \(k\) acting on the relative coordinate \(u^Tx\). The added energy is \(\tfrac12k(u^Tx)^2\), whose gradient adds \(ku(u^Tx)\) to the original balance. Introduce its scalar force \(t=ku^Tx\). Solving the old matrix with the new internal force gives
Use the constitutive equation for \(t\) to eliminate the full state and solve a one-dimensional Schur complement. The scalar \(u^Tz=u^TA^{-1}u\) is positive for nonzero \(u\). Hence the denominator is safely nonzero for a positive added stiffness,
The new relative displacement follows by applying \(u^T\) again,
This explicitly shows how the added stiffness reduces extension. If the old extension is zero, adding the spring changes neither the old force balance nor the solution. As \(k\) becomes arbitrarily large the extension tends to zero while the internal force approaches a finite constraint reaction. The original factors can serve many choices of stiffness when the location \(u\) stays fixed.
Worked example
Retrofit a link between two supported nodes
Take \(A=\operatorname{diag}(2,4)\,\mathrm{N/m}\), load \(b=(2,0)^T\,\mathrm N\), and \(u=(1,-1)^T\). Initially \(x_0=(1,0)^T\,\mathrm m\); the unit response \(z=(0.5,-0.25)^T\,\mathrm{m/N}\) gives
Adding \(k=4\,\mathrm{N/m}\) gives \(t=1\,\mathrm N\), \(x=(0.5,0.25)^T\,\mathrm m\) and relative extension \(0.25\,\mathrm m\).
Second application
Determine the stiffness needed for a target extension
A different model gives old relative displacement \(6.00\,\mathrm{mm}\) and relative compliance \(0.0200\,\mathrm{m/N}\). Cutting the extension to \(2.00\,\mathrm{mm}\) requires \(1+k(0.0200)=3\), hence \(k=100\,\mathrm{N/m}\). The new force is \(0.200\,\mathrm N\), producing a compliance displacement \(0.0200(0.200)=4.00\,\mathrm{mm}\), exactly the required reduction.
Two coupled sets of equations
A constrained equilibrium may contain displacements \(u\) and reaction coefficients \(\lambda\). Suppose the energy Hessian \(K\) is symmetric positive definite and the constraint matrix \(B\) has independent rows. With applied force \(f\) and prescribed values \(g\), stationarity of \(u^TKu/2-f^Tu+\lambda^T(Bu-g)\) gives \(Ku+B^T\lambda=f\) and \(Bu=g\). The full symmetric matrix is indefinite. Minimising the quadratic energy under the constraints still gives a unique displacement because the energy curves upward along every permissible direction.
Deriving a reduced operator
Solve the first equation formally for \(u=K^{-1}(f-B^T\lambda)\). Inserting this expression into the constraint gives a smaller positive system,
The literal lower diagonal block left by elimination is \(-S\). Multiplying both sides by minus one produces the positive form written above. For any nonzero vector \(z\), full row rank implies \(B^Tz\ne0\), hence
This proof explains why redundant constraints create a singular reduced matrix. Even in that case the physical displacement can remain unique while reactions assigned to duplicate equations become ambiguous.
OneSimulation · How stiff must a link be to act like a constraint?
Two grounded springs with stiffnesses 2 and 8 N/mm carry the force vector \((10,0)^T\) N. Before coupling them, the gap between their displacements is 5 mm. A positive link reaction \(\lambda\) reduces that gap according to \(g=g_0-S\lambda\). The scalar Schur complement \(S=B K^{-1}B^T=0.625\) mm/N measures the gap closed by a unit reaction. A real link of stiffness \(k_c\) obeys \(g=\lambda/k_c\). Eliminating the gap gives
The stiffness of the structure as seen through the link is \(1/S=1.6\) N/mm. Matching this value transfers half the limiting reaction. Reaching 90% requires nine times this stiffness, or 14.4 N/mm. The code checks the reduced force against the full coupled displacement solution over four decades of link stiffness.
"""Find the reaction transmitted by a compliant link between two supports."""
import matplotlib.pyplot as plt
import numpy as np
from onesim.numerics.linear.matrices.dense_linear_algebra import solve_dense
support = np.diag([2.0, 8.0]) # N/mm
load = np.array([10.0, 0.0]) # N
gap = np.array([1.0, -1.0]) # positive when the first support moves farther
free_gap = gap @ solve_dense(support, load)
compliance = gap @ solve_dense(support, gap) # mm/N
link_stiffness = np.geomspace(0.02, 200, 150) # N/mm
reaction = free_gap / (compliance + 1 / link_stiffness)
rigid_reaction = free_gap / compliance
# Check the reduced equation against the full two-displacement system.
for stiffness, force in zip(link_stiffness, reaction):
displacement = solve_dense(support + stiffness * np.outer(gap, gap), load)
assert np.isclose(stiffness * (gap @ displacement), force)
print(f"Half the rigid reaction at {1/compliance:.2f} N/mm; rigid limit {rigid_reaction:.2f} N")
fig, ax = plt.subplots(figsize=(6.8, 3.8), constrained_layout=True)
ax.semilogx(link_stiffness, reaction, color="#176879", label="Elastic link")
ax.axhline(rigid_reaction, ls="--", color="#a4492b", label="Rigid constraint")
ax.plot(1/compliance, rigid_reaction/2, "o", color="#273d30")
ax.set(xlabel="Link stiffness (N/mm)", ylabel="Link reaction (N)", ylim=(0, 9))
ax.grid(alpha=0.2)
ax.legend()
fig.savefig("linear-algebra.png", dpi=160)

Two springs sharing a displacement
Let \(K=\operatorname{diag}(2,8)\) in N/m and apply \(f=(10,0)^T\) N. A rigid link demands \(u_1-u_2=0\), so \(B=(1,-1)\) and \(g=0\). The uncoupled displacement is \((5,0)^T\) m. The reduced compliance is \(1/2+1/8=5/8\) m/N, giving \(\lambda=5/(5/8)=8\) N. Recovering the displacement gives \(u=(1,1)^T\) m. The first spring carries 2 N and the other carries 8 N. Independently, the common displacement under a total stiffness of 10 N/m is exactly one metre.
Prescribing a gap \(g=0.5\) m changes the reduced right-hand side to 4.5 m. The reaction drops to 7.2 N and the displacements become 1.4 and 0.9 m. Their difference verifies the new constraint. This calculation also identifies the multiplier sensitivity to a gap error as \(-1/S\), here \(-1.6\) N/m.
Solving without an explicit inverse
Applying \(S\) to a trial vector takes a multiplication by \(B^T\), a solve with \(K\), and a multiplication by \(B\). The reduced matrix may be dense even with local springs because the stiffness solve communicates through the structure. Reuse a factorisation when the load changes. With approximate inner solves, control their errors relative to the requested outer accuracy. Check force balance and compatibility independently after reconstructing \(u\). A tiny reduced residual obtained with inaccurate inner solves need not imply that the reconstructed state satisfies the original load equations.
A duplicate constraint as a diagnostic
Append a second row \(2B\) to the rigid-link constraint and prescribe a compatible right-hand side \(2g\). The new reduced matrix is \(S\left(\begin{smallmatrix}1&2\\2&4\end{smallmatrix}\right)\), which has determinant zero. Only the combination \(\lambda_1+2\lambda_2\) affects the applied reaction in the mechanical equations. In the zero-gap example every pair with that combination equal to 8 N gives the same displacement and resultant link force. A solver's complaint about a singular constraint block can thus expose a duplicated physical statement, even when a force measurement or displacement plot looks perfectly reasonable.
Condense internal degrees of freedom while preserving energy
Partition the degrees of freedom of a symmetric positive definite stiffness matrix into interior coordinates \(i\) and retained boundary coordinates \(b\). For a specified boundary displacement, the interior balance is
Eliminating it produces the boundary operator \(S=K_{bb}-K_{bi}K_{ii}^{-1}K_{ib}\) and the effective boundary load \(f_b-K_{bi}K_{ii}^{-1}f_i\). This elimination differs physically from setting the interior displacement to zero: the interior has been allowed to respond to the prescribed boundary value and applied load.
With zero load, insert \(u_i=-K_{ii}^{-1}K_{ib}u_b\) into the full strain energy. Completing the square in \(u_i\) shows that the minimum energy at fixed boundary coordinates is \(u_b^TSu_b/2\). Since the full stiffness is positive definite, any nonzero boundary vector yields positive minimum energy. This gives a physical proof that the condensed operator is positive definite. A free-floating component may instead have rigid-body modes; then the same proof establishes only nonnegativity, and some imposed displacement patterns cause no stress.
Reduce a spring chain and preserve the internal load
Two springs connect a fixed left support to an observable endpoint through an internal joint. Their stiffnesses are 6 and 3 N/mm. Let the internal and boundary displacements be \(u_i,u_b\), and apply forces 3 and 6 N at those nodes. The strain energy is \([6u_i^2+3(u_b-u_i)^2]/2\). Differentiating gives
Condensing yields \(S=3-9/9=2\) N/mm and effective boundary load \(6-(-3)(3/9)=7\) N. Thus \(u_b=3.5\) mm. Recovering the internal state gives
The first spring therefore carries \(6(1.5)=9\) N, and the second carries
Their difference is the internal force of 3 N and the support reaction balances the total applied load of 9 N. Simply using the well-known series stiffness \(2\) N/mm with the endpoint force 6 N would yield 3 mm, missing the transmitted effect of the interior load. Both condensed stiffness and condensed right-hand side are necessary in a reduced model.
A local finite-element assembly can repeat this calculation for many independent element interiors, retaining only interface coordinates for the global solve. To compute internal stress afterward, keep enough local factor information to reconstruct each eliminated state. The boundary displacement alone does not directly encode the internal load distribution; two differently loaded elements can have the same endpoint displacement and different internal stresses. This distinction matters whenever reduction is justified using one observable but results are later requested for another.
Under a change in the prescribed end condition, the same reduced law can be used in the opposite direction. Hold the endpoint at \(u_b=0\) with the internal 3 N force still present and remove the applied endpoint load. The recovered internal displacement is \(1/3\) mm. The computed endpoint force required to hold it fixed is \(-3u_i=-1\) N. A boundary law containing only the series stiffness would predict zero force for this imposed zero displacement.
Read the coupling introduced by eliminating an interior node
Three terminals join a central node through conductances \(1,2,g\) S. The central potential is their conductance-weighted average. Substitute it into each terminal current. The Schur complement introduces a direct pairwise conductance \(g_i g_j/\sum g_\ell\).

Read values from the plot
| Third branch conductance (S) | Between terminals 1 and 2 | Between terminals 1 and 3 | Between terminals 2 and 3 |
|---|---|---|---|
| 0 | 0.66667 | 0 | 0 |
| 1.24 | 0.4717 | 0.29245 | 0.58491 |
| 2.5 | 0.36364 | 0.45455 | 0.90909 |
| 3.76 | 0.29586 | 0.55621 | 1.1124 |
| 5 | 0.25 | 0.625 | 1.25 |
Change parameters · Read the coupling introduced by eliminating an interior node
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Study the full derivation
When stable eigenvalues allow large transient growth · Matrix computations and spectral accuracy
Two damped states exchange energy in only one direction. Its eigenvalues predict ultimate decay, while a short-time response can grow by a large factor. Compute the matrix exponential, its gain and a resolvent-based sensitivity check.
Problem sheet 6 · Accurate constrained solves
Track the correction error, distinguish residual definitions, and recover physical forces from a constrained quadratic model.
Reuse an inaccurate scalar factor
Solve \(5x=10\) using the approximate factor 6 for the initial solution and every correction. Derive the error after \(k\) corrections and count how many bring absolute error below 0.002.
Worked solution
The starting value \(10/6\) leaves \(e_0=1/3\). The correction adds \(5e_k/6\), so \(e_{k+1}=e_k/6\) and \(e_k=1/(3\cdot6^k)\).
Two corrections give \(1/108\approx0.00926\). Three give \(1/648\approx0.00154\), below the threshold. Residuals must use the original factor 5 because the initial value solves the approximate equation exactly.
Try this calculation. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Scale the units
For \(A=\operatorname{diag}(1,1000)\), \(b=(1,1000)^T\), \(x=(0.99,1)^T\), compute the infinity norm of the residual and the maximum componentwise backward error. Repeat when the first row and its load are multiplied by 100.
Worked solution
Initially \(r=(0.01,0)^T\), hence its infinity norm is 0.01. The maximum row ratio is
Rescaling changes the first residual to 1 and its denominator to 199. The maximum absolute residual increases hundredfold, whereas the backward error remains \(1/199\). The two systems describe exactly the same solution.
Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Prescribe a weighted displacement
Minimise \((u_1^2+4u_2^2)/2\) subject to \(u_1+2u_2=3\). Using \(Ku+B^T\lambda=0\), determine the reduced stiffness equation, the multiplier and the stored energy. Compare that energy with the admissible state \((3,0)\).
Worked solution
With \(K=\operatorname{diag}(1,4)\), \(B=(1,2)\), the scalar compliance is \(1+4/4=2\). The reduced system is \(2\lambda=-3\). Back-substitution gives \(u=(1.5,0.75)^T\), satisfying the prescribed value.
The energy is
The competing state has energy 4.5. Positive definiteness on the constraint line guarantees that the stationary state is its unique minimum.
Explore the related calculation with adjustable inputs. Inspect the effective couplings obtained by eliminating an interior variable. The same substitution generates the Schur operator in the stated constrained system.
Reconstruct a displacement measured almost twice in the same direction
Two gauges measure b = Ax with A having rows (1, 0) and (1, 0.01). With b = (1.000, 1.010) find x. Each reading has independent standard deviation 0.001. Estimate the standard deviation of each displacement and their covariance. Evaluate a proposed third gauge measuring only the second displacement.
Worked solution
The first equation gives x₁ = b₁ and differencing gives x₂ = 100(b₂−b₁) = 1. The solution is (1, 1). A residual of zero follows automatically for an invertible square system, even though the second displacement is obtained by subtracting two close readings.
The covariance follows by propagating the independent reading errors. Var(x₁) = 10⁻⁶ and Var(x₂) = 10⁴(2 × 10⁻⁶) = 0.020, so the standard deviations are 0.001 and 0.1414. The covariance is −100 × 10⁻⁶ = −0.0001. An upward perturbation of the first gauge increases x₁ but decreases the reconstructed x₂.
A third independent reading of x₂ with the same standard deviation carries much more precision along the weak direction. Fuse the old x₂ estimate with this reading using inverse variance: the new variance is 1/(1/0.020 + 1/10⁻⁶) ≈ 9.9995 × 10⁻⁷. In the joint fit solve the overdetermined system by QR. Repeating the original two directions could improve repeatability, but would retain the poor geometry.
Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Chapter 13 · Why a positive energy has a Cholesky factor
Start with the work stored in two coupled springs and discover a triangular square root of a matrix by completing the square.
From positive energy to two triangular solves
If displacements \(x\) store elastic energy \(x^TAx/2\), then a fixed structure with no free modes has \(x^TAx>0\) for every nonzero \(x\). Equilibrium under load \(f\) minimises \(x^TAx/2-f^Tx\). Differentiation gives \(Ax=f\) for symmetric \(A\). Can the energy itself tell us which operations are safe in a solver?
Write the first coordinate as \(s\) and the remaining coordinates as \(z\). Expand the quadratic form using first entry \(a\), coupling column \(b\), and trailing block \(C\). The cross term is \(2s b^Tz\). Adding and subtracting \((b^Tz)^2/a\) gives
Positivity with \(x=e_1\) proves \(a>0\). For any nonzero \(z\), choose \(s=-b^Tz/a\). The remaining term must then be positive, so the reduced matrix is positive definite. The argument repeats down to a scalar. Each completed square supplies one row of a triangular factor and one positive pivot. In matrix notation \(A=LL^T\), with \(L_{11}=\sqrt{a}\) and \(L_{2:n,1}=b/\sqrt{a}\). Solve \(Ly=f\) forward, then \(L^Tx=y\) backward. Neither inverse need be formed.
Worked equilibrium and a change of load
Use \(A=\left(\begin{smallmatrix}4&2\\2&5\end{smallmatrix}\right)\) kN/m. The first diagonal factor is 2, the off-diagonal factor is 1, and the remaining pivot is \(5-1^2=4\). Thus \(L=\left(\begin{smallmatrix}2&0\\1&2\end{smallmatrix}\right)\) in consistent numerical units. For \(f=(2,3)^T\) kN the intermediate result is
Back substitution gives \(x=(0.25,0.5)^T\) m. Check the second row directly: \(2(0.25)+5(0.5)=3\).
Now apply \(f=(0,2)^T\) to the same structure. The intermediate vector changes to \((0,1)^T\) and the displacements to \((-0.25,0.5)^T\). The same two square roots serve both load cases. This matters for many load cases on one stiffness matrix.
Change the coupling
For the dimensionless matrix with diagonal 1 and off-diagonal \(c\), predict which load direction becomes soft as \(c\) approaches one. The plot follows elimination along the first displacement for three fixed values of the second. Read the minimum on each slice before changing \(c\).
The second pivot is \(1-c^2\). Under the antisymmetric load \((1,-1)^T\) the displacement is \((1,-1)^T/(1-c)\). A modest change in the input coupling can therefore have a large physical effect even with an exact factorisation.
Tutorial on pivots and supports
A free two-node spring has matrix \(k\left(\begin{smallmatrix}1&-1\\-1&1\end{smallmatrix}\right)\). Where does the recurrence stop and which physical motion does it reveal?
Worked solution
Elimination gives the second pivot \(k-k^2/k=0\). Translating both endpoints by the same amount stores zero energy. Fixing one displacement removes that unconstrained motion.
For diagonal entries 9 and 4, what range of coupling \(b\) admits positive pivots? Interpret the endpoints.
Worked solution
The first pivot is 9. The second is \(4-b^2/9>0\), or \(|b|<6\). At equality the second completed square vanishes. There is a displacement with zero energy even though each diagonal term separately is positive.
Chapter 14 · Removing unequal scales before an iteration
Derive the change of variables behind diagonal preconditioning, then measure what it can and cannot repair in a two-spring system.
Coordinates in the energy
Suppose one displacement is measured in millimetres and the other in metres. A steepest-descent direction depends on the Euclidean lengths of the coordinates. The physical minimum does not. Let \(A\) be symmetric positive definite, \(D=\operatorname{diag}(A)\), and introduce \(y=D^{1/2}x\). Substituting \(x=D^{-1/2}y\) in the energy produces
The diagonal of the new matrix is one. Its off-diagonal entry is the original coupling divided by the geometric mean of the two direct stiffnesses. This is a dimensionless measure of interaction. The transformed gradient step maps back to \(x_{j+1}=x_j+\alpha D^{-1}(b-Ax_j)\).
Choosing a common step
For any eigenvector of the transformed matrix the iteration multiplies the error by \(1-\alpha\lambda\). With eigenvalues in \([m,M]\), equalise the two extreme absolute factors by taking \(1-\alpha m=-(1-\alpha M)\). This gives \(\alpha=2/(M+m)\) and worst-case contraction \((M-m)/(M+m)\). If \(m\) approaches zero the direction barely moves, however accurately the linear algebra is performed.
Two quite different causes of a slow solve
For \(A=\operatorname{diag}(100,1)\), an optimal unscaled step shrinks the error by only \(99/101\). Diagonal scaling gives the identity. One step of length one then solves both components exactly. This is the effect of unlike units or stiffness scales.
For a unit-diagonal matrix with coupling 0.95, scaling leaves the matrix unchanged. Its eigenvalues are 1.95 and 0.05. Each optimal step can retain 95% of the error. The nearly free opposing motion is part of the problem itself. A preconditioner that represents the coupling, or a different physical constraint, is needed for faster convergence in that direction.
Compare convergence factors
Vary the stiffness ratio and coupling independently. The curves are worst-case error factors raised to the iteration count. They give bounds attained by an extreme eigenmode with this particular fixed optimal step.
Tutorial on interpreting convergence
If a bound decreases from 1 to \(10^{-3}\) in \(k\) steps, how do you determine \(k\) from a known factor 0.8?
Worked solution
Take logarithms in \(0.8^k\le10^{-3}\). Because \(\log(0.8)\) is negative, division reverses the inequality. The smallest integer is 31.
Why should a conjugate-gradient implementation use a positive definite preconditioner?
Worked solution
In transformed variables CG minimises an energy for a symmetric positive definite operator. A positive definite preconditioner admits an invertible square root and transfers this property by congruence. An indefinite matrix does not define the corresponding norm.
Read the university treatment
Track which linear system must be solved at each iteration. Compare the cost of a preconditioner with the reduction in the iteration count. Driscoll and Braun · Preconditioning
Chapter 15 · How a moderately accurate mode can give a precise frequency
Use the Rayleigh quotient to estimate an eigenvalue, understand its stationary error and check a proposed mode with a residual.
A frequency estimate from a trial shape
For \(Kq=\lambda Mq\) with symmetric \(K\) and positive definite mass \(M\), a trial vector \(v\) fixes a direction but leaves an amplitude free. Substituting \(q(t)=a(t)v\) in kinetic and elastic energy gives effective mass \(v^TMv\) and stiffness \(v^TKv\). Their ratio \(R(v)\) estimates the squared frequency. Rescaling \(v\) has no effect. For \(M=I\), differentiating \(v^TKv/(v^Tv)\) gives a gradient proportional to \(Kv-Rv\). Its zeros are precisely the eigenvectors.
Angular error and the residual
Take exact orthonormal modes \(u_1,u_2\) and a trial \(v=u_1\cos\theta+u_2\sin\theta\). Orthogonality removes all cross terms. Then
The eigenvalue error is second order in a small angular error. The residual is first order. For general dimension write \(v=\sum c_i u_i\) with unit norm. The squared residual is \(\sum |c_i|^2(\lambda_i-R)^2\), so at least one eigenvalue lies within one residual norm of \(R\). Identifying which mode requires more information about the spectrum.
Two measurements
For squared frequencies 4 and 9 in s⁻² and a 10-degree error in the first trial mode, \(R=4+5(0.03015)=4.1508\) s⁻². The estimated angular frequency is 2.0373 rad/s. The relative error in frequency is about half the relative error in its square at small errors.
For eigenvalues 4 and 4.01, a 45-degree mixture gives a residual of just 0.005. This very small number is consistent with a large uncertainty in shape. If the two eigenvalues were identical, every combination in the eigenspace would be an exact mode.
Tilt the trial vector
The plot shows the quotient error and residual across trial angles for a chosen spectral gap. Move the angle marker, halve a small angle and compare the two responses.
Tutorial on frequency estimates
For eigenvalues 2 and 10, a trial produces \(R=2.08\). Assuming the two-mode model, estimate its angular error.
Worked solution
The mixture fraction is
Hence \(|\sin\theta|=0.1\), or about 5.74 degrees near the lower mode.
A trial gives \(R=5\) and residual zero. Does it prove that 5 is the lowest eigenvalue?
Worked solution
It proves that the trial vector is an exact eigenvector for 5. To certify the lowest eigenvalue one also needs a lower bound or a description of the remaining spectral subspace.
Read the university treatment
Compare how quickly an eigenvector direction converges with the rate for its Rayleigh-quotient eigenvalue estimate. Driscoll and Braun · Power iteration
Chapter 16 · How to rotate two point clouds into agreement
Reduce a nonlinear-looking alignment problem to two scalar sums, distinguish reflections from rotations and recognise a geometry that contains no information about angle.
Eliminate translation before fitting orientation
A microscope images the same markers twice. Marker \(i\) has coordinates \(p_i\) in the first image and \(q_i\) in the second. Seek a proper planar rotation \(R\) and translation \(t\) minimising \(\sum_i\|q_i-Rp_i-t\|^2\). Differentiating with respect to \(t\) gives
Substituting this expression centres both sets. Write \(P_i=p_i-\bar p\) and \(Q_i=q_i-\bar q\). Orthogonality of \(R\) makes \(\sum\|P_i\|^2+\|Q_i\|^2\) independent of the angle. Minimising distance is therefore equivalent to maximising \(\sum Q_i^TRP_i\).
Recover the angle and its conditioning
Insert the rotation matrix with first column \((\cos\theta,\sin\theta)\). Collect the cosine and sine terms to obtain \(C\cos\theta+S\sin\theta\), with \(C=\sum P_i\cdot Q_i\) and \(S=\sum(P_{ix}Q_{iy}-P_{iy}Q_{ix})\). The maximum occurs at \(\operatorname{atan2}(S,C)\). Unlike an ordinary arctangent, this keeps the quadrant and handles \(C=0\). The objective curvature at the maximum is \(-\sqrt{C^2+S^2}\). Small curvature signals that very different angles fit almost equally well.
Two fits with identical measurement precision
For centred markers \((-1,0),(1,0)\) and observations \((0,-1),(0,1)\), \(C=0,S=2\). The result is 90 degrees. Adding the displacement \((3,2)\) to every observation leaves the fitted angle unchanged and recovers precisely that translation. If both markers coincide then all centred \(P_i\) vanish and no angle can be identified.
Now separate the original markers by \(2a\) and shift one observed marker by a transverse measurement error \(\epsilon\). At zero true rotation the connecting segment tilts by \(\arctan(\epsilon/(2a))\). The same 0.1 mm error means about 2.86° for \(a=1\) mm but only 0.29° for \(a=10\) mm. A low spatial residual alone is an incomplete calibration certificate.
Vary the calibration baseline
The true angle is fixed at 20 degrees. A vertical error is added to the positive marker in the second image. The plotted squared distance is computed after centring. Locate its minimum and examine how broad it is for a short or long baseline.
Tutorial on what the fit measures
If an unconstrained matrix maps a chiral triangle to its mirror with zero error, can a proper planar rotation do the same?
Worked solution
A rotation has determinant +1 and preserves signed area. A reflection reverses signed area. A non-collinear labelled triangle cannot match its mirror exactly under a proper rotation and translation.
Why can one ignore weights for equally precise markers but not for a blurred outlier?
Worked solution
Independent isotropic errors with equal variance give a common quadratic weight. Different variances require weighted centroids and weighted \(C,S\) sums. A very noisy marker should contribute less to the fitted orientation.
Chapter 17 · Reading an effective resistance from a singular graph matrix
Assemble Kirchhoff's equations from oriented edge differences, remove the arbitrary reference voltage and relate a two-terminal measurement to minimum dissipation.
One matrix for current balance
Give each resistor edge an arbitrary orientation. A row of the incidence matrix \(B\) has −1 at its tail and +1 at its head. The difference \(Bv\) measures an oriented voltage drop. With diagonal conductances \(G\), the dissipated power is
Differentiating half this quadratic minus injected-current work \(j^Tv\) gives \(Lv=j\) with \(L=B^TGB\). Changing an edge orientation changes a sign twice and leaves \(L\) unchanged.
A constant voltage lies in the nullspace because \(B\mathbf1=0\). On a connected graph the converse follows from \(v^TLv=\sum_e g_e(\Delta v_e)^2\): zero energy forces equal voltage across every edge. The current injections must sum to zero. Set one reference voltage to zero or constrain the mean to remove this unobservable constant.
Compute a three-node measurement in two ways
Connect terminals A and C by a 6 Ω resistor. A second path passes through B with 2 Ω between A and B and 4 Ω between B and C. Inject 1 A at A, remove 1 A at C and ground C. Kirchhoff at B gives \((V_B-V_A)/2+V_B/4=0\), so \(V_B=2V_A/3\). At A, \(V_A/6+(V_A-V_B)/2=1\), giving \(V_A=3\) V and \(V_B=2\) V. Effective resistance is 3 Ω.
Each parallel path carries 0.5 A, and dissipates \(0.5^2(6)=1.5\) W. Total heat equals \(I(V_A-V_C)=3\) W. Opening the direct edge doubles the effective resistance. Opening an edge that bridges two otherwise disconnected subgraphs can instead make it impossible to pass any steady current between the terminals.
Challenge a network calibration
Change the two series resistors. The independent variable is the direct A–C resistance. The graph compares the terminal resistance with the middle-node voltage under a 1 A test current. In these numerical units volts and ohms have equal numbers; each curve's legend identifies the physical quantity.
Tutorial on identifiability in a circuit
Can a single terminal-resistance reading isolate the two series resistor values?
Worked solution
It determines only their sum if the direct edge is known. Measuring \(V_B\) under the same known 1 A injection determines the division within that sum.
Why does minimising dissipation with prescribed terminal voltages yield Kirchhoff balance at interior nodes?
Worked solution
A variation of any free voltage contributes twice its net current departure to the first variation of total power. At the minimum all such coefficients vanish. Terminal voltages are fixed and their reaction currents are the measured injections.
Study the full derivation
Solve a singular network without inventing a ground current · Matrix computations and spectral accuracy
A floating resistor network has unique voltage drops but no absolute voltage reference. Derive its nullspace, test charge balance, and distinguish adding a computational gauge from changing the physical boundary conditions.
Chapter 18 · Counting vibration modes without calculating their shapes
A long chain of beads is tested on a shaker. The instrument can sweep only a narrow frequency interval, and the operator wants to know which resonance lies inside it. Turn a mass and spring model into a counting problem. Work out why a sign in an elimination step can identify a frequency that has never been computed directly.
Start with one displacement per bead
Number the moving beads from one to \(n\). A fixed support at either end has zero displacement. Each neighbouring pair is joined by an identical linear spring of stiffness \(k\), including the two end springs. Write down the force on bead \(i\) by extending each spring separately. The left spring pulls in proportion to \(u_{i-1}-u_i\), the right spring in proportion to \(u_{i+1}-u_i\). The diagonal coefficient two comes from two neighbours, including a fixed support when the bead is at an end. Removing an end spring would change the physical model and its first frequency.
Set \(u_i(t)=v_i\cos(\omega t)\) and cancel the nonzero time factor. The resulting equation is \(Kv=\lambda Mv\) with \(\lambda=\omega^2\). The stiffness matrix has a quadratic energy interpretation: multiplying by a displacement on either side gives the sum of all squared spring extensions times \(k\). This sum is positive unless all displacements vanish, because the end supports pin the chain. The diagonal mass matrix is also positive. Thus a frequency of zero in this experiment would call for an explanation.
Directly dividing each row by its own mass produces \(M^{-1}K\), which need not look symmetric. Instead set \(z=M^{1/2}v\). Multiplying by \(M^{-1/2}\) on the left gives \(Az=\lambda z\) with \(A=M^{-1/2}KM^{-1/2}\). The diagonal entries are \(a_i=2k/m_i\); the neighbouring entries are \(b_i=-k/\sqrt{m_im_{i+1}}\). Both have units of inverse time squared. Increasing one bead mass changes two neighbouring off-diagonals as well as a diagonal. Changing only the diagonal in a program would simulate a different chain.
Derive the shift count by completing squares
Pick a real test value \(s\) in squared-frequency units. In an orthonormal eigenbasis the quadratic form of \(A-sI\) is \(\sum_j(\lambda_j-s)y_j^2\). The largest dimension of a subspace on which this form is strictly negative counts eigenvalues below the test value. An invertible change of coordinates maps a negative subspace bijectively onto another negative subspace of the same dimension. The largest dimension stays fixed. This is the part of the law of inertia that our computation needs.
Now look at the same form in the original bead coordinates. Its first terms are \(d_1 z_1^2+2b_1z_1z_2+(a_2-s)z_2^2\), where \(d_1=a_1-s\). Complete the square in \(z_1\). The coefficient of the transformed first square is \(d_1\). The coefficient left for \(z_2^2\) is reduced by \(b_1^2/d_1\). Only the next coordinate is touched because the matrix is tridiagonal. Repeat the same operation until no cross term remains.
Each square completion is an invertible shear when its pivot is nonzero. Consequently the number of negative pivots equals the number of negative eigenvalues of the shifted matrix. This gives a practical count with linear work per shift and only one saved pivot. It also explains why the signs of the unmodified diagonal alone cannot work. Every spring couples two neighbouring trial directions; elimination carries the contribution of that coupling forward.
Find the bracket for a requested resonance
Put \(k=m_i=1\) in a three-bead chain. Its diagonal is \(2,2,2\) and both off-diagonals equal \(-1\). At \(s=1\) the second pivot is exactly zero, so choose \(s=1.2\) first to follow ordinary arithmetic. The pivots are \(0.8,-0.45,3.0222\ldots\). There is one eigenvalue below 1.2. At \(s=2.4\) they are \(-0.4,2.1,-0.87619\ldots\), giving two eigenvalues below 2.4. The second resonance in squared-frequency units lies between these two shifts. The uncertainty in angular frequency is the difference between their square roots.
For a longer chain it would be inconvenient to choose the first two trial shifts by luck. In an eigenvector choose a component of maximum absolute value. Divide its matrix row by that component. The sum of the neighbouring contributions is bounded in magnitude by the sum of the neighbouring absolute off-diagonals. Every eigenvalue therefore falls inside at least one interval centred on a diagonal entry with that row sum as radius. The minimum left endpoint and the maximum right endpoint supply an enclosing interval. A small outward extension avoids ties at the first or last bound.
To select the \(j\)-th eigenvalue in ascending order, halve the interval. If the count at its midpoint is less than \(j\), the desired eigenvalue is on the upper side. Otherwise keep the lower side. Once the interval is initialised, the reduction factor does not depend on the accuracy of an initial frequency guess. After \(r\) splits the width in exact arithmetic equals its original width divided by \(2^r\). A small eigenvalue can still have a relatively wide frequency interval after taking square roots, so apply the stopping criterion in the quantity your instrument actually reports.
Separate the numerical count from an experimental identification
Open full-size diagramFor the uniform chain try \(v_i=\sin(i\theta)\). This trial shape vanishes at the left support. The right support requires
Substitution into an interior row and the sum formula for neighbouring sines give
For three unit beads the spectrum is approximately 0.58579, 2 and 3.41421. This furnishes an independent reference for all the mode counts, including the mode with an exactly representable eigenvalue. The notebook also compares with a dense symmetric solve which can be repeated using OneSimulation's linear algebra backend.
Double the mass of the middle bead and think about the second uniform mode before solving again. Its displacement vector is proportional to \((1,0,-1)\). There is a node at the heavier bead. Both \(Kv\) and \(Mv\) are unchanged for this particular vector, so its squared frequency remains two. The lowest mode has substantial displacement there and generally moves. The operator can use this contrast experimentally: a frequency that hardly shifts under a known local mass change constrains the possible mode shape even when that shape was never recorded.
The count itself describes the modelled spectrum. A measured frequency response can hide a resonance if the shaker or the sensor sits exactly on a modal node. Conversely, a broad peak may contain two lightly separated modes. To compare with an experiment one needs the forcing and measurement directions as well as the frequency count. In the symmetric ideal chain, replacing a centre sensor with two off-centre sensors can expose a mode that a centre sensor cannot see. The counting algorithm has no term for this observation geometry.
What a zero pivot means on a computer
A zero intermediate pivot need not be an eigenvalue of the entire matrix. It may be an eigenvalue of a smaller leading block. Approaching the troublesome shift from one side resolves the ambiguous endpoint convention. If instead one jumped directly to an arbitrary large replacement pivot, its coupling contribution and sometimes its sign count would be wrong. The notebook uses a small negative pivot in unit-scaled problems, as in a conventional safeguarded Sturm count. An exact eigenvalue at the shift is then counted on the lower side. It tests that convention on the known three-bead chain.
Floating-point arithmetic places another limit on what it means to halve a bracket. Eventually the rounded midpoint equals one of its endpoints. At that stage further iterations cannot separate floating-point trial values. A production interval solver also handles extreme scaling, split tridiagonal blocks and tiny off-diagonals, and can report an interval containing a cluster. The notebook is deliberately a transparent solver for moderate, nondimensional examples. Its final consistency test tolerates a few units of roundoff so that the dense reference can be rounded differently.
Tutorial on counts, brackets and experimental nodes
1. A four-second sweep is centred at an angular frequency of 1.4 per second. Does the three-bead example put the second natural frequency between 1.40 and 1.43 per second?
Work through the solution
Square both positive bounds to get 1.96 and 2.0449 in inverse seconds squared. The count changes from one to two across them because the middle eigenvalue is 2. Its frequency is the square root of two, approximately 1.41421 per second. A finite measurement time still limits how sharply an instrument can identify this peak.
2. A starting interval in squared frequency is 8 units wide. How many halvings guarantee a width below one thousandth of a unit, and what part of the cost grows with bead count?
Work through the solution
Thirteen halvings give
Twelve leave \(0.001953125\). Each test visits every diagonal and each connecting off-diagonal once. The number of halvings follows from the desired absolute accuracy; the work of each count grows with the length of the chain.
3. Break the spring between beads 7 and 8 of a fixed-end chain without adding a support. How should the inertia procedure and the stiffness entries change?
Work through the solution
Remove the coupling and subtract that spring’s stiffness from each of the two adjacent unscaled diagonal entries before mass normalisation. The two components now have an independently free end and a fixed outer support. Count the shifted pivots separately in the two blocks and add the counts. Simply setting the off-diagonal to zero while keeping both diagonals would add artificial restoring forces at the cut.
Further reading · LAPACK Working Note 172 on Sturm counts and floating-point arithmetic for symmetric tridiagonal matrices
Change parameters · Counting vibration modes without calculating their shapes
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Problem sheet 7 · Project · Can two displacement sensors distinguish soft and stiff modes?
A pair of spring-mounted platforms forms a small inverse experiment. Use energy, conditioning, factorisation and modal residuals to decide what can be inferred from a measured displacement.
Assemble the stiffness from a physical experiment
Each platform is attached to a wall by a spring of stiffness \(k=1\) N/m. A coupling spring between platforms has stiffness \(c=49.5\) N/m. Start with the extensions of all three springs, write twice the energy and identify \(K\). Predict the two eigenvectors before computing its eigenvalues.
Work through the solution
The extension of the coupling is \(x_2-x_1\). Thus \(2U=k(x_1^2+x_2^2)+c(x_2-x_1)^2\) and the diagonal entries are \(k+c=50.5\), with off-diagonals \(-c=-49.5\). In-phase motion leaves the coupling untouched and has eigenvalue 1. Opposing motion stretches it and has eigenvalue 100. The 2-norm condition number is 100.
Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Solve one load and verify the result independently
Apply \(f=(1,0)\) N. Solve in modal coordinates, then calculate the elimination pivots and the diagonal of the Cholesky factor and recover the same displacements by a separate route. Which part of \(x\) is most difficult to infer from imperfect displacement measurements?
Work through the solution
The load is half the sum of \((1,1)\) and \((1,-1)\). Divide by their stiffnesses to get \(x=(0.505,0.495)\) m. The first pivot is 50.5, the second is
Eliminating the first row yields this second pivot with right-hand side \(49.5/50.5\). These elimination pivots are the diagonal of \(D\) in an \(LDL^T\) factorization. The positive-diagonal Cholesky factor has their square roots on its diagonal, about 7.106 and 1.407. Back substitution agrees. The difference of the displacements is only 0.01 m. Estimating the large coupling stiffness from that difference is sensitive to small sensor errors.
Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Change the energy and test the diagnosis
Divide \(K\) by 50.5 to give a matrix with unit diagonal. Enter the new off-diagonal into the chapter on positive pivots to the nearest slider value and compare the minimum across slices. Next use the scaling experiment with equal diagonal stiffnesses and the absolute coupling. Explain the residual slow direction.
Work through the solution
The normalised coupling is about \(-0.9802\). Its second pivot is \(1-0.9802^2\simeq0.0392\). The almost-flat valley runs along the in-phase motion. Flipping the sign of the second coordinate changes the sign of the coupling and preserves eigenvalues. Diagonal preconditioning cannot separate the scales because the diagonal terms are already equal; a basis that separates the two physical modes can.
Transfer the conclusion to a reported frequency
A unit-mass trial mode is tilted 3° away from the soft mode. Predict its Rayleigh quotient and the frequency bias. Would a two-decimal-place frequency match identify the trial shape?
Work through the solution
For eigenvalues 1 and 100 the quotient is \(1+99\sin^2(3^\circ)\simeq1.2712\) s⁻². The angular frequency is about 1.1275 rad/s, an error close to 12.8%. At an independently verified angular frequency of 1.00 rad/s to the nearest 0.01, this two-mode model requires \(1+99\sin^2\theta<1.005^2\), hence \(|\theta|<0.58^\circ\) up to the arbitrary eigenvector sign. The reading bounds the tilt but does not determine its value or sign. A smaller eigenvalue gap would weaken that bound.
Explore the related calculation with adjustable inputs. Change the parameters in the corresponding calculation and compare its independently recomputed values with the equation derived in this solution.
Problem sheet 8 · Can an eigensolver certify the pitch of a continuous string?
A taut string gives a known continuum spectrum. Use its kinetic and elastic energies to construct two different matrix pencils. Both can pass a residual test to machine precision while assigning visibly different pitches to the same oscillation.
Build both matrices from a single element
A straight string of length \(L=1\) m, tension \(S=40\) N and mass per unit length \(\rho=0.0040\) kg/m has fixed ends. Divide it into \(N\) intervals of length \(h=L/N\). Approximate transverse displacement on each interval by a straight line between neighbouring nodal displacements \(u_i,u_{i+1}\). Use this shape for both velocity and slope. Which local mass entries would be lost by assigning half the segment mass to each end before squaring the interpolated velocity?
Integrate the kinetic and elastic quadratic forms
Derive the two \(2\times2\) matrices and explain which physical motion makes the elastic energy vanish.
Work through the solution
The interpolated velocity at local coordinate \(\xi\in[0,1]\) is \((1-\xi)\dot u_i+\xi\dot u_{i+1}\). The squared shape functions each integrate to \(1/3\) and their product integrates to \(1/6\). The slope is constant, \((u_{i+1}-u_i)/h\). Comparing the integrals with half a matrix quadratic form gives
A common translation costs no elastic energy and a uniform velocity gives exactly the total element mass. Replacing \(M_e\) by its diagonal of row sums produces two equal masses \(\rho h/2\). This lumped version also gets the uniform-motion energy right but gives more kinetic energy for velocities of opposite sign at the nodes. Assemble contributions at shared nodes and eliminate fixed endpoint degrees of freedom after applying the local row sum. Summing rows only after deleting endpoint columns silently changes the end-adjacent mass.
Explore the related calculation with adjustable inputs. Change the parameters in the experiment on this same project page and compare its output with this part of the derivation.
Diagonalise a sparse pencil without forming an inverse
The interior stiffness row applies \(S(2u_j-u_{j-1}-u_{j+1})/h\). Set \(u_j=\sin(j\theta)\) so
What does each mass row do to the same nodal vector, and which wavenumbers obey both boundary conditions?
Find both discrete dispersion relations
Impose \(u_0=u_N=0\), discard the zero vector and express the angular frequencies directly.
Work through the solution
Use \(\theta=m\pi/N\) for \(m=1,\ldots,N-1\). The consistent mass row multiplies the nodal sine by \(\rho h(2+\cos\theta)/3\); the lumped row multiplies it by \(\rho h\). Inserting \(u(t)=v e^{i\omega t}\) into \(M\ddot u+Ku=0\) gives
With \(c=\sqrt{S/\rho}=100\) m/s the results are
The consistent mass includes the exact kinetic energy of each piecewise-linear trial displacement. For this conforming space its Rayleigh–Ritz eigenvalues bound the exact squared frequencies from above. The lumped result is lower because \(\sin u<u\) for positive \(u\). Lumping changes the inner product, so the same variational upper-bound argument cannot simply be transferred to it. For a nonuniform mesh the sine vectors need not diagonalise either matrix. A symmetric generalised eigensolver or a Cholesky reduction \(M=BB^T,\ B^{-1}KB^{-T}w=\lambda w\) retains the appropriate symmetry. Recover \(v=B^{-T}w\) and normalise in the mass inner product.
Explore the related calculation with adjustable inputs. Change the parameters in the experiment on this same project page and compare its output with this part of the derivation.
Distinguish algebraic and discretisation error
Audit a computed fourth harmonic
Use eight intervals. Both sine vectors give tiny relative residual \(\|Kv-\lambda Mv\|/[(\|K\|+|\lambda|\|M\|)\|v\|]\) in their own equations. Report the predicted frequency with each mass. Explain how an experimenter could spot the error without an exact continuum reference.
Work through the solution
Here \(\theta=\pi/2\). The continuum fourth harmonic is 200.0 Hz. The lumped value is \(800\sqrt{2}/(2\pi)=180.06\) Hz, and the consistent value is larger by \(\sqrt{3/2}\), giving 220.53 Hz. Each algebraic residual tests whether the vector solves the matrix equation supplied to the solver. Neither residual tests the geometric approximation used to build that equation. Refine while keeping the same physical mode number and track the same number of interior zeros. Comparing the highest available harmonic after every refinement compares different physical modes.
For a smooth fixed mode the frequency ratios expand as \(1-\theta^2/24+O(\theta^4)\) for lumping and \(1+\theta^2/24+O(\theta^4)\) for consistent mass. Doubling the number of intervals quarters the leading bias. Their mean cancels the leading term for this uniform constant-coefficient string. Such cancellation is a consequence of these specific expansions; on a different mesh, solve or measure the convergence order again. Checking mass orthogonality between the reported modes gives a separate test that an eigensolver has returned distinct vectors, particularly when modes approach a cluster.
Explore the related calculation with adjustable inputs. Change the parameters in the experiment on this same project page and compare its output with this part of the derivation.
Measure the usable part of a spectrum
The experiment plots the two percentage errors against mode number over the actual discrete spectrum. Move the interval count while keeping track of mode 4. Look for a mode with about 1% frequency error and estimate how many points per wavelength the mesh must supply. The optional blended mass \(M_\alpha=(1-\alpha)M_L+\alpha M_C\) gives another quantitative test of the asymptotic cancellation. Blending mass matrices differs from averaging the two eigenfrequencies at finite \(h\).
Predict a dispersion-cancelling blend
Expand the blended mass multiplier and find the value of \(\alpha\) cancelling the leading smooth-mode frequency error. Why can it still give misleading high harmonics?
Work through the solution
The mass multiplier divided by \(\rho h\) is
Its inverse square root contributes \(+\alpha\theta^2/12\) to the frequency ratio. Multiplying by the lumped sine ratio gives leading coefficient \((2\alpha-1)/24\), which vanishes at \(\alpha=1/2\). At eight intervals mode 4 has a blended frequency \(180.06/\sqrt{5/6}=197.25\) Hz. The improvement is substantial but finite. As the mode approaches the grid scale, the discarded higher powers of \(\theta\) cease to be small; exact solution of the blended pencil cannot restore a sub-element waveform.
Explore the related calculation with adjustable inputs. Change the parameters in the experiment on this same project page and compare its output with this part of the derivation.
Further reading
Notebook practice · Counting vibration modes without calculating their shapes
Matrix computations and spectral accuracy
Trace how algebraic structure, representation and numerical precision affect the solution of linear problems. Verify each conclusion with an independent diagnostic.
- When stable eigenvalues allow large transient growth
Two damped states exchange energy in only one direction. Its eigenvalues predict ultimate decay, while a short-time response can grow by a large factor. Compute the matrix exponential, its gain and a resolvent-based sensitivity check.
- How a random sketch finds a dominant subspace
An instrument returns a matrix too large to factor densely but cheap enough to multiply by a few vectors. Build a low-rank approximation by probing its range, explain what a random draw can miss and design a residual check using fresh probes.
- Solve a singular network without inventing a ground current
A floating resistor network has unique voltage drops but no absolute voltage reference. Derive its nullspace, test charge balance, and distinguish adding a computational gauge from changing the physical boundary conditions.
- Refitting a sensor as observations arrive or disappear
A calibration line receives one new observation at a time. Update its least-squares factorisation using rotations, quantify the influence of a deleted observation and detect when removing a sample destroys identifiability.
- Which resistor can carry its current through another path?
A short circuit diagram leads to a matrix that describes both voltage differences and sensitivity to losing an edge. Change one conductance and follow where the current goes.
- How a computer can lose a sensor direction
Two sensors report almost the same quantity. Trace a perturbation through orthogonalisation, a Gram matrix and a rectangular SVD, then decide which computed digits the data support.
- Recovering a spectrum from three-term recurrences
A large vibrating system supplies products with its stiffness operator. Derive the short recurrence implied by symmetry and use a residual and a moment test to interpret its small projected spectrum.
Matrix computations and spectral accuracy · 1. When stable eigenvalues allow large transient growth
Two damped states exchange energy in only one direction. Its eigenvalues predict ultimate decay, while a short-time response can grow by a large factor. Compute the matrix exponential, its gain and a resolvent-based sensitivity check.
Solve the evolution one component at a time
Consider dimensionless time \(t\) and state \(x=(x_1,x_2)^T\) with \(\dot x=Ax\), \(A=\left(\begin{smallmatrix}-1&K\\0&-2\end{smallmatrix}\right)\), for real \(K\ge0\). The second component decays independently; its transient drives the first. A physical example is a linearised pair of relaxation processes with one readout feeding another. Choose state units so the Euclidean norm represents the amplification of interest. If the coordinates measure unrelated quantities such as volts and kelvins, the unweighted norm changes if one simply changes units. A physical energy or covariance supplies a more appropriate weighted norm.
Starting from \(x(0)=(u,v)\), integrate the second row to find
The first row obeys \((e^t x_1)'=K e^{-t}v\), hence
Both eigenvalues are negative and the whole matrix exponential tends to zero. Yet for \(v=1,u=0\) the driven component reaches \(K/4\) at \(t=\ln2\), since \(e^{-t}-e^{-2t}\) is maximal there. With \(K=12\), the state at this instant is \((3,0.25)\) and its norm is 3.010. This is a lower bound on the maximum possible gain over unit input vectors and on the maximum over all times. The peak of the driven component need not coincide exactly with the peak of the total norm.
Find the input that grows most at a chosen time
For \(M=e^{tA}\), the squared output norm is \(x_0^TM^TMx_0\). Its maximum over unit vectors is the largest eigenvalue of \(M^TM\), hence the gain is the largest singular value of \(M\). For the triangular matrix above denote its entries by \(a,b,d\) on the first diagonal, off-diagonal and second diagonal. The characteristic polynomial of \(M^TM\) has trace \(s=a^2+b^2+d^2\) and determinant \(a^2d^2\). Its larger eigenvalue is \([s+\sqrt{s^2-4a^2d^2}]/2\). This direct formula lets a simulation compare a specified initial condition with the optimal combination at each time. The optimal right singular vector varies with time; a plot of the optimal curve is an envelope of different preparations.
Another test asks whether any instantaneous squared norm can increase at \(t=0\). Its derivative is \(x_0^T(A^T+A)x_0\). The largest eigenvalue of the symmetric part \(H=(A+A^T)/2\) is \((-3+\sqrt{1+K^2})/2\). It is positive precisely when \(K>\sqrt8\). If \(H\) is negative semidefinite every instantaneous state has a nonpositive norm derivative and the Euclidean semigroup is contractive. This criterion concerns energy growth in a specified norm and is distinct from asymptotic stability. At \(K=12\) the eigenvector of \(H\) giving fastest initial growth is also not generally the input giving largest long-time response.
Link a small singular value to sensitivity of eigenvalues
For \(z\) away from either eigenvalue, direct triangular inversion gives an off-diagonal resolvent entry \(K/[(z+1)(z+2)]\). Even at complex points visibly far from the eigenvalues the resolvent norm can be large. To see what that means, let \(\sigma_{\min}(zI-A)=\varepsilon\) with unit right and left singular vectors \(v,u\). Then \((zI-A)v=\varepsilon u\). The rank-one perturbation \(E=\varepsilon u v^*\) makes \((A+E)v=zv\), while its spectral norm is precisely \(\varepsilon\). Conversely any perturbation moving an eigenvalue to \(z\) must have norm at least \(\sigma_{\min}\). Therefore a contour of \(1/\|(zI-A)^{-1}\|\) maps the perturbation required for an eigenvalue there. This is the pseudospectrum construction. Physical perturbations may have additional sparsity or sign constraints, so unstructured contours describe the allowed full matrix perturbations of the stated norm.
Compare one preparation with the worst-case envelope
The experiment evaluates the exact triangular evolution and the largest singular value at each time. Change the coupling first, then rotate the unit initial input. At zero coupling both state components decay. At \(K=12\) with initial excitation only in the second coordinate the output norm exceeds three before decaying. Explain why the envelope can exceed every single displayed preparation at different times and why changing the input does not alter either eigenvalue.
How a detector can miss the strongest transient
The apparatus often measures a scalar trace \(y=c^Tx\). With preparation \(x(0)=(0,1)^T\) and a detector aligned with the first coordinate, \(y=K(e^{-t}-e^{-2t})\). A detector aligned with the second coordinate instead records \(e^{-2t}\), whose graph decreases immediately. Rotating the detector leaves the evolution untouched. At \(t=\ln 2\) and \(K=12\), two orthogonal recordings therefore give \(3\) and \(0.25\). Their sum of squares recovers \(9.0625\), so their joint norm reproduces the transient concealed in the second recording alone.
Given an input direction \(b\) and a detector \(c\), the measurable input-to-output amplitude is \(c^Te^{tA}b\). The optimal detector for that input is parallel to \(e^{tA}b\) by Cauchy–Schwarz. Maximising also over the preparation recovers the singular-value experiment above. Thus a discrepancy between a large theoretical bound and a small experimental trace can arise from either the excitation or the readout. An experiment that rotates only one of them cannot by itself test the unrestricted bound.
Tutorial · verify three distinct amplification diagnostics
Find the exact growth at one time
With \(K=8\), compare the driven component for input \((0,1)\) and the maximum Euclidean gain at \(t=\ln2\).
Work through the solution
The matrix entries are
The specified input gives norm \(\sqrt{4.0625}=2.016\); the driven component itself is 2. The optimum follows from \(s=4.3125\) and \(a^2d^2=0.015625\), giving gain about 2.076. Selecting the unit right singular vector of the larger eigenvalue attains it. A direct check is to rotate a unit input around the circle and find the maximum by sampling increasingly fine angles.
Construct a structured perturbation placing an eigenvalue at zero
Keep both diagonal entries fixed and alter only \(A_{21}\) by \(\delta\). Determine the value needed for a zero eigenvalue and compare it with changing only a diagonal entry.
Work through the solution
The determinant becomes \(2-K\delta\). Thus \(\delta=2/K\), or \(1/6\) for \(K=12\). Changing only the first diagonal entry would require a shift of one, and changing only the second a shift of two. The smaller lower-left change closes a positive feedback loop. It need not be the smallest unrestricted spectral-norm perturbation, which is obtained from the singular value of \(-A\), but it explicitly demonstrates which physical feedback is implicated.
Decide which conclusion survives nondimensionalisation
Replace the coordinates by \(y=(x_1/10,x_2)\). How do the eigenvalues, coupling and interpretation of a Euclidean gain change?
Work through the solution
The similar matrix \(DAD^{-1}\), with \(D=\operatorname{diag}(0.1,1)\), has diagonal entries \(-1,-2\) and off-diagonal \(K/10\). The dynamics represent the same trajectories in different units; the eigenvalues agree. The bare Euclidean norm in \(y\) now downweights the original first component, so it can show much less gain. To recover the original norm use \(y^T D^{-T}D^{-1}y\). A statement about growth must name the norm and scales, especially when assessing whether a stable numerical model can amplify perturbations beyond a physical tolerance.
Further reading
Matrix computations and spectral accuracy · 2. How a random sketch finds a dominant subspace
An instrument returns a matrix too large to factor densely but cheap enough to multiply by a few vectors. Build a low-rank approximation by probing its range, explain what a random draw can miss and design a residual check using fresh probes.
Start with the approximation that would be best if its subspace were known
Let \(A\) be an \(m\times n\) real data matrix. It can represent a collection of spatial snapshots, one per column. A reduced rank-\(k\) model stores \(k\) spatial patterns and a small coefficient matrix. If a matrix \(Q\) has orthonormal columns spanning a proposed range, then the closest approximation with columns in that range in Frobenius norm is \(QQ^TA\): each snapshot is independently orthogonally projected. Store \(B=Q^TA\); its singular-value decomposition is small when \(Q\) has relatively few columns. The distinction between finding the subspace and factoring within it is important. A perfect small SVD cannot recover a spatial direction missing from \(Q\).
If \(A=U\Sigma V^T\) is exactly rank \(k\), choose \(n\times k\) test matrix \(\Omega\) and form \(Y=A\Omega=U_k\Sigma_k V_k^T\Omega\). If the last \(k\times k\) factor is invertible, \(Y\) spans exactly the range of \(A\). Independent Gaussian columns make singularity a zero-probability event in exact arithmetic, because the rotated coefficients are again a continuous Gaussian matrix. This statement does not imply every draw has a well-conditioned factor, nor that a single probe spans every near-rank-\(k\) matrix. Orthogonalising \(Y\) with a numerically reliable QR yields the candidate basis \(Q\).
Derive the effect of gap and starting alignment
Consider rank reduction of \(A=\operatorname{diag}(10,1)\) with one unit probe \(\omega=(\cos\theta,\sin\theta)\). Its image is \((10\cos\theta,\sin\theta)\), so the angle \(\phi\) between the sampled direction and dominant left singular vector obeys \(\tan\phi=\tan\theta/10\) whenever \(\cos\theta\ne0\). A typical mixed direction is pulled toward the dominant range. A nearly perpendicular probe can still give a poor direction even with a substantial singular gap. For \(\theta=45^\circ\), \(\tan\phi=0.1\). The residual \((I-qq^T)A\) has only one nonzero singular value because its left range is one-dimensional. With \(q=(\cos\phi,\sin\phi)\), its norm squared is \(100\sin^2\phi+\cos^2\phi\), giving \(\sqrt{200/101}=1.407\). The optimal rank-one error is the discarded singular value 1.
One power step forms \(Y=(AA^T)A\Omega\), raising singular values to the third power in the sampled direction while the approximation is still formed for the original \(A\). The angle ratio shrinks to \(\tan\theta/1000\); the residual norm is then about 1.00005 for the same \(45^\circ\) probe. Additional steps require more passes over data. In finite precision reorthogonalise between multiplications so weak required directions are not erased by a large gap. If the target includes both leading and moderate directions, blindly powering a block without intermediate QR can make the very reduced subspace one wants numerically rank deficient.
Independently test an approximation after building it
Add \(p\) extra columns to \(\Omega\) to reduce the chance of poorly exciting a dominant combination. An oversampled \(Q\) has \(k+p\) columns; project to \(B=Q^TA\), take its dominant \(k\) small left singular vectors and map them back through \(Q\). For an exactly rank-\(k\) input the extra columns need appropriate numerical rank handling. In the nearly low-rank case they provide room to represent part of the tail and improve the final cut. Cost depends on access: computing \(A^TQ\) or performing every additional power pass can dominate on streamed or distributed data, even though the final dense SVD is tiny.
Freeze the fitted approximation \(\tilde A\) and consider an independent random sign vector \(g\) with entries equally likely \(\pm1\). Write \(R=A-\tilde A\). Since \(\mathbb E[gg^T]=I\),
Multiple independent checks estimate residual energy and its sampling spread without explicitly assembling \(R\). This estimates Frobenius norm squared; the maximum directional error is a different objective. A single small response does not certify a small spectral norm or guarantee missed directions are unimportant to a particular downstream measurement. Test the physically relevant load or measurement directions as well.
Background · Why must the test vector be independent of the sketch?
Build the sampled range \(Q\) by orthogonalising \(A\Omega\). With exact arithmetic every sampled column already lies in the range of \(Q\). Applying the residual to those same vectors gives
For example, one column sampled from the two-dimensional identity spans only a line. It reconstructs its own training vector exactly while the unit vector perpendicular to it has error one. A fresh isotropic probe has, on average, nonzero energy in every missing direction. For a standard Gaussian vector \(g\) independent of \(Q\), the mean squared diagnostic is \(\mathbb E\|Rg\|^2=\|R\|_F^2\), with \(R=(I-QQ^T)A\). This identity follows by expanding \(g^TR^TRg\) and using \(\mathbb E[gg^T]=I\). One draw is still a noisy diagnostic, especially when only a single direction is missing.
Which starting direction defeats a random range probe?
For a diagonal matrix with singular values 1 and r, rotate a test vector through the dominant right singular direction. Each power iteration multiplies the tangent of its output angle by r². Set r to 0.45, compare zero and two iterations, then inspect the exactly orthogonal probe at 90°. Explain why its residual stays at one.
Tutorial · check an apparently good random approximation
Identify a failure when the test vector is reused
A matrix \(A\) is approximated by the orthogonal projection onto the range of \(A\Omega\). You test residuals only on the original columns of \(\Omega\) and find zeros. What does this certify?
Work through the solution
By construction \(QQ^TA\Omega=A\Omega\), up to roundoff if the full sampled range was kept. Thus the test is nearly tautological and does not measure error on independent directions. If \(\Omega\) has a missing dominant right singular direction, all these residuals can vanish while the leading reconstruction is poor. Use fresh random probes and targeted physical snapshots held out during fitting. If a final rank truncation is applied within \(Q\), the original probe residual need no longer vanish exactly but remains dependent on the fitted subspace.
Calculate a deliberately poor draw
Use \(A=\operatorname{diag}(10,1)\) and \(\tan\theta=100\). Compare the one-pass angle and residual with one power iteration.
Work through the solution
Initially \(\tan\phi=10\), so \(\sin^2\phi=100/101\) and the residual norm squared is \((10000+1)/101\), giving about 9.95. With one power step \(\tan\phi=0.10\), giving 1.407 instead. The bad starting direction had a small but nonzero overlap, so powering can recover it. An exactly perpendicular deterministic probe remains perpendicular after every power step. Oversampling adds independent opportunities to see a missed direction.
Design a stopping criterion for snapshot energies
Independent residual probes give squared norms \(1.0,1.4,0.8,1.6,1.2\) in scaled energy units, while independently known \(\|A\|_F^2=100\). Estimate the residual energy fraction and its sampling uncertainty. Does it imply a 1.2% relative error on every snapshot?
Work through the solution
The sample mean is 1.2 and sample standard deviation \(\sqrt{0.10}=0.316\), so the standard error is about 0.141 for independent probes. The estimated fraction of total squared Frobenius norm is \(1.20\%\), with approximate standard error 0.14 percentage points. The relative Frobenius norm itself is about \(\sqrt{0.012}=0.110\). Individual snapshots may fare much better or worse; the tests estimate a global aggregate. Five samples give only a rough uncertainty estimate, particularly if residual energy is concentrated in a few directions.
Further reading
Matrix computations and spectral accuracy · 3. Solve a singular network without inventing a ground current
A floating resistor network has unique voltage drops but no absolute voltage reference. Derive its nullspace, test charge balance, and distinguish adding a computational gauge from changing the physical boundary conditions.
Build the conductance matrix as an energy Hessian
Orient each of the \(m\) connections of a connected graph and form an incidence matrix \(B\) with one row per edge, containing \(+1\) at its upstream node and \(-1\) at its downstream node. For node voltages \(v\), differences \(Bv\) determine currents \(i_e=g_e(Bv)_e\) in edges of conductance \(g_e>0\). Conservation at nodes reads \(B^Ti=b\), where externally injected currents \(b\) are positive into the network. Eliminating edge currents yields \(Lv=b,\ L=B^TGB\) with \(G=\operatorname{diag}(g_e)\). Reversing an edge changes a row of \(B\) and its current sign together; \(L\) and physical voltage predictions are invariant.
The identity \(v^TLv=\sum_e g_e(v_i-v_j)^2\ge0\) gives the nullspace directly. Equality forces equal voltage along each edge and hence constant voltage on a connected graph. Thus \(\ker L=\operatorname{span}\{\mathbf1\}\) and its range is \(\mathbf1^\perp\). A solution exists exactly when total injection is zero. On a graph with disconnected components the current sum must vanish separately on each component; one global cancellation can hide two incompatible islands. This is a compatibility condition on the physical data, distinct from the gauge freedom that persists for already compatible data.
Compare grounding, projection and a bordered solve
If \(b\) is compatible, choosing one node potential as zero removes one variable and one redundant conservation equation. The remaining principal submatrix is positive definite because a zero-energy vector extending with zero at the reference must vanish everywhere. An alternative chooses mean-zero voltage without favouring one node. Introduce a Lagrange multiplier \(\lambda\) and solve
The last equation fixes the gauge. Multiplying the first block by \(\mathbf1^T\) gives
For consistent data \(\lambda=0\), so the bordered solution satisfies the original equations exactly and is the Moore–Penrose minimum-norm solution. For inconsistent data the solver effectively removes a uniform current \(\lambda\) from every node. This may be sensible as a least-squares projection under an explicitly chosen equal-error model, but it is not the same physical network as a returning current concentrated at an actual external lead. Retain and interpret the multiplier.
Another formulation works directly in the zero-mean subspace with projector \(P=I-\mathbf1\mathbf1^T/n\). Iterative methods can project the right side and reproject iterates to remove accumulated constant drift. A preconditioner must preserve the intended subspace or be followed by the appropriate projection. The gauge-invariant observable \(v_i-v_j\) is always preferable for comparing solvers with different references. Comparing raw voltages node by node can report a large error between mathematically equivalent physical solutions. A separate edge-current balance and dissipated power check validate more than one reference-dependent vector residual.
Verify a triangle by current conservation and work
Connect nodes 1–2 and 2–3 with 1 S each, and 1–3 with 0.5 S. Inject 1 A at node 1 and remove it at node 3. The direct branch has 2 Ω and the two-edge indirect branch also totals 2 Ω, so 0.5 A flows along each path. The terminal difference is 1 V. Taking \(v_3=0\) gives \(v=(1,0.5,0)\) V, while subtracting their mean yields \((0.5,0,-0.5)\) V. Both produce Joule power \(2(0.5^2/1)+(0.5^2/0.5)=1\) W. The terminal injection work is \(b^Tv=1\) W in either gauge because the sum of \(b\) vanishes.
A guard against concealed modelling error is to solve first with all conservation rows, reporting the incompatible component of \(b\); only then introduce the intended reference. If measured injected currents are \(1.00,0,-0.97\) A and node 3 is grounded by deleting its equation, the computed branch currents imply that node 3 actually returns 1.00 A. The measured 0.03 A mismatch is thereby absorbed entirely by the chosen reference. The bordered projection instead distributes 0.01 A equally among the nodes. A calibrated return-lead model or a covariance-weighted correction can choose between such interpretations. A small residual after row deletion alone cannot tell whether the three measured currents were physically consistent.
What changes when a floating voltmeter is re-zeroed?
Connect three nodes by a triangle. The 1–3 and 2–3 conductances are each 1 S. Inject the selected current at node 1 and remove it at node 3. The graph sweeps a common reference-voltage shift. Use the oriented drop across branch 1–2 to predict its current, then compare the total injected power with the displayed dissipation.
The downloadable OneSimulation circuit solves the three resistors and current source twice, choosing a different reference node. The two absolute voltage reports change. Their branch drops must agree.
Tutorial · audit gauges, disconnected graphs and sensitivities
Find an effective resistance without choosing a reference
For connected \(L\), point injection pair \(b=I(e_a-e_b)\) and minimum-norm inverse \(L^+\), derive the effective resistance and verify its sign.
Work through the solution
The gauge-fixed solution is \(v=L^+b\), so terminal voltage divided by \(I\) is \(R=(e_a-e_b)^TL^+(e_a-e_b)\). Positive definiteness on the zero-sum subspace gives nonnegative \(R\), strictly positive for distinct connected nodes. In the example it is 1 Ω, independently confirmed by the parallel branches. Summing injected power \(I^2R\) matches edge dissipation.
Determine how much one connection is worth
What is the first derivative of the triangle's effective resistance with respect to the direct conductance? Compare a prediction for raising it by 0.01 S with a direct circuit reduction.
Work through the solution
For unit injection, differentiating \(Lv=b\) on the fixed gauge subspace gives
A single conductance change has \(dL=(e_i-e_j)(e_i-e_j)^Tdg\), so
The direct drop is 1 V per ampere, giving \(-1\) in compatible units. Prediction is \(R\simeq0.990\) Ω; exact parallel conductance becomes 1.01 S, so \(R=0.99010\) Ω. A positive conductance increment cannot increase effective resistance here.
Diagnose an island and an unobservable offset
Remove every link between two internally connected components carrying net injections \(+0.10,-0.10\) A. Is one ground constraint enough? What if both component sums are corrected to zero?
Work through the solution
The disconnected graph has two independent constant null vectors, one per component. Although the total current is zero, both component compatibility tests fail. No voltage gauge can make the missing inter-island return path appear. If both sums become zero, two independent gauge constraints still remain necessary for unique node voltages. Potential differences within either component are uniquely determined; differences across the two floating components remain arbitrary unless a physical reference or coupling is introduced.
Further reading
Matrix computations and spectral accuracy · 4. Refitting a sensor as observations arrive or disappear
A calibration line receives one new observation at a time. Update its least-squares factorisation using rotations, quantify the influence of a deleted observation and detect when removing a sample destroys identifiability.
Rotate away a new observation while preserving the objective
Suppose \(A\) has full column rank \(p\), observations \(b\), and an orthogonal factorisation has already transformed the upper part of the problem into \(Rx=z\) with upper-triangular \(R\). Lower transformed rows carry residuals but no coefficients. Because the transformations are orthogonal,
where \(s^2\) is the accumulated minimum residual sum of squares. Appending row \(a^T\) and response \(y\) requires minimising \(\|Rx-z\|^2+(a^Tx-y)^2+s^2\). One can update the small augmented triangle instead of reloading every original sample. This is particularly useful when storing raw observations is expensive and fits need refreshing repeatedly.
Write the new row directly below \([R\;z]\). At column \(j\), combine diagonal value \(r\) with bottom value \(q\) using a Givens rotation with \(c=r/\operatorname{hypot}(r,q),\ s=q/\operatorname{hypot}(r,q)\). Multiplication of the two selected rows by \(\bigl(\begin{smallmatrix}c&s\\-s&c\end{smallmatrix}\bigr)\) gives a nonnegative diagonal \(\sqrt{r^2+q^2}\) and zero in the bottom column. Apply the same rotation to every remaining column and to the right side. If both inputs vanish choose the identity and investigate numerical rank separately. A robust hypotenuse evaluation avoids overflow when \(r^2+q^2\) itself exceeds the available range even though its square root is representable.
After sweeping all \(p\) columns the bottom row is zero in coefficients and has transformed response \(\gamma\). The new triangular solve gives the updated fit and the minimum residual sum rises by \(\gamma^2\). Each step preserves a squared norm, so this identity is a direct independent audit of online accumulation. Weighted least squares fits into the same calculation by scaling the row and response by the square root of its weight first. Dynamic reweighting of historical observations is a different operation and generally requires preserved information about individual rows.
Use one-dimensional corrections for interpretation
The rank-one update also has a useful algebraic form without explicitly computing a dense inverse. Set \(G=A^TA\), \(w=G^{-1}a\) evaluated by two triangular solves with \(R\), and \(h=a^Tw\). After adding a point the normal matrix becomes \(G+aa^T\). Subtracting the old normal equations from the new ones gives \((G+aa^T)\delta x=a(y-a^Tx)\), so \(\delta x=w(y-a^Tx)/(1+h)\), since \((G+aa^T)w=(1+h)a\). The increment to residual sum of squares is \((y-a^Tx)^2/(1+h)\). This formula for diagnostics is consistent with the orthogonal update and shows explicitly how a surprising response interacts with geometric leverage.
As an example fit a line \(y=c+dt\) at times \(t=-1,0,+1\) with readings \(0,1,2\). The exact line is \(c=d=1\), with \(G=\operatorname{diag}(3,2)\). A new observation at \(t=2\) reports \(y=4\) rather than predicted 3. Here \(a=(1,2)^T\), \(w=(1/3,1)^T\), \(h=7/3\). The corrected coefficients are \(c=1.1,\ d=1.3\), and residual sum rises by \(1/(1+7/3)=0.30\). Substitution back into all four data gives residuals \(0.2,-0.1,-0.4,0.3\); their squared sum is indeed 0.30. The update has moved a previously exact historical fit because the new reading changed the estimated slope and intercept.
Distinguish a safe deletion from rank loss
For deleting a row already included in the fitted \(G\), use that row's in-sample leverage \(\ell=a^TG^{-1}a\). It lies between zero and one as a diagonal element of the orthogonal projection \(A(A^TA)^{-1}A^T\). If \(\ell<1\), the remaining-data fit changes by \(-G^{-1}a\,r/(1-\ell)\), where \(r=y-a^Tx\) is the residual while the point was present. The leave-one-out prediction residual is \(r/(1-\ell)\). A point with small in-sample residual can therefore be highly influential when nearly essential to identification. If \(\ell=1\), deletion loses rank, and a formula dividing by \(1-\ell\) is warning of a structural change. Downdating a triangular factor should use a well-conditioned dedicated downdate or refactor with rank detection when close to this boundary. Squaring a poorly conditioned design into \(G\) just for convenience can lose accuracy.
Refit the line after one influential observation
Begin with three calibration pairs on y = x at x = −1, 0 and 1. Place a fourth sensor farther from the centre and choose its deviation from the old line. Predict its training residual and the error made when the entire fourth observation is omitted. Move it farther out with a fixed nonzero offset. Which residual approaches zero and which retains the full offset? Set the offset to zero and check whether a high-leverage point must also have a large residual.
The OneSimulation model fits the full augmented observation matrix with its dense least-squares solver. Compare this independent refit with the one-row update on screen.
Tutorial · inspect an update from three angles
Perform a complete scalar QR update
Three readings of a constant have average 2 and residual sum 0.50. Add value 5 at equal weight. Find the updated average, residual increment and scalar triangle.
Work through the solution
Before appending,
With appended row 1 the new diagonal is 2. The rotated right side is \((\sqrt3/2)(2\sqrt3)+(1/2)5=5.5\), giving average 2.75. The bottom response is \((-1/2)(2\sqrt3)+(\sqrt3/2)5=1.5\sqrt3\), contributing 6.75 to sum of squares and giving new total 7.25. The mean from the raw sum is also \((6+5)/4=2.75\).
Reverse the four-point line update
For the newly appended point in the line example, infer its in-sample leverage from the original append leverage, then recover the original leave-one-out residual.
Work through the solution
Adding its own row changes leverage from \(h\) to \(\ell=h/(1+h)=0.70\), obtained by solving \((G+aa^T)^{-1}a=w/(1+h)\). Its current fitted value is \(1.1+2(1.3)=3.7\), giving residual 0.3. Dividing by \(1-\ell=0.3\) recovers the predicted deletion residual 1.0. Confusing \(h\) with \(\ell\) would incorrectly put a leverage larger than one inside a leave-one-out formula.
Detect a geometry where a zero residual is inevitable
Fit a line with many observations at \(t=0\) and exactly one at \(t=1\). Show why the latter's in-sample residual can be zero for any value and why its fit quality cannot validate the slope.
Work through the solution
All \(t=0\) samples determine the intercept by their mean. The unique nonzero time then fixes the slope to hit its own response exactly, so its residual is always zero and its in-sample leverage is one. Removing it leaves only one time coordinate and the slope unidentifiable. An extra independent observation at a distinct time, or a justified physical slope prior, is needed to test predictive slope accuracy. Increased repetitions at \(t=0\) reduce intercept noise without repairing this missing diagnostic.
Further reading
Matrix computations and spectral accuracy · 5. Which resistor can carry its current through another path?
A short circuit diagram leads to a matrix that describes both voltage differences and sensitivity to losing an edge. Change one conductance and follow where the current goes.
Ground a node and derive the electrical leverage
Nodes A, B and C form a triangular loop. Node D connects only to C. Every edge is an ideal linear resistor. Orient an edge from node \(i\) to node \(j\) and give it an incidence vector \(b_e\) with a +1 at \(i\) and a −1 at \(j\). Its current under nodal voltages \(v\) is \(g_e b_e^T v\), where conductance \(g_e\) is measured in siemens. Kirchhoff's current law sums all outgoing currents into the net injection \(f\). It gives
Adding a constant to every potential preserves all currents. Fix the potential of D at zero and remove its row and column. For a connected network the resulting grounded matrix is positive definite. Inject one ampere at one end of an edge and withdraw it at the other. With grounded coordinates the voltage difference per unit current is the effective resistance \(R_e=b_e^T L_g^{-1} b_e\). The fraction of this test current that flows through the tested edge is \(\ell_e=g_eR_e\). A bridge carries the full ampere. A parallel path reduces its share.
There is also a global check on the calculation. The sum of all the leverages is \(\mathrm{tr}(L_g^{-1}\sum_e g_e b_e b_e^T)=n-1\) on a connected graph with \(n\) nodes. Each leverage depends only on the graph and its conductances. The actual current in a specified operating condition also depends on the chosen source and sink.
Solve the triangle by hand
With 1 S on every branch, the detour A–C–B consists of two 1 Ω resistors in series. Inject 1 A at A and extract it at B. The detour's 0.5 S combines with the direct 1 S, so the measured drop is \(1/1.5=2/3\) V. The direct current is 2/3 A. The dead-end C–D branch carries zero current in this experiment. When tested between its own endpoints, however, C–D carries the entire test current. The four leverages are consequently \(2/3,2/3,2/3,1\) and sum to three.
Double A–B's conductance to 2 S. Its leverage rises to \(2/2.5=0.8\), while the voltage needed for the same 1 A drops to 0.4 V. This is why the two traces in the experiment have opposite slopes. Rerun with a weaker bridge. Its resistance increases, yet its leverage stays equal to one.
Open full-size diagram
Open full-size diagramExercise · remove the direct branch
How much does the terminal resistance rise when the 1 S direct edge is removed? What changes if the bridge is removed instead?
Work through the solution
For A and B the sole remaining connection consists of two 1 Ω resistors, so resistance rises from 2/3 Ω to 2 Ω, an increase of 4/3 Ω. Removing C–D instead isolates D. Measurements within the triangle remain finite, but a test injecting current at D and withdrawing it at C no longer has a finite DC voltage solution.
Exercise · differentiate the measured voltage
Under a fixed one-ampere A-to-B test, find the sensitivity of the terminal resistance to the direct conductance at 1 S.
Work through the solution
For variable \(g\) the resistance is \(1/(g+0.5)\). Differentiation gives \(-1/(g+0.5)^2=-4/9\) Ω/S at the chosen point. The magnitude equals the square of the voltage drop per ampere across that branch. Differentiating \(L_gv=f\) at fixed injection gives the same result for any branch, \(\partial (f^Tv)/\partial g_e=-(b_e^Tv)^2\) for the unit test.
Change parameters · Explore this notebook model
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Matrix computations and spectral accuracy · 6. How a computer can lose a sensor direction
Two sensors report almost the same quantity. Trace a perturbation through orthogonalisation, a Gram matrix and a rectangular SVD, then decide which computed digits the data support.
Subtracting a projection in finite precision
Let \(A\) be a real \(m\)-by-\(n\) matrix, with \(m\ge n\) and independent columns. The first unit vector is \(q_1=a_1/\|a_1\|_2\). To construct another, classical Gram–Schmidt computes all coefficients \(r_{ij}=q_i^Ta_j\) against the original column before subtracting the sum. Modified Gram–Schmidt instead updates a running residual \(v\) after each projection, computing the next coefficient from that residual.
In exact arithmetic the two formulas agree by orthogonality. In floating point, a component along an earlier \(q_i\) can survive subtraction. Dividing by the norm of a nearly cancelled column amplifies that component. For the three columns of the matrix with first row \((1,1,1)\) and lower block \(\delta I_3\), the difference of two original columns has size proportional to \(\delta\). Computing both of the third column's coefficients before either subtraction carries the error of previously computed directions into both coefficients. Sequential projection removes some of that contamination. A second pass projects the surviving residual again. Monitor both \(\|A-QR\|/\|A\|\) and \(\|I-Q^TQ\|\). A small first diagnostic alone permits poor orthogonality.
Why a reflector gives a backward-error result
Given nonzero \(x\), set \(v=x+\operatorname{sign}(x_1)\|x\|e_1\), using positive sign at zero. Then \(H=I-2vv^T/(v^Tv)\) is orthogonal and \(Hx\) has only its first entry nonzero. The sign ensures the construction of \(v_1\) adds magnitudes. Assume normal-range floating-point arithmetic with unit roundoff \(u\) and \(mu\ll1\). A length-\(m\) dot product has absolute error bounded by \(\gamma_m |v|^T|x|\), with \(\gamma_m=mu/(1-mu)\), by multiplying the factors \(1+\delta_i\), \(|\delta_i|\le u\), along the sum. Cauchy–Schwarz bounds this by \(\gamma_m\|v\|\|x\|\).
Apply a stored, normalised reflector as a dot product and an axpy. Each column incurs a perturbation of order \(mu\) times its norm, including normalisation error. The exact reflector for the stored direction has norm one. Pull each local error backwards through the preceding exact orthogonal transformations and add. In Frobenius norm this yields
where \(C\) accommodates the implementation's fixed number of elementary operations. This explains the nature of the bound without claiming an implementation-independent sharp constant. A tiny singular value may still have large relative uncertainty under this absolute perturbation.
Turn a rectangular matrix into a bidiagonal one
Apply a left reflector to column 1 and a right reflector to row 1, starting its operation in column 2. Repeat on the trailing block. Each transformation preserves earlier zeros. This yields \(A=UBV^T\) with orthogonal factors and upper bidiagonal \(B\). As a concrete first step take rows \((3,0),(4,5),(0,12)\). Multiplying the first two rows by the rotation with rows \((3/5,4/5),(-4/5,3/5)\) leaves rows \((5,4),(0,3),(0,12)\). A second left rotation combines \(3,12\), giving diagonal entries \(5,\sqrt{153}\) and superdiagonal \(4\). Two columns make the right step trivial here. A third column would require eliminating the new first row's tail.
For a bidiagonal matrix one can carry out shifted QR on \(B^TB\) implicitly. If the first diagonal and off-diagonal entries of that tridiagonal matrix are \(a,b\), select a right rotation from \((a-\mu,b)\). Applying it to \(B\) introduces a subdiagonal entry. A left rotation eliminates that entry and moves the disturbance to the next column pair. Repeat to the bottom and accumulate both sets of rotations. Vanishing superdiagonals split independent blocks. This obtains singular values without explicitly storing an already rounded Gram matrix. For two almost parallel sensor columns \((1,\delta,0)^T,(1,-\delta,0)^T\) the singular values are \(\sqrt2,\sqrt2|\delta|\). The entries \(1\pm\delta^2\) of the Gram matrix can round to the same number.
OneSimulation experiment · Resolve the smaller singular value
Change the separation grid. Which lost singular value can a direct SVD still measure?
Download the executable notebook · Python source
Adjust the experiment in the browser. Move the selected separation across the loss threshold and switch between binary32 and binary64 arithmetic. The Gram estimate evaluates the rounded difference \((1+\delta^2)-(1-\delta^2)\); the stable comparison uses the exact orthogonality of the two nonzero rows. It is an analytic benchmark, while the notebook below runs the rectangular SVD and OneSimulation eigenvalue solver. Locate the threshold near \(\delta\sim\sqrt{u}\), then explain why changing arithmetic precision cannot recover information already lost in noisy measurements.
"""Measure loss of the weaker of two almost parallel sensor directions."""
import matplotlib.pyplot as plt
import numpy as np
from onesim.numerics.linear.matrices.dense_linear_algebra import symmetric_eigenvalues
separations = np.logspace(-12, -2, 31)
direct, normal = [], []
for delta in separations:
matrix = np.array([[1.0, 1.0], [delta, -delta], [0.0, 0.0]])
reference = np.sqrt(2.0) * delta
direct.append(np.linalg.svd(matrix, compute_uv=False)[-1] / reference)
smallest = symmetric_eigenvalues(matrix.T @ matrix)[0]
normal.append(np.sqrt(max(smallest, 0.0)) / reference)
assert np.allclose(direct, 1.0)
assert normal[0] == 0.0
print(f"At delta={separations[0]:.0e}: direct/reference={direct[0]:.3f}, Gram/reference={normal[0]:.3f}")
fig, ax = plt.subplots(figsize=(7, 4), layout="constrained")
ax.semilogx(separations, direct, label="Direct rectangular SVD")
ax.semilogx(separations, normal, "o-", ms=3, label="Eigenvalues of the Gram matrix")
ax.set(xlabel="Separation of sensor directions, δ", ylabel="Estimated / exact small singular value")
ax.legend()
fig.savefig("numerics-small-singular-value.png", dpi=170)
Output from the reference run
At delta=1e-12: direct/reference=1.000, Gram/reference=0.000

Tutorial on orientation and detectability
Reconstruct the product for the bidiagonal example
Work through the solution
The trace of \(B^TB\) is \(25+16+153=194\), equal to the sum of squares of the six input entries. Its determinant is \(25(153)=3825\). Trace and determinant determine the two squared singular values independently.
Predict a failure threshold and compare two noise sources
Work through the solution
When \(\delta^2\) is of order \(u\), rounding an explicitly formed Gram matrix threatens its weaker eigenvalue. Perturbations in the original data of norm \(10^{-5}\) already permit errors of that size in singular values by the variational characterisation. A stable algorithm cannot certify a sensor separation much smaller than instrument uncertainty.
Matrix computations and spectral accuracy · 7. Recovering a spectrum from three-term recurrences
A large vibrating system supplies products with its stiffness operator. Derive the short recurrence implied by symmetry and use a residual and a moment test to interpret its small projected spectrum.
Let symmetry remove old directions
Assume \(A=A^T\), choose \(\|q_1\|=1\), and initialise \(\beta_0=0,q_0=0\). Arnoldi projects \(Aq_j\) against every available basis vector. For \(i<j-1\), \(Aq_i\) already lies in the span through \(q_{i+1}\), so \(q_i^TAq_j=(Aq_i)^Tq_j=0\). For \(i=j-1\) the product is the previously computed \(\beta_{j-1}\). Thus the only new diagonal coefficient is \(\alpha_j=q_j^TAq_j\).
A zero \(\beta_j\) signals an invariant subspace in exact arithmetic. Stacking the identities gives \(AQ_k=Q_kT_k+\beta_k q_{k+1}e_k^T\) where \(T_k\) is real symmetric tridiagonal. A normalised eigenpair \((\theta,z)\) of \(T_k\) gives a Ritz vector \(Q_kz\) and residual norm \(\beta_k|z_k|\). In an eigenbasis of \(A\), that residual is at least the distance from \(\theta\) to the nearest eigenvalue. To bound an angle to a particular eigenvector also separate its eigenvalue from its neighbours.
Read the first two measurements
Use \(A=\operatorname{diag}(1,2,4)\) and \(q_1=(1,1,1)^T/\sqrt3\). Direct averaging gives \(\alpha_1=7/3\) and \(\beta_1=\sqrt{14}/3\). The second direction is \((-4,-1,5)^T/\sqrt{42}\), giving \(\alpha_2=59/21\). The projected pair captures only part of the original three-dimensional spectrum. The first quadrature node \(7/3\) already gives the exact weighted average \(q_1^TAq_1\), while its square misses \(q_1^TA^2q_1=7\) by \(14/9\), exactly \(\beta_1^2\).
More generally, \(q_1^Tf(A)q_1\) integrates \(f\) against masses \(|v_i^Tq_1|^2\) at the eigenvalues. For degrees up to \(2k-1\), paths through the tridiagonal recurrence cannot step outside the first \(k\) directions and return to the first one in time. Hence
This is the Gauss quadrature rule for that spectral measure. It also explains why a mode orthogonal to the starting vector remains invisible regardless of the iteration count.
Why can a computed tridiagonal matrix contain a duplicate mode?
A rounding perturbation can reintroduce a converged eigendirection into later vectors. The three-term recurrence removes only the last two components explicitly. The reintroduced component can grow until a second Ritz vector reports the old mode. Monitor the Gram matrix of stored basis vectors and residuals in the original space. Selective or full reorthogonalisation trades extra products and storage for independent directions.

Tutorial on invisible modes and misleading accuracy
Start from a different vector for the same operator
Work through the solution
With \(q_1=(1,0,0)^T\), the first residual vanishes. The one-node quadrature is exact for every polynomial for this particular observation, despite both eigenvalues 2 and 4 remaining undetected.
Derive the quadrature weights for a two-mode experiment
Work through the solution
With equal projections on two distinct eigenvectors, the measure has two masses of one half. The first recurrence coefficient is their arithmetic mean and the first off-diagonal coefficient is half their absolute difference. The second diagonal equals the first. Diagonalising that two-by-two matrix returns both eigenvalues and weights without prior knowledge of the modes.
Trefethen and Bau · Krylov projections and spectral quadrature
Change parameters · Recovering a spectrum from three-term recurrences
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Operators derived from a physical balance
Construct the matrix of a constrained network, a mechanical mode or a spatial field. Determine its nullspace, symmetry and natural inner product before choosing a factorisation.
- How a continuum balance becomes a finite-element stiffness matrix
- Finding a displacement when no load acts in its direction
- Coupled oscillators and normal coordinates
- Estimating a cantilever frequency from energy
- Incompressibility and discrete pressure modes
- Pure flux boundaries, compatibility and the missing constant
- Why two finite-element wave solvers propagate the same mode at different speeds
- A converged field solver can still give the wrong voltage
- Measure tunnelling from a four-site spectrum
- How many lattice sites remember the colour of a neighbour?
Ill conditioning and information
Inspect the small singular directions in actual observation operators. Distinguish a good residual from a well-determined physical parameter.
- Weighted least squares and residual diagnostics
- Singular systems and the amplification of noise
- Regularisation, resolution and the price of stability
- Adjoint gradients through a forward solver
- Choosing regularisation when the true answer is hidden
- How model error masquerades as a fitted physical parameter
- Capacitance matrices, floating nodes and controlled approximation bounds
- Reconstructing a source from noisy voltage measurements
- Which part of a sample changes a four-electrode impedance measurement?
- Scattering from a central potential and what angular data can recover
Applied study
Separate residual, solution error and conditioning when solving linear systems.
Can a small residual hide a large error?
After discretising steady heat conduction, the unknown nodal temperatures form a vector \(x\). Heat balance at the nodes gives \(Ax=b\). Substitute an approximate solution \(\hat x\) back into this equation. The mismatch \(r=b-A\hat x\) is the residual. The temperature error \(e=x-\hat x\) satisfies \(Ae=r\). Even an exactly evaluated residual still has to pass through \(A^{-1}\) to tell us about temperature.
For nonsingular \(A\), the Euclidean norm gives
Since \(\|b\|_2\leq\|A\|_2\|x\|_2\), a nonzero right-hand side gives
The condition number measures how strongly a problem can amplify a relative perturbation. The bound covers the worst direction. An error in a different direction may have a much smaller amplification.
Work through a poorly resolved direction
Take \(A=\operatorname{diag}(1,10^{-4})\), \(b=(1,10^{-4})^T\). The exact solution is \((1,1)^T\). The trial vector \((1,0)^T\) gives a residual of magnitude \(10^{-4}\), nearly \(10^{-4}\) relative to \(b\). Yet one component is missing altogether and the relative solution error is
Along the second coordinate, multiplying by \(A\) suppresses an error by a factor of ten thousand.
Scale the second equation by \(10^4\). The exact solution stays the same and the scaled matrix is the identity. The new residual of the same trial vector is \((0,1)^T\). Always say which system and norm a reported stopping test uses. Temperature differences from a direct solve on a small mesh provide an independent check in physical units.
Choose an iteration from the matrix structure
For a symmetric positive definite matrix, solving \(Ax=b\) minimises the strictly convex quadratic \(J(x)=x^TAx/2-b^Tx\). Its negative gradient at \(\hat x\) is \(r\). Conjugate gradients (CG) searches in the span of \(r_0,Ar_0,\ldots\), using search directions orthogonal in the \(A\)-inner product. It minimises the energy error \(\|e\|_A=\sqrt{e^TAe}\) over the growing trial space.
In exact arithmetic CG terminates in at most as many iterations as there are distinct eigenvalues. A positive definite preconditioner \(M\) seeks a more favourable spectrum for \(M^{-1/2}AM^{-1/2}\). For a moderate problem a direct factorisation gives a convenient reference. Both methods solve a discrete system, whose mesh error persists even when the algebraic equations are solved to roundoff.
Problem class
Set a defensible tolerance
A condition estimate bounds \(\kappa_2(A)\) by 5000. How small should the relative residual be to guarantee relative solution error at most 1%? If the solver reports \(10^{-5}\), what can you conclude?
Show the calculation
Require \(5000\|r\|/\|b\|\leq0.01\), or a relative residual at most \(2\times10^{-6}\). A residual of \(10^{-5}\) guarantees at most 5%. The actual error can still be below 1% because the bound may be loose.
Check whether CG applies
Consider two interior temperatures in a uniform line with fixed ends. Their matrix, up to a positive factor, is \(A=\left(\begin{smallmatrix}2&-1\\-1&2\end{smallmatrix}\right)\). Identify its two modes, condition number and maximum number of exact-arithmetic CG steps.
Show the calculation
Multiplication gives eigenvalues 1 for \((1,1)^T\) and 3 for \((1,-1)^T\). Both are positive, and the matrix is symmetric. Thus \(\kappa_2=3\) and two search directions suffice. The alternating mode has a larger stiffness because the temperature changes more sharply between neighbours.
OneSimulation laboratory
Separate algebraic error from mesh error
Compare recorded OneSimulation runs on this page. To test your own inputs, download the Python model and run the model in an activated OneSimulation environment.
A unit cube has conductivity 1 W/(m·K), uniform heating 1 W/m³ and zero temperature rise on every face. The script compares CG and a direct solver on the same trilinear finite-element mesh. Predict the effects of first refining the mesh and then relaxing only the CG tolerance. Download the Python experiment · OneSimulation linear solvers.
python linear-algebra.py
python linear-algebra.py --cells 10
python linear-algebra.py --cells 10 --rtol 0.05
| Cells per axis, CG tolerance | Direct peak (K) | CG peak (K) | Max. difference (K) |
|---|---|---|---|
| 5, 10⁻¹⁰ | 0.05483074 | 0.05483074 | 2.8 × 10⁻¹⁷ |
| 10, 10⁻¹⁰ | 0.05708900 | 0.05708900 | 3.6 × 10⁻¹³ |
| 10, 0.05 | 0.05708900 | 0.05620782 | 8.8 × 10⁻⁴ |

The refined mesh includes the cube centre as a node, whereas the five-cell mesh samples the peak off-centre. The change between direct nodal maxima therefore includes a sampling effect. The final two rows use identical nodes, isolating the effect of the CG stopping test. Differences near roundoff can vary between implementations.
Change parameters · Change the laboratory inputs
Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.
Problem sheet 3 · Bound the effect of stopping a linear solve early
Notation and assumptions
Read each defining equation with its assumptions and units, then follow the link to the argument that gives the equation its meaning.
Condition number
For an invertible square matrix choose a compatible norm. Conditioning describes data sensitivity, while stability refers to the algorithm processing the data.
Krylov subspace
The starting vector determines which parts of the spectrum are visible. Orthogonalisation avoids storing nearly dependent raw powers.
Orthogonal projector
Columns of Q must be orthonormal in the stated real inner product. Least squares removes the component of the data orthogonal to the fitted range.
Residual
A small residual tests the computed equation. Converting it into an error estimate needs information on the inverse or the troublesome singular directions.
Schur complement
Eliminate the first block of a partitioned system by solving with A. Forming an explicit inverse is unnecessary and may discard useful structure.
Singular value
Input and output directions can live in different spaces. A small positive singular value can cause large inverse amplification.
Further reading
Follow the sequence from orthogonality and projection to conditioning and backward error. Use the same least-squares problem to distinguish sensitivity of the data from stability of a factorisation. Trefethen and Bau · Numerical Linear Algebra
Chapters 2, 3 and 8 connect factorisations, least squares and Krylov methods through executable examples. Driscoll and Braun · Fundamentals of Numerical Computation






