Comprehensive computational methods for solving linear systems, matrix operations, eigenvalues, and numerical linear algebra.
Gaussian elimination, LU decomposition
Jacobi, Gauss-Seidel, Conjugate Gradient
QR, SVD, Cholesky, Eigen decomposition
Sparse matrices, banded systems
Purpose: Solve Ax = b or find matrix inverse
When to use: Small to medium systems (n ≤ 1000), exact arithmetic needed
Purpose: Factor A = LU, then solve multiple systems efficiently
When to use: Solving Ax = b for multiple b vectors with same A
Purpose: Solve least squares, eigenvalue problems, orthogonalization
When to use: Least squares problems, ill-conditioned systems
Purpose: Matrix analysis, rank determination, pseudoinverse, dimensionality reduction
When to use: Rank-deficient systems, data compression (PCA), image processing
Purpose: Find eigenvalues λ and eigenvectors v where Av = λv
When to use: Stability analysis, principal component analysis, quantum mechanics
Purpose: Solve large sparse systems Ax = b without forming A⁻¹
When to use: Large sparse systems (n > 10,000), PDE discretizations
| Method | Best For | Complexity | Stability | Implementation |
|---|---|---|---|---|
| Gaussian Elimination | Small dense systems | O(n³) | Good with pivoting | Easy |
| LU Decomposition | Multiple RHS | O(n³) setup, O(n²) solve | Good with pivoting | Moderate |
| QR Factorization | Least squares, ill-conditioned | O(2n³/3) | Excellent | Moderate |
| SVD | Rank-deficient, analysis | O(mn²) | Excellent | Complex |
| Conjugate Gradient | Large sparse SPD | O(nnz) per iteration | Good with preconditioning | Moderate |
numpy.linalg, scipy.linalg, scipy.sparse
Built-in: \, inv, eig, svd, lu, qr
LinearAlgebra stdlib, fast JIT compilation
Template library, expression templates
base::solve, Matrix package for sparse
Industry standard, highly optimized
Solve (XᵀX)β = Xᵀy
Using SVD/PCA
PageRank as eigenvector
κ(A) = ||A||·||A⁻¹||. If κ(A) ≈ 10ᵏ, lose k digits of accuracy.
Essential for stability. Partial pivoting (row swaps) or complete pivoting.
Hilbert matrix: Hᵢⱼ = 1/(i+j-1). κ(Hₙ) grows exponentially.
CSR, CSC formats for large sparse matrices to save memory.
Use Gaussian elimination or A\b
LU decomposition, then solve
QR or SVD (more stable than normal equations)
Conjugate Gradient with preconditioning
QR algorithm for small, Lanczos for large sparse
SVD for rank, condition number, pseudoinverse