Solution (source code)

= Solution

The <orthogonal matrix> $Q$ preserves the <Euclidean norm>, so
$$
\|Ax-b\|^2=\|Rx-Q^Tb\|^2,
\qquad Q^Tb=\begin{pmatrix}98/25\\35\\4\\-3\end{pmatrix}.
$$
The first three entries of $Rx-Q^Tb$ can be set to zero by <backward substitution in a triangular system>, while its fourth entry is always $3$. Solving the triangular system gives $x_3=16/5$, $x_2=(35-2x_3)/5=143/25$, and $x_1=(98/25-x_2-x_3)/3=-5/3$. Thus \b[the unique <least-squares solution> and residual norm are]
$$
\boxed{x^*=\begin{pmatrix}-5/3\\143/25\\16/5\end{pmatrix},\qquad\|Ax^*-b\|=3.}
$$
Uniqueness follows from the nonzero diagonal entries of the top triangular block, equivalently the full column rank of $A$.