7.4 Why QR Is Often Preferred

7.4 Why QR Is Often Preferred

At this point, we’ve explored the landscape of least-squares solvers and the decompositions that power them: Gram–Schmidt, Modified Gram–Schmidt, and Householder reflections. We’ve contrasted the elegance of the normal equations with their practical fragility, and we’ve seen how orthogonality allows us to sidestep the numerical traps that arise when matrices become ill-conditioned.

Now we arrive at a natural question:

Why does the numerical linear algebra community overwhelmingly prefer QR decomposition?

The answer comes from a blend of geometry, numerical stability, and computational pragmatism. Let’s unpack the key reasons.


1. Orthogonality preserves numerical accuracy

Orthogonal matrices have a superpower:

Multiplying by an orthogonal matrix does not amplify errors.

This property is the bedrock of QR-based methods. When we write:

A = QR

we can solve least squares via:

R x = Qᵀ b

The crucial observation is that Qᵀ b is a perfectly safe operation. Because Q is orthogonal, it simply rotates or reflects the vector. No stretching, no shrinking, no distortion.

Compare this with the normal equations approach:

Aᵀ A x = Aᵀ b

The matrix Aᵀ A can dramatically amplify errors because it squares the condition number of A. Even mildly ill-conditioned problems become unstable.

This difference—orthogonality versus squared conditioning—is the single most important reason QR is favored.


2. QR handles rank deficiency gracefully

Real datasets are messy:

  • Two features might be nearly identical.
  • Columns may be linearly dependent.
  • Data might behave differently than expected.

In these cases, Aᵀ A becomes nearly singular and numerical errors skyrocket. QR decomposition, especially when paired with column pivoting, can detect and handle rank-deficient matrices much more elegantly.

This is because orthogonal transformations do not hide degeneracies—they expose them.


3. Householder QR is stable and efficient

Householder reflections give us an algorithm that is:

  • Stable: resistant to floating-point error accumulation.
  • Deterministic: unlike classical Gram–Schmidt, results do not depend on subtle numerical orderings.
  • Efficient: even for large dense matrices, Householder QR performs extremely well.

This makes QR a natural default in high-quality numerical libraries such as:

  • LAPACK
  • NumPy / SciPy
  • MATLAB
  • Julia’s LinearAlgebra package
  • Tensor libraries used inside ML frameworks

When developers rely on QR, they inherit decades of tuning and algorithmic refinement.


4. QR generalizes better than LU for least squares

LU decomposition is excellent for solving square linear systems, but least squares problems are fundamentally rectangular. LU can be adapted, but it’s not natural.

QR is designed for rectangular matrices from the start:

  • A tall → overdetermined → least squares
  • A wide → underdetermined → minimum-norm solutions

The geometric clarity of QR—projecting onto a subspace—makes it the right conceptual tool for many problems in ML, statistics, and scientific computing.


5. QR becomes the backbone of broader algorithms

QR is not just useful for solving least squares. It also appears in:

  • Eigenvalue algorithms
  • Stability analysis
  • Orthogonalization processes
  • Kalman filtering
  • Control theory
  • Kernel methods

In fact, as we will see soon, the QR algorithm is the foundation of modern eigenvalue computation. This gives QR a dual role: a practical solver today, and a theoretical engine for more advanced algorithms.


Putting it all together

QR decomposition strikes a rare balance:

  • It is stable without excessive computational cost.
  • It handles rectangular systems with elegance and clarity.
  • It exposes rank deficiencies quickly and reliably.
  • It integrates smoothly into bigger numerical pipelines.

This is why, across numerical libraries and scientific disciplines, QR remains a default choice for solving least squares and other foundational linear algebra problems.


Looking ahead: the bridge to eigenvalues

There is a beautiful symmetry in numerical linear algebra: the same decomposition used to solve least squares efficiently also lies at the heart of one of the most powerful algorithms for computing eigenvalues.

Understanding QR decomposition gives us the conceptual foundation we need to enter the next major topic: eigenvalues and eigenvectors. These objects reveal the structure of matrices, govern the stability of dynamical systems, and appear everywhere from PCA to differential equations to deep learning.

Before we dive into iterative methods and spectral analysis, we will first explore the essential ideas that make eigenvalues so powerful. With QR now in hand, we’re ready to begin.

Next up: Eigenvalues and Eigenvectors — understanding the spectrum of a matrix.

2025-10-05

Shohei Shimoda

I organized and output what I have learned and know here.