Least Squares Solver using QR Decomposition

Find the best approximate solution to \(A\mathbf{x} \approx \mathbf{b}\) using QR Decomposition1.
Minimizes the Euclidean norm \(\|A\mathbf{x} - \mathbf{b}\|_2\) via Householder reflections2.

When the system \(A\mathbf{x} = \mathbf{b}\) is overdetermined (more equations than unknowns), we find the solution that minimizes the residual:

\[\min_{\mathbf{x}} \|A\mathbf{x} - \mathbf{b}\|_2\]

QR Method:

  • Factor \(A = QR\) where \(Q\) is orthogonal and \(R\) is upper triangular3
  • Compute \(c = Q^T\mathbf{b}\), then solve \(R\mathbf{x} = c\)
  • More numerically stable than the normal equations4

Advantages:

  • Handles rank-deficient matrices gracefully
  • Provides minimum-norm solution for underdetermined systems
  • Uses Householder reflections for robust computation
Set matrix dimensions

Enter dimensions and click Generate Matrix to create the input grid and b vector.

Display values as:
Set Up
Loads a pre-filled 4×2 overdetermined system — ready to compute.
Compute
Solves the least-squares problem via QR decomposition and back substitution.
Resets all dimensions, matrix entries, and results.