Numerical Stability & Conditioning
00 · Symbol Glossary
The condition number of an invertible matrix measures how much relative errors in or in can amplify in the solution of . For the 2-norm: . Large means the problem is ill-conditioned — small input perturbations cause large output changes.
The smallest floating-point number such that in computer arithmetic. For IEEE double precision, . All numerical algorithms lose precision at a rate governed by .
A measure of the "size" of a matrix. The operator 2-norm is the largest stretching factor. The Frobenius norm treats the matrix as a long vector. Condition numbers depend on the norm chosen; is standard in numerical analysis.
The matrix actually stored in floating-point — a perturbed version of the exact . Backward stability means the computed answer is the exact answer for a nearby problem .
01 · Why Numerical Stability Matters
Chapters 16–18 derived exact LU, QR, and SVD factorisations. A computer stores numbers to only decimal digits. When is large, those digits are not enough — the computed solution can be meaningless even when the algorithm is algebraically correct.
For , the relative error in the solution satisfies approximately:
— well-conditioned: input noise barely affects the output.
— ill-conditioned: small relative errors in (or ) can cause large relative errors in .
always (for any norm). .
A covariance matrix has — nearly collinear factor exposures make some eigenvalues very small.
A relative perturbation in (within machine noise) can produce a relative error in optimal weights — a allocation error on a billion-dollar book is million dollars.
Knowing before inverting tells you whether the optimiser's output is trustworthy.
Solve where , . Exact solution: .
Perturb to — relative change .
New solution: — completely different allocation.
Why it breaks: . The near-parallel rows of make the system sensitive.
Consequence: a correct LU or QR implementation still returns a useless answer for ill-conditioned . The problem is the data, not the code.
02 · The Condition Number via SVD
For invertible with singular values :
— largest singular value; .
— smallest singular value; .
. Equality holds for orthogonal matrices ().
Singular values from Chapter 18: , .
Compute condition number: .
The comes from the ratio of largest to smallest stretching.
Interpret: a relative error in of size can cause a relative error in of at most . This system is well-conditioned — three digits of safety beyond machine epsilon.
The Hilbert matrix has growing as . For , — inversion in double precision loses all reliable digits. The Hilbert matrix is a standard test for numerical linear algebra libraries.
03 · Forward Error vs Backward Error
Forward error: — how far the computed solution is from the true answer.
Backward error: the smallest perturbation such that is the exact solution of .
An algorithm is backward stable if is small — the computed answer solves a nearby problem. Backward stability does not guarantee small forward error when is large.
LU with partial pivoting is backward stable: .
For Hilbert , LU produces tiny but has no correct digits because .
Consequence: backward stability is a property of the algorithm; forward accuracy requires both a stable algorithm and a well-conditioned problem. QR and SVD are preferred for least squares precisely because they are backward stable and avoid squaring .
04 · Stability of LU, QR, and SVD
| Method | Operation | Conditioning impact |
|---|---|---|
| LU solve | Solve | |
| Normal equations | Form , solve | |
| QR least squares | Solve | |
| SVD least squares | ; can truncate small |
Normal equations square the condition number. QR and SVD avoid this — Chapter 17's warning made precise.
Design matrix for factor regression. .
Normal equations: . Expected relative error — betas unreliable below relative precision.
QR: . Expected error — four extra digits of reliability.
For risk attribution requiring 6 significant figures in factor exposures, QR is mandatory; normal equations fail silently.
05 · Truncated SVD and Regularisation
When is huge because (rank deficiency or near-dependency), truncating tiny singular values stabilises the solution.
Replace with a truncated version that sets when (threshold):
This is Tikhonov regularisation in disguise — trading bias (approximate fit) for lower variance (stability). In portfolio optimisation, it corresponds to discarding near-zero-variance factor directions that amplify noise.
Nearly collinear factors give in the SVD of . Including in amplifies noise by .
Truncating (ridge penalty corresponds to ) yields stable betas at the cost of slight bias. Cross-validation selects — standard in quantitative equity factor models.
06 · Practice Exercises
. For diagonal , singular values are .
. , .
.
A relative error in can cause up to relative error in .
For , compute from singular values. If , bound the relative error in .
. For , compute and explicitly.
. .
.
(order of magnitude). .
— ill-conditioned. Near-duplicate rows cause extreme sensitivity.
Estimate for using and . Explain why this matrix is ill-conditioned.
. If , normal equations lose digits.
. .
Double precision: .
Normal equations relative error bound: — about 10 reliable digits.
QR relative error bound: — about 13 reliable digits.
QR preserves 3 extra digits — critical for .
If , compare to . How many digits of accuracy might normal equations lose relative to QR in double precision?
Orthogonal matrices have , so . They are perfectly conditioned.
(90° rotation). .
Singular values of : both equal 1. .
for all — rotations preserve length. No amplification of errors.
Therefore orthogonal transformations (QR's factor, SVD's and ) are numerically safe operations.
Show that for any orthogonal matrix . Use as a concrete example and explain why orthogonal transformations preserve lengths.
grows rapidly with . For , . Inversion loses digits.
has entries .
.
Digits lost .
In double precision ( digits), solving via LU yields at most reliable digits — and fewer if also has error.
For , — complete loss of precision. The Hilbert matrix demonstrates that problem conditioning, not algorithm choice, can make the answer unknowable.
The Hilbert matrix has . How many digits of accuracy are lost in solving in double precision? Why does increasing make the problem worse?
large means eigenvalues span a wide range — near-collinearity. Invert via SVD, truncating small . Optimal weights become unstable when .
. Eigenvalues: and .
.
— entries .
A perturbation in changes by order — large relative swings in optimal portfolio weights.
Remedy: SVD of , truncate (or add ridge ). Stable approximate weights sacrifice exact mean-variance optimality for robustness — standard in production portfolio systems.
A covariance matrix arises from two nearly identical factors. Compute , explain why is numerically dangerous, and describe one stabilisation strategy used in portfolio optimisation.
07 · Summary
| Term | Definition |
|---|---|
| Condition number | Amplification factor for relative input errors; |
| Well-conditioned | ; small input noise, small output change |
| Ill-conditioned | ; solution sensitive to perturbations |
| Machine epsilon | in double precision |
| Forward error | |
| Backward error | Smallest such that computed is exact for |
| Normal equations | — avoid in practice |
| QR / SVD | Backward stable; not squared |
| Truncated SVD | Regularisation by discarding small |
Next: Calculus — Limits & Continuity — the analytical foundations for derivatives, optimisation, and stochastic models that build on the linear algebra toolkit completed in this subject.