The least-squares solution x̂ can be computed by several distinct routes, each with its own cost and numerical-stability profile. The table below collects the main methods alongside their formulas, operation counts, and stability characteristics, providing a single reference for choosing among them.
| Method |
How the LS solution is obtained |
Cost (m × n, m ≫ n) |
Numerical stability |
| Normal equations directly |
form AᵀA and Aᵀb; solve AᵀA x̂ = Aᵀb (e.g. by Cholesky) |
~ m n² + n³ / 3 |
poor — forming AᵀA squares the condition number of A |
| QR decomposition |
A = Q R; solve the triangular system R x̂ = Qᵀ b by back substitution |
~ 2 m n² (Householder QR) |
good — preserves the original condition number; the workhorse in numerical libraries |
| Pseudoinverse via SVD |
A = U Σ Vᵀ; x̂ = V Σ⁺ Uᵀ b (Moore–Penrose pseudoinverse) |
dominated by SVD: roughly ~ m n² + n³ |
best — handles rank-deficient A; returns the minimum-norm LS solution |
| Iterative methods (e.g. CG on AᵀA) |
apply Krylov-subspace iteration to AᵀA x̂ = Aᵀb without forming AᵀA explicitly |
depends on iteration count; one matrix-vector product per iteration |
depends on preconditioning; preferred when A is huge and sparse |