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.
The four methods below all return the same x^ in exact arithmetic, so the choice between them is not about correctness. It is about a single decision: whether the method forms ATA or arranges never to see it. The grouping is that decision, and it is also the ranking. Orthogonality · least squares
Four ways to compute the same solution
All four minimise ∥Ax−b∥2 and return the same x^ in exact arithmetic. In floating point they do not, and the difference is entirely about whether the method forms ATA or avoids it.
4methods
Forms ATA — correct, fragile1 1∼mn2+n3/3; needs full column rank ATAx^=ATb The derivation everyone learns and the computation nobody should run. Setting the gradient to zero gives these equations directly, and ATA is symmetric positive definite so Cholesky solves it — but the squared condition number means the answer can lose half its digits before Cholesky begins. Avoids it — the practical routes3
2∼2mn2 via Householder Rx^=QTb Factor A=QR, multiply through by QT, and back-substitute on the triangular system. Q is orthogonal so it preserves lengths and therefore the condition number — the workhorse in every numerical library, and the reason QR is taught alongside least squares. 3x^=VΣ+UTb The only method that works when A is rank-deficient, where the others have no unique solution to find. Among the infinitely many minimisers it returns the one of smallest norm — a choice made deliberately rather than by accident of the algorithm. Costs more than QR and is worth it when the rank is in doubt. 4one matrix–vector product per step
Krylov iteration on ATAx^=ATb Never forms ATA explicitly — only its action on a vector, which costs two multiplications by A. The right choice when A is large and sparse and a factorization would destroy the sparsity. Convergence depends on conditioning, so preconditioning is part of the method rather than an optimisation. Why forming ATA hurts is worth stating in numbers. The condition number of ATA is the square of the condition number of A, so a matrix with κ(A)=104 — unremarkable in a fitting problem — produces a system with κ=108. In double precision that consumes roughly half the available digits before the solve has started, and no amount of care in the solver recovers them. QR avoids this because Q is orthogonal: multiplying by it preserves lengths, so it cannot amplify error, and the triangular system inherits A's conditioning rather than its square. The SVD goes further and drops the rank requirement entirely, which is the case where the other three have no unique answer to compute — among infinitely many minimisers it returns the one of least norm. That is a deliberate choice, not a default, and it is why the pseudoinverse is the right tool when the rank is uncertain.