= Solution
The <linear least-squares problem> is to minimize $\|Ax-b\|_2^2$ over $x\in\mathbb R^n$, allowing an overdetermined system to have a nonzero residual. For a full <QR decomposition>, $Q$ is $m\times m$ orthogonal and $R$ is $m\times n$ with an upper-triangular top block. <Orthogonal transformations> preserve the <Euclidean norm>, so
$$
\|Ax-b\|_2=\|Q^T(Ax-b)\|_2=\|Rx-Q^Tb\|_2.
$$
If $A$ has full column rank, the top triangular block is nonsingular; setting its residual to zero gives the unique minimizer, while the remaining residual is independent of $x$. Without full column rank, minimizers still exist but need not be unique.
For the specified matrix, one <Householder reflection> already produces an upper-triangular matrix. Take $v=(-1,1,1,1)^T$, the difference between the first column and $2e_1$, and set
$$
H=I-\frac{2vv^T}{v^Tv}
=\frac12\begin{pmatrix}1&1&1&1\\1&1&-1&-1\\1&-1&1&-1\\1&-1&-1&1\end{pmatrix}.
$$
The formula gives $H^T=H$, $H^2=I$. Direct multiplication yields the <Householder QR decomposition>
$$
\boxed{Q=H,\qquad R=HA=\begin{pmatrix}2&4&2\\0&2&2\\0&0&2\\0&0&0\end{pmatrix},\qquad A=QR.}
$$
All subdiagonal entries in the remaining columns are already zero, so no further reflection is needed. For the supplied right-hand side, $Q^Tb=(2,0,2,-2)^T$. Back substitution gives $x_3=1$, $x_2=-1$, $x_1=2$, hence
$$
\boxed{x^*=(2,-1,1)^T,\qquad\min\|Ax-b\|_2^2=4.}
$$
The residual $Ax^*-b=(1,-1,-1,1)^T$ is orthogonal to every column of $A$, independently confirming the <normal equations> $A^T(Ax^*-b)=0$.
Back to article page