Foundations to Frontier
Tests
A. Mathematical Foundations › A2 Linear Algebra › Decompositions

Matrix Norms and the Condition Number

How big is a matrix, and how badly can it amplify errors? Norms and the condition number decide whether a solution can be trusted, how fast optimizers converge, and how robust a neural network or controller is.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

When a tiny nudge causes a huge change

Two roads cross at a sharp angle, like an X. If you shift one road a little, the crossing point moves a little. But if the roads are almost parallel, a tiny shift makes the crossing point slide far away.

Problems like that are called ill-conditioned. The number that measures how badly small errors get blown up is the condition number. Try it: make the lines nearly parallel, and watch the cloud of possible answers spread out.

Ill-conditioning: nearly parallel lines
κ₂(A) = 1.49e+1 · noise 1e-2 → solutions scatter up to 8.8e-2 from the true point (1, 1)
Rule of thumb: relative error in x ≲ κ × relative error in b. Make the lines nearly parallel and watch the orange cloud explode.

How big is a machine?

A machine that stretches things by at most 4× has “size” 4. That’s a matrix norm: the biggest stretch it can produce.

Why engineers care

A robot measures positions with tiny sensor errors. If the maths it uses to compute its next move is ill-conditioned, those tiny errors can turn into wild, dangerous motions. The condition number warns you before that happens.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Two nearly parallel roads. A small nudge moves their crossing point…
  2. 2. A machine stretches one direction 4× and another 1×. Its biggest stretch?
  3. 3. A 1% measurement error becomes a 100% answer error. The amplification factor is…

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

Common matrix norms

Norm Formula Meaning
Frobenius ∥A∥F\lVert A\rVert_F ∑aij2\sqrt{\sum a_{ij}^2} treat the matrix as one long vector
Spectral ∥A∥2\lVert A\rVert_2 σ1\sigma_1 largest stretch of a unit vector
1-norm ∥A∥1\lVert A\rVert_1 largest absolute column sum largest stretch in the L1L^1 sense
∞-norm ∥A∥∞\lVert A\rVert_\infty largest absolute row sum largest stretch in the L∞L^\infty sense
Nuclear ∥A∥∗\lVert A\rVert_* ∑σi\sum\sigma_i convex proxy for rank

Example. A=(1−234)A = \begin{pmatrix}1&-2\\3&4\end{pmatrix}: the column sums are 4 and 6, so ∥A∥1=6\lVert A\rVert_1 = 6. The row sums are 3 and 7, so ∥A∥∞=7\lVert A\rVert_\infty = 7.

The condition number

κ(A)=∥A∥ ∥A−1∥,κ2(A)=σmax⁡σmin⁡\kappa(A) = \lVert A\rVert\,\lVert A^{-1}\rVert, \qquad \kappa_2(A) = \frac{\sigma_{\max}}{\sigma_{\min}}
  • κ(I)=1\kappa(I) = 1: perfect.
  • κ(diag⁡(10,0.1))=100\kappa(\operatorname{diag}(10, 0.1)) = 100.
  • A singular matrix has κ=∞\kappa = \infty.
📝 Quick check (Level 1)
0/3 answered
  1. 1. ‖diag(3, −5)‖₂ = ?
  2. 2. κ(diag(10, 0.1)) = ?
  3. 3. Frobenius norm of [[3, 4]]?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Induced (operator) norms

Given a vector norm, the induced matrix norm is the biggest stretch:

∥A∥=max⁡x≠0∥Ax∥∥x∥\lVert A\rVert = \max_{\mathbf x\ne0}\frac{\lVert A\mathbf x\rVert}{\lVert\mathbf x\rVert}

This gives ∥Ax∥≤∥A∥∥x∥\lVert A\mathbf x\rVert\le\lVert A\rVert\lVert\mathbf x\rVert and the very useful ∥AB∥≤∥A∥∥B∥\lVert AB\rVert\le\lVert A\rVert\lVert B\rVert. The 2-norm induces σ1\sigma_1, the 1-norm the max column sum, and the ∞-norm the max row sum. (The Frobenius norm isn’t induced, but it satisfies the same product rule.)

What the condition number promises

For Ax=bA\mathbf x = \mathbf b, if b\mathbf b has a small relative error:

∥Δx∥∥x∥≤κ(A) ∥Δb∥∥b∥\frac{\lVert\Delta\mathbf x\rVert}{\lVert\mathbf x\rVert}\le\kappa(A)\,\frac{\lVert\Delta\mathbf b\rVert}{\lVert\mathbf b\rVert}

Rule of thumb: with float64 (about 16 digits), expect to lose about log⁡10κ\log_{10}\kappa digits. With κ=106\kappa = 10^6, roughly 10 digits are left. With κ=1016\kappa = 10^{16}, none are.

🐍 Exercise 1: compute five matrix norms
Implement the 1, ∞, Frobenius, spectral and nuclear norms, and check them against np.linalg.norm. Also check ‖A‖₂ ≤ ‖A‖_F ≤ ‖A‖_*.

Where conditioning bites

Situation Conditioning issue
Polynomial regression, Vandermonde matrices κ\kappa grows exponentially with the degree. Use orthogonal polynomials or QR
Normal equations κ(A⊤A)=κ(A)2\kappa(A^\top A) = \kappa(A)^2 (A2.3-4)
Features on very different scales inflated κ\kappa. Standardize your data (D0)
Gradient descent iterations needed grow like κ\kappa of the Hessian (A6)
Robot near a singular pose κ(J)→∞\kappa(J)\to\infty: joint speeds blow up (A2.3-7)
📝 Quick check (Level 2)
0/3 answered
  1. 1. ‖A‖₁ for [[1, −2], [3, 4]]?
  2. 2. κ = 10⁶ in float64 leaves roughly how many correct digits?
  3. 3. Why standardize features before regression?

Level 3: Advanced

★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.

Proof of the error bound

Theorem

If Ax=bA\mathbf x = \mathbf b and A(x+Δx)=b+ΔbA(\mathbf x + \Delta\mathbf x) = \mathbf b + \Delta\mathbf b, then ∥Δx∥∥x∥≤κ(A)∥Δb∥∥b∥\dfrac{\lVert\Delta\mathbf x\rVert}{\lVert\mathbf x\rVert}\le\kappa(A)\dfrac{\lVert\Delta\mathbf b\rVert}{\lVert\mathbf b\rVert}.

Proof. Δx=A−1Δb\Delta\mathbf x = A^{-1}\Delta\mathbf b, so ∥Δx∥≤∥A−1∥∥Δb∥\lVert\Delta\mathbf x\rVert\le\lVert A^{-1}\rVert\lVert\Delta\mathbf b\rVert. Also ∥b∥=∥Ax∥≤∥A∥∥x∥\lVert\mathbf b\rVert = \lVert A\mathbf x\rVert\le\lVert A\rVert\lVert\mathbf x\rVert, so 1/∥x∥≤∥A∥/∥b∥1/\lVert\mathbf x\rVert\le\lVert A\rVert/\lVert\mathbf b\rVert. Multiply the two inequalities. ∎ The bound is tight: it’s reached when b\mathbf b lies along the top singular direction and Δb\Delta\mathbf b along the bottom one (Practice Code 3 gets within 0.02% of it).

Distance to singularity

Theorem

min⁡{∥A−B∥2:B singular}=σmin⁡(A)\min\{\lVert A - B\rVert_2 : B \text{ singular}\} = \sigma_{\min}(A), so the relative distance to the nearest singular matrix is 1/κ2(A)1/\kappa_2(A).

This follows from Eckart–Young (A2.3-6) with k=n−1k = n - 1. A huge condition number means the matrix is almost singular. The determinant does not measure this (A2.2-2).

Norm relationships

For A∈Rm×nA\in\mathbb{R}^{m\times n} with rank rr:

∥A∥2≤∥A∥F≤r ∥A∥2,∥A∥F≤∥A∥∗≤r ∥A∥F,∥A∥2≤∥A∥1∥A∥∞\lVert A\rVert_2\le\lVert A\rVert_F\le\sqrt r\,\lVert A\rVert_2, \qquad \lVert A\rVert_F\le\lVert A\rVert_*\le\sqrt r\,\lVert A\rVert_F, \qquad \lVert A\rVert_2\le\sqrt{\lVert A\rVert_1\lVert A\rVert_\infty}

Orthogonal matrices don’t change the 2-, Frobenius or nuclear norms (they are unitarily invariant), and they have κ2=1\kappa_2 = 1. That’s why orthogonal transformations are numerically safe.

Exercise 3.1: Show κ(AᵀA) = κ(A)² in the 2-norm

The singular values of A⊤AA^\top A are σi2\sigma_i^2, so κ2(A⊤A)=σmax⁡2/σmin⁡2=κ2(A)2\kappa_2(A^\top A) = \sigma_{\max}^2/\sigma_{\min}^2 = \kappa_2(A)^2.

📝 Quick check (Level 3)
0/3 answered
  1. 1. ‖A‖₂ = 3 and ‖B‖₂ = 4. The bound on ‖AB‖₂?
  2. 2. Distance (2-norm) from diag(5, 0.2) to the nearest singular matrix?
  3. 3. κ(A) = 100. κ(AᵀA) = ?

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

A stable algorithm can’t fix an ill-conditioned problem

Solving with the notoriously ill-conditioned Hilbert matrix Hij=1/(i+j−1)H_{ij} = 1/(i+j-1) shows the difference between an unstable algorithm and an ill-conditioned problem. LAPACK’s solver is backward stable (A2.2-4), yet the error grows in proportion to κ⋅εmachine\kappa\cdot\varepsilon_{\text{machine}}. By n=12n = 12, κ≈1016\kappa\approx10^{16} and essentially no digits survive. The fix must come from the modelling: better bases, regularization, or more precise data.

🐍 Exercise 2 (research): conditioning vs accuracy on Hilbert matrices
Solve Hx = b with a known answer for growing n, and compare the error with κ·ε.

Norms and conditioning in modern ML

  • Optimization speed. Gradient descent on a quadratic converges at a rate set by κ\kappa of the Hessian: the number of iterations grows like κ\kappa, or κ\sqrt\kappa with momentum (A6). Preconditioners (Adam, Shampoo, K-FAC) are attempts to reduce the effective κ\kappa. Normalization layers help partly by improving conditioning (E5).
  • Robustness and Lipschitz bounds. A network f=WLσ(⋯σ(W1x))f = W_L\sigma(\cdots\sigma(W_1\mathbf x)) with 1-Lipschitz activations satisfies ∥f(x)−f(y)∥≤∏l∥Wl∥2∥x−y∥\lVert f(\mathbf x) - f(\mathbf y)\rVert\le\prod_l\lVert W_l\rVert_2\lVert\mathbf x - \mathbf y\rVert. Controlling spectral norms (spectral normalization, Miyato et al., 2018; Parseval networks, Cissé et al., 2017) gives certified bounds on how much an adversarial perturbation can change the output (M1). For robot policies, this caps how much sensor noise can change the commanded action. Practice Code 5 shows the bound is valid but often loose.
  • Generalization theory. Norm-based bounds (Bartlett, Foster and Telgarsky, 2017) use products of spectral norms instead of parameter counts to explain why large networks generalize (B2).

References

  1. J. von Neumann and H. Goldstine (1947). “Numerical inverting of matrices of high order.” Bulletin of the AMS, 53(11).
  2. A. Turing (1948). “Rounding-off errors in matrix processes.” Quarterly Journal of Mechanics and Applied Mathematics, 1. (Coined “condition number”.)
  3. N. Higham (2002). Accuracy and Stability of Numerical Algorithms, 2nd ed. SIAM.
  4. P. Bartlett, D. Foster, M. Telgarsky (2017). “Spectrally-normalized margin bounds for neural networks.” NeurIPS.
  5. M. Cissé, P. Bojanowski, E. Grave, Y. Dauphin, N. Usunier (2017). “Parseval networks: Improving robustness to adversarial examples.” ICML.
  6. T. Miyato, T. Kataoka, M. Koyama, Y. Yoshida (2018). “Spectral normalization for generative adversarial networks.” ICLR.
  7. L. Trefethen and D. Bau (1997). Numerical Linear Algebra. SIAM. Lectures 3, 12–15.