← Back to Math Roadmap

Numerical Linear Algebra

Matrix computations at scale — the engine behind scientific computing, machine learning, and data science.

Matrix Decompositions

▼
Matrix decompositions factor a matrix into products of simpler matrices, each with special properties. The LU decomposition factors a square matrix into a lower triangular matrix L and an upper triangular matrix U, enabling efficient solving of linear systems and computation of determinants. The QR decomposition factors into an orthogonal matrix Q (Q transpose times Q equals the identity) and an upper triangular matrix R, essential for least squares and eigenvalue algorithms. The Cholesky decomposition is a specialized factorization for symmetric positive definite matrices: A equals L times L transpose, where L is lower triangular. It is twice as fast as LU.
Singular Value Decomposition (SVD). A is decomposed into orthogonal matrices U and V and a diagonal matrix Sigma of singular values. The outer product sum reveals the rank-r structure.

The Singular Value Decomposition (SVD)

▼
The SVD is arguably the most important matrix decomposition in applied mathematics. It factors any matrix A (even rectangular or singular) into U times Sigma times V transpose. U and V are orthogonal matrices, and Sigma is a diagonal matrix of singular values (non-negative, sorted in descending order). The SVD reveals the fundamental structure of a matrix: the rank equals the number of non-zero singular values. Truncating to the largest k singular values gives the optimal rank-k approximation — the basis of Principal Component Analysis (PCA), latent semantic analysis, collaborative filtering, and image compression.

Iterative Methods for Large Systems

▼
When matrices are very large (millions of rows) and sparse (mostly zeros), direct methods like Gaussian elimination become too expensive (O of n cubed). Iterative methods solve these efficiently. The Conjugate Gradient (CG) method is optimal for symmetric positive definite systems, converging in at most n iterations. GMRES (Generalized Minimal Residual) handles non-symmetric systems. Preconditioning transforms the system to improve convergence — a good preconditioner can reduce iterations from thousands to dozens. Multigrid methods achieve optimal O of n complexity by solving on multiple grid resolutions simultaneously, making them among the fastest solvers for elliptic PDEs.
Condition number. Measures sensitivity of the solution to small changes in the input. A large condition number means an ill-conditioned (unstable) problem.

Computational Considerations

▼
Computational Considerations
Numerical stability is paramount in matrix computations. Partial pivoting in LU decomposition prevents catastrophic loss of precision. Orthogonal transformations (Householder reflections, Givens rotations) are more stable than elementary row operations. The SVD costs more but is the most numerically stable decomposition. Iterative refinement can improve accuracy of direct solutions. For very large sparse matrices, only the non-zero entries are stored (compressed sparse row or column formats).

Worked Example

▼
Worked Example
Compute the SVD of A = [[3,0],[0,1]].
A is already diagonal: A = I × [[3,0],[0,1]] × I. So U=I, Sigma=[[3,0],[0,1]], V=I.
The singular values are 3 and 1. The condition number is 3/1 = 3.
A rank-1 approximation uses only sigma_1=3: A_1 = [[3,0],[0,0]].

SVD Visualization

▼
See how the SVD decomposes a matrix transformation into rotation, scaling, and rotation. Adjust parameters to see the geometric interpretation.

The SVD: The Ultimate Matrix Decomposition

▼
The Singular Value Decomposition factors ANY matrix A (m×n) into A = UΣV^T. U (m×m) and V (n×n) are orthogonal matrices (U^T U = I, V^T V = I). Σ is a diagonal matrix of singular values σ_1 ≥ σ_2 ≥ ... ≥ σ_r > 0, where r is the rank. Geometrically: every matrix is a rotation (V^T), then axis-aligned scaling (Σ), then another rotation (U).

The SVD is the crown jewel of numerical linear algebra because: (1) it exists for EVERY matrix, even rectangular and singular, (2) it reveals rank (number of nonzero singular values), (3) it provides the optimal low-rank approximation (keep the largest k singular values — this is the Eckart-Young theorem and the math behind PCA), (4) the condition number κ = σ_max/σ_min measures sensitivity to errors, (5) the pseudoinverse A^+ = VΣ^+U^T solves least-squares problems for any matrix. Google's PageRank, Netflix's recommendation system, image compression (JPEG), and semantic search embeddings all rely on the SVD.

SVD of a 2×2 Matrix

▼
SVD of a 2×2 Matrix
A = [[3, 0], [0, 1]]. This is already diagonal: U = [[1,0],[0,1]], Σ = [[3,0],[0,1]], V = [[1,0],[0,1]]. Singular values: σ₁=3, σ₂=1. Condition number: 3/1 = 3. Rank = 2.

Rank-1 approximation (keep only σ₁): A₁ = [[3,0],[0,0]]. This captures 3/(3+1) = 75% of the matrix energy.

A = [[1, 2], [2, 1]]. SVD: U = [[-√2/2, √2/2], [-√2/2, -√2/2]], Σ = [[3,0],[0,1]], V = [[-√2/2, -√2/2], [-√2/2, √2/2]]. Singular values: 3, 1. Check: UΣV^T = [[1,2],[2,1]] ✓.