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 2.7 Exercises
Learning outcomes. The labels below identify the learning outcomes for each exercise group. Individual problems may also involve earlier outcomes.
Subsection Systems, geometry, and row reduction
Learning outcomes. U2-LO1, U2-LO2.
Subsection Subspaces
Learning outcomes. U2-LO3, U2-LO4.
Subsection Independence, bases, and dimension
Learning outcomes. U2-LO4.
Subsection Rank and nullity
Learning outcomes. U2-LO3, U2-LO4, U2-LO6.
Subsection Inverses and determinants
Learning outcomes. U2-LO5, U2-LO7.
Subsection Additional exercises
These exercises connect the main Unit 2 ideas through short applied computations: reachable outputs, forgotten directions, row reduction, subspaces, rank, nullity, redundant features, inverses, determinants, and code interpretation. Solutions are collected in Appendix
C.2 .
Additional exercise 2.7.1 . Projection and forgotten height in code.
A sensor records only horizontal position. It keeps the first two coordinates and drops height.
import numpy as np
P = np.array([
[1., 0., 0.],
[0., 1., 0.],
])
x = np.array([2., 1., 5.])
z = np.array([0., 0., 1.])
rank = np.linalg.matrix_rank(P)
nullity = P.shape[1] - rank
P @ x, P @ (x + 6*z), P @ z, rank, nullity
(array([2., 1.]), array([2., 1.]), array([0., 0.]), 2, 1)
What does
\(P\) do to an input vector?
Why do
\(P\mathbf{x}\) and
\(P(\mathbf{x}+6\mathbf{z})\) agree?
What does
\(P\mathbf{z}=\mathbf{0}\) say about the direction
\(\mathbf{z}\text{?}\)
Interpret the rank and nullity.
Why can the original input not be recovered uniquely from the output?
Learning outcomes. U2-LO3, U2-LO6.
Additional exercise 2.7.2 . Reachable outputs from augmented rref.
\begin{equation*}
A=
\begin{bmatrix}
1\amp0\\
0\amp1\\
1\amp1
\end{bmatrix},
\qquad
\mathbf{b}_1=
\begin{bmatrix}
1\\
2\\
3
\end{bmatrix},
\qquad
\mathbf{b}_2=
\begin{bmatrix}
1\\
2\\
4
\end{bmatrix}.
\end{equation*}
The following code row-reduces the augmented matrices for
\begin{equation*}
A\mathbf{x}=\mathbf{b}_1
\qquad\text{and}\qquad
A\mathbf{x}=\mathbf{b}_2.
\end{equation*}
import sympy as sp
M1 = sp.Matrix([
[1, 0, 1],
[0, 1, 2],
[1, 1, 3],
])
M2 = sp.Matrix([
[1, 0, 1],
[0, 1, 2],
[1, 1, 4],
])
M1.rref(), M2.rref()
((Matrix([
[1, 0, 1],
[0, 1, 2],
[0, 0, 0]]), (0, 1)),
(Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]]), (0, 1, 2)))
Read the two rref matrices as
\begin{equation*}
\left[
\begin{array}{cc|c}
1\amp0\amp1\\
0\amp1\amp2\\
0\amp0\amp0
\end{array}
\right],
\qquad
\left[
\begin{array}{cc|c}
1\amp0\amp0\\
0\amp1\amp0\\
0\amp0\amp1
\end{array}
\right].
\end{equation*}
Which target vector is reachable?
Which target vector is not reachable?
What row shows inconsistency?
What does a pivot to the right of the vertical line mean?
For the reachable target, give one input
\(\mathbf{x}\text{.}\)
Learning outcomes. U2-LO1, U2-LO2, U2-LO3.
Additional exercise 2.7.3 . Line of intersection from an rref output.
\begin{equation*}
x+y+z=1,
\qquad
-x+2y-3z=-1.
\end{equation*}
The following code row-reduces the augmented matrix for the system.
import sympy as sp
M = sp.Matrix([
[1, 1, 1, 1],
[-1, 2, -3, -1],
])
M.rref()
(Matrix([
[1, 0, 5/3, 1],
[0, 1, -2/3, 0]]), (0, 1))
\begin{equation*}
\left[
\begin{array}{ccc|c}
1\amp0\amp5/3\amp1\\
0\amp1\amp-2/3\amp0
\end{array}
\right].
\end{equation*}
Write
\(x\) and
\(y\) in terms of
\(z\text{.}\)
Let
\(z=t\text{.}\) Write the solution set in parametric vector form.
Why is the solution set a line?
How does this connect to the intersection of two planes?
Learning outcomes. U2-LO1, U2-LO2.
Additional exercise 2.7.4 . Plane through three points from a null-space computation.
\begin{equation*}
P=(1,1,-2),
\qquad
Q=(0,2,1),
\qquad
R=(-1,-1,0).
\end{equation*}
Two displacement vectors in the plane are
\begin{equation*}
\overrightarrow{PQ}
=
\begin{bmatrix}
-1\\
1\\
3
\end{bmatrix},
\qquad
\overrightarrow{PR}
=
\begin{bmatrix}
-2\\
-2\\
2
\end{bmatrix}.
\end{equation*}
A normal vector
\(\mathbf{n}\) must be perpendicular to both displacement vectors. The following code solves for such directions.
import sympy as sp
M = sp.Matrix([
[-1, 1, 3],
[-2, -2, 2],
])
M.nullspace()
[Matrix([
[ 2],
[-1],
[ 1]])]
What do the rows of
\(M\) represent?
Why does a vector in
\(\operatorname{null}(M)\) give a normal vector to the plane?
Use the output to choose a normal vector
\(\mathbf{n}\text{.}\)
Write an equation of the plane.
Learning outcomes. U2-LO1, U2-LO2, U2-LO3.
Additional exercise 2.7.5 . Reading a null-space basis in code.
The following code asks SymPy for a basis of a null space.
import sympy as sp
A = sp.Matrix([
[1, 2, 3],
[2, 4, 6],
[0, 1, 1],
])
A.nullspace()
[Matrix([
[-1],
[-1],
[ 1]])]
\begin{equation*}
\mathbf{z}
=
\begin{bmatrix}
-1\\
-1\\
1
\end{bmatrix}.
\end{equation*}
Is
\(\mathbf{z}\) an input direction or an output direction?
Verify that
\(A\mathbf{z}=\mathbf{0}\text{.}\)
If
\(A\mathbf{x}=\mathbf{y}\text{,}\) compute
\(A(\mathbf{x}+t\mathbf{z})\text{.}\)
What does this say about uniqueness of inputs?
Learning outcomes. U2-LO3, U2-LO6.
Additional exercise 2.7.6 . Redundant square-footage features in code.
Rows represent houses. The columns are first-level area, second-level area, and total area, measured in hundreds of square feet.
import numpy as np
X = np.array([
[9., 7., 16.],
[11., 9., 20.],
[14., 0., 14.],
[8., 8., 16.],
])
z = np.array([1., 1., -1.])
c = np.array([3., 1., 0.])
c_alt = np.array([2., 0., 1.])
rank = np.linalg.matrix_rank(X)
X @ z, rank, X @ c, X @ c_alt
(array([0., 0., 0., 0.]), 2, array([34., 42., 42., 32.]), array([34., 42., 42., 32.]))
What feature relation does
\(X\mathbf{z}=\mathbf{0}\) show?
What does
\(\operatorname{rank}(X)=2\) say about the three feature columns?
Why do
\(X\mathbf{c}\) and
\(X\mathbf{c}_{\mathrm{alt}}\) agree?
What warning does this give about interpreting individual coefficients?
In this example, why is it not clear whether first-level area, second-level area, or total area is the βmost importantβ feature?
Learning outcomes. U2-LO3, U2-LO6.
Additional exercise 2.7.7 . Difference matrix: levels versus changes.
The following matrix computes consecutive differences in a short time series.
import numpy as np
D = np.array([
[-1., 1., 0., 0.],
[0., -1., 1., 0.],
[0., 0., -1., 1.],
])
x = np.array([2., 5., 9., 10.])
ones = np.ones(4)
D @ x, D @ (x + 10*ones), D @ ones, np.linalg.matrix_rank(D)
(array([3., 4., 1.]), array([3., 4., 1.]), array([0., 0., 0.]), 3)
What does
\(D\mathbf{x}\) measure?
Why do
\(D\mathbf{x}\) and
\(D(\mathbf{x}+10\mathbf{1})\) agree?
What input direction does
\(D\) forget?
What does the rank say about the three output differences?
What is the nullity of
\(D\text{?}\)
Learning outcomes. U2-LO3, U2-LO6.
Additional exercise 2.7.8 . Debugging a column-space basis from code.
A student computes an rref and pivot columns.
import sympy as sp
A = sp.Matrix([
[1, 2, 3],
[2, 4, 6],
[0, 1, 1],
])
R, pivots = A.rref()
R, pivots
(Matrix([
[1, 0, 1],
[0, 1, 1],
[0, 0, 0]]), (0, 1))
\begin{equation*}
\text{``Columns 1 and 2 of }R\text{ are a basis for }\operatorname{col}(A).\text{''}
\end{equation*}
What do the pivot indices
(0, 1) mean in mathematical column numbering?
What is wrong with using columns of
\(R\) as a basis for
\(\operatorname{col}(A)\text{?}\)
Which matrix should supply the basis vectors?
Write a basis for
\(\operatorname{col}(A)\text{.}\)
Learning outcomes. U2-LO3, U2-LO4.
Additional exercise 2.7.9 . Invertibility gallery in code.
The following code checks determinant and rank for five
\(2\times 2\) matrices from the Unit 1 transformation gallery.
import numpy as np
mats = [
np.array([[0., 0.], [0., 1.]]),
np.array([[-1., 0.], [0., 1.]]),
np.array([[1., 1.], [0., 1.]]),
np.array([[0., -1.], [1., 0.]]),
np.array([[1., 0.], [0., 0.]]),
]
[(float(np.linalg.det(A)), np.linalg.matrix_rank(A)) for A in mats]
[(0.0, 1), (-1.0, 2), (1.0, 2), (1.0, 2), (0.0, 1)]
Which matrices are invertible?
Which matrices forget a nonzero input direction?
How does determinant detect singularity here?
How does rank detect singularity here?
For each singular matrix, name one direction that is forgotten.
Learning outcomes. U2-LO5, U2-LO7.
Additional exercise 2.7.10 . Reading an inverse-computation output.
The following code row-reduces
\([A\mid I_3]\text{.}\)
import sympy as sp
A = sp.Matrix([
[1, 1, 4],
[2, 3, 2],
[0, 0, 1],
])
M = A.row_join(sp.eye(3))
M.rref()
(Matrix([
[1, 0, 0, 3, -1, -10],
[0, 1, 0, -2, 1, 6],
[0, 0, 1, 0, 0, 1]]), (0, 1, 2))
\begin{equation*}
\left[
\begin{array}{ccc|ccc}
1\amp0\amp0\amp3\amp-1\amp-10\\
0\amp1\amp0\amp-2\amp1\amp6\\
0\amp0\amp1\amp0\amp0\amp1
\end{array}
\right].
\end{equation*}
What does the left side of the vertical line show?
Read off
\(A^{-1}\text{.}\)
Why does row-reducing
\([A\mid I_3]\) give the inverse?
Learning outcomes. U2-LO5, U2-LO7.