Each lab worksheet will contain several activities, most of which will involve writing math on paper, and some of which will involve running code in a Jupyter Notebook. Lab activities are meant to last an hour, and the second hour of lab is dedicated to starting the homework assignment. To receive credit for a lab, you must show your lab TA your work on both the lab worksheet and homework assignment.
While you must get checked off by your lab TA individually, we encourage you to form groups with 1-2 other students to complete the activities together.
Its length is also \(13\), giving \(\vec u_2=\frac1{13}\begin{bmatrix}-12\\5\end{bmatrix}\).
The Gram-Schmidt process preserves the span: \(\vec u_1,\vec u_2\) are combinations of the original columns, and the equations in part (b) recover those columns. Thus they form an orthonormal basis of \(\operatorname{colsp}(A)\).
b)
Write the relationships between the original vectors (\(\vec v_1\) and \(\vec v_2\)) and the orthonormal basis vectors (\(\vec u_1\) and \(\vec u_2\)). Use these equations to find \(Q\) and \(R\) such that \(A=QR\).
Solution
Undoing the normalization and projection steps gives the relationships \(\vec v_1=13\vec u_1\) and \(\vec v_2=13\vec u_1+13\vec u_2\). Thus
Weβll now consider the case of three vectors. Suppose that \(A\) is a matrix whose columns \(\vec v_1,\vec v_2,\vec v_3\) are linearly independent. We want to use the Gram-Schmidt method to construct an orthonormal basis \(\vec u_1,\vec u_2,\vec u_3\) of their span and find the QR factorization of \(A\). The first two steps are just what weβve already done.
First vector: normalize. Divide by its length:
$$ \vec u_1=\frac{\vec v_1}{\|\vec v_1\|}. $$
Second vector: subtract one projection, then normalize. Let \(\ell_1=\operatorname{span}(\vec u_1)\). Remove the part of \(\vec v_2\) along this line:
Third vector: subtract two projections, then normalize. Hereβs the new step. We want a vector perpendicular to both \(\vec u_1\) and \(\vec u_2\). Let \(\ell_2=\operatorname{span}(\vec u_2)\). Subtract the parts along both lines:
Because \(\vec u_1\) and \(\vec u_2\) are perpendicular, removing the component along one doesnβt change the component along the other. Whatβs left is perpendicular to both. The remaining vectors \(\vec w_2,\vec w_3\) cannot be zero, because the original columns are independent.
How does this give \(A=QR\)? First record how the old vectors relate to the new ones. Put back the components we subtracted:
So \(Q\) contains the orthonormal vectors, and each column of \(R\) contains the coefficients for one original vector. The diagonal entries are the lengths we divided by; the entries above them are the dot products we used for the projections. Keep these numbers as you work!
Our goal is to find a QR factorization of \(A\). To start, weβll apply the Gram-Schmidt process to \(A\). Call \(A\)βs columns \(\vec v_1\), \(\vec v_2\), and \(\vec v_3\), in that order.
a)
Find \(\vec u_1\), then subtract the component of \(\vec v_2\) along \(\vec u_1\) and normalize to find \(\vec u_2\).
Solution
The first column has length \(\sqrt{2^2+(-2)^2+1^2}=3\), so
Its length is \(3\), so \(\vec u_3=\frac13\begin{bmatrix}-2\\-1\\2\end{bmatrix}\).
c)
Write the relationships between the original vectors (\(\vec v_1\), \(\vec v_2\), and \(\vec v_3\)) and the orthonormal basis vectors (\(\vec u_1\), \(\vec u_2\), and \(\vec u_3\)). Use these equations to find \(Q\) and \(R\) such that \(A=QR\). Verify that \(QR=A\) and that the columns of \(Q\) are orthonormal.
Solution
Putting back the components we subtracted and undoing normalization gives
Each column of \(Q\) has squared length \(9/9=1\). The distinct-column dot products are \((2-4+2)/9=0\), \((-4+2+2)/9=0\), and \((-2-2+4)/9=0\). Finally,