logo

QR Decomposition for Least Squares Method 📂Matrix Algebra

QR Decomposition for Least Squares Method

Algorithm

ACm×nA \in \mathbb{C}^{m \times n} and vector bCm\mathbf{b} \in \mathbb{C}^{m}, let rankA=n\text{rank} A = n and the least squares solution of Ax=bA \mathbf{x} = \mathbf{b} be x\mathbf{x}_{\ast}.

Step 1. QR decomposition

Find the orthogonal matrix Q^\widehat{Q} and upper triangular matrix R^\widehat{R} that satisfy A=Q^R^A = \widehat{Q} \widehat{R}.


Step 2.

Using the obtained Q^\widehat{Q} from QR decomposition to compute the projection P:=Q^Q^P : = \widehat{Q} \widehat{Q}^{\ast}. Since Ax=PbA \mathbf{x}_{\ast} = P \mathbf{b}, it follows that Q^R^x=Q^Q^b\widehat{Q} \widehat{R} \mathbf{x}_{\ast} = \widehat{Q} \widehat{Q}^{\ast} \mathbf{b}, and by multiplying the left side of both sides by Q^\widehat{Q}^{\ast}, we derive R^x=Q^b\widehat{R} \mathbf{x}_{\ast} = \widehat{Q}^{\ast} \mathbf{b}.


Step 3.

Calculate y:=Q^b\mathbf{y} := \widehat{Q}^{\ast} \mathbf{b} to get R^x=y\widehat{R} \mathbf{x}_{\ast} = \mathbf{y}.


Step 4. Back substitution

Since R^\widehat{R} is an upper triangular matrix, solve for x\mathbf{x}_{\ast} in equation R^x=y\widehat{R} \mathbf{x}_{\ast} = \mathbf{y} using back substitution.