Thin QR and a least-squares fit

Problem

Let AA have columns a1=(1,0,0)Ta_1=(1,0,0)^{\mathsf T} and a2=(1,1,0)Ta_2=(1,1,0)^{\mathsf T}, and let b=(1,2,3)Tb=(1,2,3)^{\mathsf T}. Find a thin QR factorization A=QRA=QR, use it to solve min⁡x∥Ax−b∥2\min_x\|Ax-b\|_2, and give the fitted vector and residual.

Reveal answer or reference solution

Gram-Schmidt gives q1=(1,0,0)Tq_1=(1,0,0)^{\mathsf T} and q2=(0,1,0)Tq_2=(0,1,0)^{\mathsf T}, so

Q=[100100],R=[1101]Q=\begin{bmatrix}1&0\\0&1\\0&0\end{bmatrix},\qquad R=\begin{bmatrix}1&1\\0&1\end{bmatrix}

The least-squares equation is Rx=QTb=(1,2)TRx=Q^{\mathsf T}b=(1,2)^{\mathsf T}. Thus x2=2x_2=2 and x1=−1x_1=-1. The fitted vector and residual are

Ax=(1,2,0)T,b−Ax=(0,0,3)TAx=(1,2,0)^{\mathsf T},\qquad b-Ax=(0,0,3)^{\mathsf T}
Outcome

Previous attempts

Loading attempts saved in this browser…

    Review Screening Results