Numerically stable solution methods

Factorization-based methods can be used to obtain the least-squares solution directly from the matrix $\mathbf{A}$, without explicitly forming $\mathbf{A}^{\top}\mathbf{A}$.

One option is to use QR factorization, an algorithm known for its numerical stability. For a matrix $\mathbf{A}$ of size $m\times n$, with $m\geq n$, we can write

\begin{displaymath}
\mathbf{A}=\mathbf{Q}\mathbf{R}
\end{displaymath} (1.18)

where $\mathbf{Q}$ has orthonormal columns and $\mathbf{R}$ is an upper triangular matrix. The least-squares problem then becomes
\begin{displaymath}
\mathbf{Q}\mathbf{R}\mathbf{x}\simeq\mathbf{y}.
\end{displaymath} (1.19)

Using the orthogonality of $\mathbf{Q}$, the solution can be obtained by solving
\begin{displaymath}
\mathbf{R}\mathbf{x}
=
\mathbf{Q}^{\top}\mathbf{y}.
\end{displaymath} (1.20)

This approach avoids forming the matrix $\mathbf{A}^{\top}\mathbf{A}$ and is therefore numerically more stable than directly solving the normal equations.

The SVD is an even more general method and also handles rank-deficient matrices naturally. The decomposition (1.9) can be used to obtain the pseudoinverse directly via (1.12), and hence the solution

\begin{displaymath}
\hat{\mathbf{x}}
=
\mathbf{V}\mathbf{\Sigma}^{+}\mathbf{U}^{\top}\mathbf{y}.
\end{displaymath} (1.21)

The SVD also directly identifies the problem directions associated with very small singular values. These directions correspond to solution components that are poorly determined by the data, and are particularly important when analyzing conditioning and homogeneous linear systems.

From a numerical computing perspective, when possible, the matrix condition number can also be reduced by appropriately normalizing or scaling the columns of $\mathbf{A}$.

Paolo medici
2026-10-19