Skip to main content
Contents
Dark Mode Prev Up Next
\(\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\dimens}{\operatorname{dim}}
\DeclareMathOperator{\row}{\operatorname{row}}
\DeclareMathOperator{\col}{\operatorname{col}}
\newcommand{\im}{\operatorname{im}}
\newcommand{\nulls}{\operatorname{null}}
\newcommand{\minor}{\operatorname{minor}}
\newcommand{\spans}{\operatorname{span}}
\newcommand{\nullity}{\operatorname{nullity}}
\newcommand{\kers}{\operatorname{ker}}
\newcommand{\proj}{\operatorname{proj}}
\newcommand{\diag}{\operatorname{diag}}
\newcommand{\Tr}{\operatorname{Tr}}
\newcommand{\rank}{\operatorname{rank}}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 4.6 Exercises
Exercise tags. The tags below identify the primary outcomes and competency types for each exercise group. Individual problems may also involve earlier outcomes.
Subsection Orthogonality and orthogonal bases
Primary outcomes. U4-LO1, U4-LO2.
Competencies. P+C.
Subsection Orthogonal projection and Gram-Schmidt
Primary outcomes. U4-LO2, U4-LO3.
Competencies. P+C.
Nicholson 8.1.1(d) math.libretexts.org/Bookshelves/Linear_Algebra/Linear_Algebra_with_Applications_(Nicholson)/08%3A_Orthogonality/8.01%3A_Orthogonal_Complements_and_Projections/8.1E%3A_Orthogonal_Complements_and_Projections_Exercises
Nicholson 8.1.2(b,d) math.libretexts.org/Bookshelves/Linear_Algebra/Linear_Algebra_with_Applications_(Nicholson)/08%3A_Orthogonality/8.01%3A_Orthogonal_Complements_and_Projections/8.1E%3A_Orthogonal_Complements_and_Projections_Exercises
Nicholson 8.1.4(b) math.libretexts.org/Bookshelves/Linear_Algebra/Linear_Algebra_with_Applications_(Nicholson)/08%3A_Orthogonality/8.01%3A_Orthogonal_Complements_and_Projections/8.1E%3A_Orthogonal_Complements_and_Projections_Exercises
Subsection QR factorization and least squares
Primary outcomes. U4-LO6.
Competencies. P+R.
Subsection Additional applied and computational problems
These exercises connect the main Unit 4 ideas: orthogonality, orthogonal bases, projections, residuals, least squares, normal equations, regression, QR factorization, and code interpretation. Solutions are collected in Appendix
C.4 .
Checkpoint 4.6.1 . Orthogonal-basis coefficients.
Let
\begin{equation*}
\mathbf{f}_1 =
\begin{bmatrix}1\\1\\0\end{bmatrix},\quad
\mathbf{f}_2 =
\begin{bmatrix}1\\-1\\0\end{bmatrix},\quad
\mathbf{f}_3 =
\begin{bmatrix}0\\0\\2\end{bmatrix},
\end{equation*}
and let
\begin{equation*}
\mathbf{x} =
\begin{bmatrix}3\\1\\4\end{bmatrix}.
\end{equation*}
Verify that
\(\mathbf{f}_1,\mathbf{f}_2,\mathbf{f}_3\) are pairwise orthogonal.
Use dot products to write
\(\mathbf{x}\) as a linear combination of
\(\mathbf{f}_1,\mathbf{f}_2,\mathbf{f}_3\text{.}\)
Explain why each dot product isolates one coefficient.
Tags. [U4-LO1, U4-LO2 | P+C+R | Core]
Checkpoint 4.6.2 . Projection onto a line.
Let
\begin{equation*}
\mathbf{u} = \begin{bmatrix}1\\2\end{bmatrix},\quad
\mathbf{x} = \begin{bmatrix}3\\1\end{bmatrix},
\end{equation*}
and let \(L = \operatorname{span}\{\mathbf{u}\}\text{.}\)
Compute
\(\operatorname{proj}_L(\mathbf{x})\text{.}\)
Compute
\(\mathbf{r} = \mathbf{x} - \operatorname{proj}_L(\mathbf{x})\text{.}\)
Check that
\(\mathbf{r} \cdot \mathbf{u} = 0\text{.}\)
Explain what the residual measures.
Tags. [U4-LO3 | P+C | Core]
Checkpoint 4.6.3 . Column-space orthogonal complement.
Let
\begin{equation*}
A =
\begin{bmatrix}
1\amp 0\\
0\amp 1\\
1\amp 1
\end{bmatrix}.
\end{equation*}
Compute
\(A^T\mathbf{r}\) for
\(\mathbf{r} = \begin{bmatrix}-1\\-1\\1\end{bmatrix}\text{.}\)
Explain why
\(\mathbf{r}\) is orthogonal to
\(\operatorname{col}(A)\text{.}\)
Describe
\(\operatorname{col}(A)^\perp\text{.}\)
Explain the identity
\(\operatorname{col}(A)^\perp = \operatorname{null}(A^T)\) in this example.
Tags. [U4-LO3, U4-LO4, U2-LO3 | C+R | Core]
Checkpoint 4.6.4 . Projection onto a plane.
Let \(U\) be the plane \(x + y + z = 0\text{,}\) and let
\begin{equation*}
\mathbf{p} = \begin{bmatrix}1\\2\\4\end{bmatrix}.
\end{equation*}
Give a normal vector
\(\mathbf{n}\) for
\(U\text{.}\)
Compute
\(\operatorname{proj}_U(\mathbf{p})\) by subtracting the component of
\(\mathbf{p}\) in the normal direction.
Check that the projected point lies in
\(U\text{.}\)
Tags. [U4-LO3 | P+C+R | Core]
Checkpoint 4.6.5 . Unreachable target, closest output.
Let
\begin{equation*}
A =
\begin{bmatrix}
1\amp 0\\
0\amp 1\\
1\amp 1
\end{bmatrix},
\qquad
\mathbf{b} = \begin{bmatrix}2\\1\\5\end{bmatrix}.
\end{equation*}
Explain why
\(A\mathbf{x} = \mathbf{b}\) has no exact solution.
Form
\(A^T A\) and
\(A^T\mathbf{b}\text{.}\)
Solve the normal equations.
Compute
\(A\hat{\mathbf{x}}\) and
\(\mathbf{r} = \mathbf{b} - A\hat{\mathbf{x}}\text{.}\)
Check
\(A^T\mathbf{r} = \mathbf{0}\text{.}\)
Tags. [U4-LO4, U4-LO5, U2-LO3 | P+C+R | Core]
Checkpoint 4.6.6 . Regression design matrix and residual.
Fit a line \(y = c_0 + c_1 t\) to the data
\begin{equation*}
(0,1),\quad (1,2),\quad (2,2).
\end{equation*}
Build the design matrix
\(X\text{.}\)
Form
\(X^T X\) and
\(X^T\mathbf{y}\text{.}\)
Solve the normal equations.
Compute the fitted values and residual.
Check
\(X^T\mathbf{r} = \mathbf{0}\text{.}\)
Tags. [U4-LO5 | P+C+M | Core]
Checkpoint 4.6.7 . Code interpretation: residual orthogonality.
xhat = np.linalg.lstsq(A, b, rcond=None)[0]
r = b - A @ xhat
A.T @ r
Suppose the output of the last line is approximately
array([2.2e-16, -1.1e-16]).
What does
xhat represent?
What does
\(\mathbf{r}\) represent?
What geometric condition does
A.T @ r check?
Does this output mean
\(\mathbf{r}\) is the zero vector?
Tags. [U4-LO4, U4-LO7 | C+T | Core]
Checkpoint 4.6.8 . Debug: wrong residual check.
A student tries to check residual orthogonality with
What is the shape problem when
\(A\) is
\(m\) by
\(n\) and
\(\mathbf{r}\) is in
\(\mathbb R^m\text{?}\)
Even if the dimensions happened to match, why would
A @ r be the wrong check?
State the correct residual-orthogonality check.
Tags. [U4-LO4, U4-LO7 | C+R+T | Core]
Checkpoint 4.6.9 . Rank and nonunique coefficients.
Let
\begin{equation*}
A =
\begin{bmatrix}
1\amp 0\amp 1\\
0\amp 1\amp 1\\
1\amp 1\amp 2
\end{bmatrix},
\end{equation*}
and let \(\mathbf{z} = \begin{bmatrix}1\\1\\-1\end{bmatrix}\text{.}\)
Compute
\(A\mathbf{z}\text{.}\)
Suppose
\(\hat{\mathbf{x}}\) is a least-squares solution. Compare
\(A\hat{\mathbf{x}}\) and
\(A(\hat{\mathbf{x}} + 5\mathbf{z})\text{.}\)
Which can be nonunique: the fitted vector or the coefficient vector?
How does this connect to dependent columns?
Tags. [U4-LO4, U2-LO6 | C+R | Core]
Checkpoint 4.6.10 . QR code reading.
Q, R = np.linalg.qr(A)
x_qr = np.linalg.solve(R, Q.T @ b)
x_lstsq = np.linalg.lstsq(A, b, rcond=None)[0]
Q.T @ Q, x_qr, x_lstsq
What should
Q.T @ Q be close to?
Why does the code solve a system with
R?
Why should
x_qr and
x_lstsq agree when
\(A\) has independent columns?
Does this prove
\(A\mathbf{x} = \mathbf{b}\) has an exact solution?
Tags. [U4-LO6, U4-LO7 | C+T | Core]
Checkpoint 4.6.11 . Attention versus projection.
Classify each phrase as attention-like, projection-like, or both.
Forms a weighted average of value vectors.
Finds the closest vector in a subspace.
Produces a residual orthogonal to a subspace.
Normalizes scores into weights.
Can be checked by
\(A^T\mathbf{r} = \mathbf{0}\text{.}\)
Tags. [U4-LO1, U4-LO3, U4-LO4 | C+M | Core]