Solution (source code)

= Solution

Let the columns of $A$ be $a_1,a_2,a_3$. The <Gram-Schmidt process> gives
$$
q_1=\frac{a_1}{|a_1|}
=\frac12(1,1,1,-1)^T,
\qquad r_{11}=4.
$$
Next,
$$
r_{12}=q_1^Ta_2=2,
\qquad
a_2-r_{12}q_1=(1,-1,1,1)^T,
$$
so
$$
q_2=\frac12(1,-1,1,1)^T,
\qquad r_{22}=2.
$$
For the final column,
$$
r_{13}=q_1^Ta_3=-2,
\qquad
r_{23}=q_2^Ta_3=4,
$$
and
$$
a_3-r_{13}q_1-r_{23}q_2=(-1,-1,1,-1)^T.
$$
Thus $q_3=\frac12(-1,-1,1,-1)^T$ and $r_{33}=2$. The reduced <QR decomposition> is
$$
\boxed{
Q=\frac12
\begin{pmatrix}
1&1&-1\\
1&-1&-1\\
1&1&1\\
-1&1&-1
\end{pmatrix},
\qquad
R=
\begin{pmatrix}
4&2&-2\\
0&2&4\\
0&0&2
\end{pmatrix}}.
$$
The columns of $Q$ are orthonormal, and direct multiplication gives $QR=A$.