In the video, we reasoned that the following two algorithms compute the same values, except that the columns of \(Q \) overwrite the corresponding columns of \(A \text{:}\)
This homework illustrates how, given a vector \(y \in \Cm \) and a matrix \(Q \in \C^{mxk} \) the component orthogonal to the column space of \(Q \text{,}\) given by \(( I - Q Q^H ) y
\text{,}\) can be computed by either of the two algorithms given in Figure 3.2.4.1. The one on the left, \(\mbox{Proj}\perp Q_{\rm CGS}( Q, y ) \) projects \(y\) onto the column space perpendicular to \(Q \) as did the Gram-Schmidt algorithm with which we started. The one on the left successfuly subtracts out the component in the direction of \(q_i \) using a vector that has been updated in previous iterations (and hence is already orthogonal to \(q_0, \ldots, q_{i-1} \)). The algorithm on the right is one variant of the Modified Gram-Schmidt (MGS) algorithm.
These insights allow us to present CGS and this variant of MGS in FLAME notation, in Figure 3.2.4.2 (left and middle).
Next, we massage the MGS algorithm into the alternative MGS algorithmic variant given in Figure 3.2.4.2 (right).
The video discusses how MGS can be rearranged so that every time a new vector \(q_k \) is computed (overwriting \(a_k \)), the remaining vectors, \(\{ a_{k+1}, \ldots, a_{n-1} \} \text{,}\) can be updated by subtracting out the component in the direction of \(q_k \text{.}\) This is also illustrated through the next sequence of equivalent algorithms.
This discussion shows that the updating of future columns by subtracting out the component in the direction of the latest column of \(Q \) to be computed can be cast in terms of a rank-1 update. This is also captured, using FLAME notation, in the algorithm in Figure 3.2.4.2, as is further illustrated in Figure 3.2.4.4:
Ponder This3.2.4.2.
Let \(A \) have linearly independent columns and let \(A = Q R \) be a QR factorization of \(A \text{.}\) Partition
\begin{equation*}
A \rightarrow
\FlaOneByTwo{A_L}{A_R},
\quad
Q \rightarrow
\FlaOneByTwo{Q_L}{Q_R},
{\rm ~~~and~~~}
R \rightarrow
\FlaTwoByTwo
{R_{TL}}{R_{TR}}
{ 0 }{R_{BR}},
\end{equation*}
where \(A_L \) and \(Q_L \) have \(k \) columns and \(R_{TL} \) is \(k \times k \text{.}\)
As you prove the following insights, relate each to the algorithm in Figure 3.2.4.4. In particular, at the top of the loop of a typical iteration, how have the different parts of \(A \) and \(R \) been updated?
\(A_L = Q_L R_{TL}\text{.}\)
(\(Q_L R_{TL} \) equals the QR factorization of \(A_L \text{.}\))
\({\cal C}( A_L ) = {\cal C}( Q_L ) \text{.}\)
(The first \(k\) columns of \(Q \) form an orthonormal basis for the space spanned by the first \(k \) columns of \(A \text{.}\))
\(R_{TR} = Q_L^H A_R\text{.}\)
\((A_R - Q_L R_{TR} )^H Q_L = 0 \text{.}\)
(Each column in \(A_R - Q_L R_{TR}\) equals the component of the corresponding column of \(A_R \) that is orthogonal to \(\Span( Q_L ) \text{.}\))
\({\cal C}( A_L ) = {\cal C}( Q_L ) \) can be shown by noting that \(R \) is upper triangular and nonsingular and hence \(R_{TL} \) is upper triangular and nonsingular, and using this to show that \({\cal C}( A_L ) \subset {\cal C}( Q_L ) \) and \({\cal C}( Q_L ) \subset {\cal C}( A_L ) \text{:}\)
\({\cal C}( A_L ) \subset {\cal C}( Q_L ) \text{:}\) Let \(y \in {\cal C}( A_L ) \text{.}\) Then there exists \(x \) such that \(A_L x = y
\text{.}\) But then \(Q_L R_{TL} x = y \) and hence \(Q_L( R_{TL} x ) = y \) which means that \(y \in {\cal C}( Q_L ) \text{.}\)
\({\cal C}( Q_L ) \subset {\cal C}( A_L ) \text{:}\) Let \(y \in {\cal C}( Q_L ) \text{.}\) Then there exists \(x \) such that \(Q_L x = y
\text{.}\) But then \(A_L R_{TL}^{-1} x = y \) and hence \(A_L( R_{TL}^{-1} x ) = y \) which means that \(y \in {\cal C}( A_L ) \text{.}\)
This answers 2.
Take \(A_R - Q_L R_{TR} = Q_R R_{BR} \) and multiply both side by \(Q_L^H \text{:}\)
Input is an \(m \times n \) matrix A and a \(n \times n \) matrix \(R \text{.}\) Output is the matrix \(Q \text{,}\) which has overwritten matrix A, and the upper triangular matrix \(R \text{.}\) (The values below the diagonal can be arbitrary.) You may want to use Assignments/Week03/matlab/test_MGS_QR.m to check your implementation.