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 3.8 Exercises
Subsection OpenStax practice
Exercise tags. The tags below identify the primary outcomes and competency types for each exercise group. Individual problems may also involve earlier outcomes.
Subsubsection General functions and domains
Primary outcomes. U3-LO1.
Competencies. P+R+C.
Subsubsection One-parameter maps and changes
Primary outcomes. U3-LO1, U3-LO2.
Competencies. P+R.
Subsubsection Partial derivatives, gradients, Hessians, and Jacobian matrices
Primary outcomes. U3-LO2, U3-LO3.
Competencies. P.
Subsubsection Local linearization and tangent planes
Primary outcomes. U3-LO4, U3-LO5.
Competencies. P+C.
Subsubsection Chain rule as matrix multiplication
Primary outcomes. U3-LO6.
Competencies. P+R.
Subsubsection Additional conceptual, geometric, and computational checkpoints
These checkpoints cover Unit 3 ideas not fully represented in the OpenStax practice: scalar-valued and vector-valued functions, domains, local language, derivatives, gradients, Hessians, Jacobian matrices, tangent planes, local linear prediction, the chain rule, and code interpretation. Solutions are collected in Appendix
C.3 .
Checkpoint 3.8.1 . Function type and component functions.
Let
\begin{equation*}
F(x,y)=
\begin{bmatrix}
x^2+y\\
e^{x-y}\\
x-y
\end{bmatrix}.
\end{equation*}
Is
\(F\) scalar-valued or vector-valued?
What are the domain and codomain?
Write the component functions
\(F_1,F_2,F_3\text{.}\)
Compute
\(F(1,0)\text{.}\)
What should be the shape of
\(J_F(1,0)\text{?}\)
Tags. [U3-LO1, U3-LO3 | C+R | Core]
Checkpoint 3.8.2 . Domain, boundary, closed, and bounded.
Let
\begin{equation*}
D=\{(x,y)\in\mathbb R^2:x\ge 0,\ y>x^2\}.
\end{equation*}
Explain why this is the domain of
\(f(x,y)=\ln(y-x^2)+\sqrt{x}\text{.}\)
Give one interior point of
\(D\text{.}\)
Give one boundary point of
\(D\text{.}\)
Tags. [U3-LO1, U3-LO2 | C+R | Core]
Checkpoint 3.8.3 . One-parameter map and tangent vector.
Let
\begin{equation*}
\mathbf r(t)=
\begin{bmatrix}
1\\
0\\
-1
\end{bmatrix}
+t
\begin{bmatrix}
2\\
-1\\
3
\end{bmatrix}.
\end{equation*}
Compute
\(\mathbf r(2)\text{.}\)
Compute
\(\mathbf r'(t)\text{.}\)
What does
\(\mathbf r'(t)\) say about the curve?
How does this connect to the Unit 2 parametric equation of a line?
Tags. [U3-LO2, U2-LO1 | P+R | Core]
Checkpoint 3.8.4 . Gradient and Hessian.
Let
\begin{equation*}
f(x,y)=x^2+xy+2y^2.
\end{equation*}
Compute
\(f_x\) and
\(f_y\text{.}\)
Compute
\(\nabla f(1,-1)\text{.}\)
Compute
\(H_f(x,y)\text{.}\)
Is the Hessian symmetric?
What does each entry of
\(\nabla f(1,-1)\) measure?
Tags. [U3-LO3 | P+C+R | Core]
Checkpoint 3.8.5 . Jacobian matrix rows and columns.
Let
\begin{equation*}
F(x,y)=
\begin{bmatrix}
x^2y\\
xe^y
\end{bmatrix},
\qquad
\mathbf a=
\begin{bmatrix}
1\\
0
\end{bmatrix}.
\end{equation*}
Compute
\(J_F(x,y)\text{.}\)
Compute
\(J_F(\mathbf a)\text{.}\)
What are the input and output dimensions?
Which row corresponds to the second component of
\(F\text{?}\)
What do the two columns of
\(J_F(\mathbf a)\) measure?
Tags. [U3-LO3, U3-LO5, U1-LO4 | P+C+R | Core]
Checkpoint 3.8.6 . Tangent plane as a Unit 2 plane.
Let
\begin{equation*}
f(x,y)=x^2+xy.
\end{equation*}
Compute
\(f(1,2)\text{,}\) \(f_x(1,2)\text{,}\) and
\(f_y(1,2)\text{.}\)
Write the tangent plane to
\(z=f(x,y)\) at
\((1,2,f(1,2))\text{.}\)
Rewrite the tangent plane in the form
\begin{equation*}
\mathbf n\cdot
\begin{bmatrix}
x-1\\
y-2\\
z-f(1,2)
\end{bmatrix}
=0.
\end{equation*}
Identify a normal vector
\(\mathbf n\text{.}\)
Which Unit 2 idea is being reused?
Tags. [U3-LO4, U2-LO1 | P+R | Core]
Checkpoint 3.8.7 . Scalar local linear prediction.
Use the same function \(f(x,y)=x^2+xy\) at
\begin{equation*}
\mathbf a=
\begin{bmatrix}
1\\
2
\end{bmatrix},
\qquad
\mathbf h=
\begin{bmatrix}
0.1\\
-0.2
\end{bmatrix}.
\end{equation*}
Compute
\(f(\mathbf a)\text{.}\)
Compute
\(\nabla f(\mathbf a)\text{.}\)
Compute the local linear prediction
\(f(\mathbf a)+\nabla f(\mathbf a)^T\mathbf h\text{.}\)
Compute the actual value
\(f(\mathbf a+\mathbf h)\text{.}\)
Compare the actual value with the prediction.
Tags. [U3-LO4, U3-LO5 | P+C+R | Core]
Checkpoint 3.8.8 . Vector-valued local linear prediction.
Use
\begin{equation*}
F(x,y)=
\begin{bmatrix}
x^2y\\
xe^y
\end{bmatrix},
\qquad
\mathbf a=
\begin{bmatrix}
1\\
0
\end{bmatrix},
\qquad
\mathbf h=
\begin{bmatrix}
0.1\\
-0.2
\end{bmatrix}.
\end{equation*}
Compute
\(F(\mathbf a)\text{.}\)
Compute
\(F(\mathbf a)+J_F(\mathbf a)\mathbf h\text{.}\)
Compute
\(F(\mathbf a+\mathbf h)\text{.}\)
What does the error vector measure?
Tags. [U3-LO5 | P+C+R | Core]
Checkpoint 3.8.9 . Locally forgotten direction.
Suppose
\begin{equation*}
J_F(\mathbf a)=
\begin{bmatrix}
1&2\\
2&4
\end{bmatrix}.
\end{equation*}
Find a nonzero vector
\(\mathbf h\) such that
\(J_F(\mathbf a)\mathbf h=\mathbf 0\text{.}\)
What does this say about the local linear map?
How does this connect to Unit 2 null spaces?
Does this prove that
\(F(\mathbf a+\mathbf h)=F(\mathbf a)\) exactly? Explain.
Tags. [U3-LO5, U2-LO3, U2-LO6 | C+R | Core]
Checkpoint 3.8.10 . Chain-rule shape check.
Suppose
\begin{equation*}
G:\mathbb R^2\to\mathbb R^3,
\qquad
F:\mathbb R^3\to\mathbb R^2.
\end{equation*}
What is the shape of
\(J_G(\mathbf a)\text{?}\)
What is the shape of
\(J_F(G(\mathbf a))\text{?}\)
What is the shape of
\(J_{F\circ G}(\mathbf a)\text{?}\)
Which product gives
\(J_{F\circ G}(\mathbf a)\text{?}\)
Why is the reverse order not correct?
Tags. [U3-LO6, U1-LO6 | C+R | Core]
Checkpoint 3.8.11 . Reading a tiny sigmoid block.
def sigmoid(t):
return 1 / (1 + np.exp(-t))
s = W1 @ x + b1
u = sigmoid(s)
D = np.diag(u * (1 - u))
y = W2 @ u + b2
J_at_x = W2 @ D @ W1
Which lines are affine maps?
Which line contains the coordinatewise nonlinear step?
Which variables represent vectors?
Which line computes the Jacobian matrix of the block at
\(\mathbf{x}\text{?}\)
Why is the whole block usually not one linear map?
Tags. [U3-LO7, U1-LO7 | C+R+T | Core]
Checkpoint 3.8.12 . Corners are not enough.
Let
\begin{equation*}
T\left(\begin{bmatrix}x\\y\end{bmatrix}\right)
=
\begin{bmatrix}
x+y\\
y
\end{bmatrix},
\qquad
F\left(\begin{bmatrix}x\\y\end{bmatrix}\right)
=
\begin{bmatrix}
x+y^2\\
y
\end{bmatrix}.
\end{equation*}
Compute the images of the four corners of the unit square under
\(T\text{.}\)
Compute the images of the four corners of the unit square under
\(F\text{.}\)
Compute the images of
\(\begin{bmatrix}0\\1/2\end{bmatrix}\) under both maps.
Explain why the four corners do not prove that two maps are the same.
Explain why a grid gives more information than the four corners.
Tags. [U3-LO1, U1-LO5 | C+R | Core]
Checkpoint 3.8.13 . Local square-grid error.
Let
\begin{equation*}
F\left(\begin{bmatrix}x\\y\end{bmatrix}\right)
=
\begin{bmatrix}
x+y^2\\
y
\end{bmatrix},
\qquad
\mathbf{a}
=
\begin{bmatrix}
0\\
1/2
\end{bmatrix}.
\end{equation*}
Compute
\(J_F(x,y)\text{.}\)
Compute
\(J_F(\mathbf{a})\text{.}\)
Let
\(\mathbf{h}=\begin{bmatrix}h_1\\h_2\end{bmatrix}\text{.}\) Compute
\(F(\mathbf{a}+\mathbf{h})-F(\mathbf{a})\text{.}\)
Compute
\(J_F(\mathbf{a})\mathbf{h}\text{.}\)
Compute the error
\begin{equation*}
F(\mathbf{a}+\mathbf{h})-F(\mathbf{a})-J_F(\mathbf{a})\mathbf{h}.
\end{equation*}
If
\(|h_2|\le r\text{,}\) explain why the error goes to zero as
\(r\to 0\text{.}\)
Tags. [U3-LO3, U3-LO5 | P+C+R | Core]
Checkpoint 3.8.14 . Code interpretation: square-grid arrays.
import numpy as np
def F(P):
x = P[0, :]
y = P[1, :]
return np.vstack([x + y**2, y])
P = np.array([
[0.0, 1.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 1.0, 0.5],
])
Q = F(P)
Q
What is the shape of
\(P\text{?}\)
Are input points stored as rows or columns?
Which column stores
\(\begin{bmatrix}0\\1/2\end{bmatrix}\text{?}\)
What is the corresponding output column of
\(Q\text{?}\)
What does the expression
np.vstack([x + y**2, y]) construct?
Why is this computation not a matrix multiplication?
Tags. [U3-LO1, U3-LO5, U1-LO8 | C+R+T | Core]
Checkpoint 3.8.15 . Sigmoid derivative and local matrix.
Let
\begin{equation*}
\sigma(t)=\frac{1}{1+e^{-t}},
\qquad
\sigma'(t)=\sigma(t)(1-\sigma(t)),
\end{equation*}
applied coordinatewise. Define
\begin{equation*}
W_1=
\begin{bmatrix}
1&0\\
0&1\\
1&1
\end{bmatrix},
\qquad
\mathbf{b}_1=
\begin{bmatrix}
0\\
0\\
0
\end{bmatrix},
\end{equation*}
\begin{equation*}
W_2=
\begin{bmatrix}
1&0&-1/2\\
0&1&1/2
\end{bmatrix},
\qquad
\mathbf{b}_2=
\begin{bmatrix}
0\\
0
\end{bmatrix}.
\end{equation*}
For
\begin{equation*}
\mathbf{x}
=
\begin{bmatrix}
x\\
y
\end{bmatrix},
\end{equation*}
set
\begin{equation*}
N(\mathbf{x})=W_2\sigma(W_1\mathbf{x}+\mathbf{b}_1)+\mathbf{b}_2.
\end{equation*}
Let
\begin{equation*}
\mathbf{a}
=
\begin{bmatrix}
0\\
0
\end{bmatrix}.
\end{equation*}
Compute
\(\mathbf{s}_{\mathbf a}=W_1\mathbf{a}+\mathbf{b}_1\text{.}\)
Compute
\(\mathbf{u}_{\mathbf a}=\sigma(\mathbf{s}_{\mathbf a})\text{.}\)
Compute
\(D_{\mathbf a}=\operatorname{diag}(\sigma'((\mathbf{s}_{\mathbf a})_1),\sigma'((\mathbf{s}_{\mathbf a})_2),\sigma'((\mathbf{s}_{\mathbf a})_3))\text{.}\)
Compute the local matrix
\(W_2D_{\mathbf a}W_1\text{.}\)
Is this local matrix invertible?
Let
\(\mathbf{c}=\begin{bmatrix}1\\0\end{bmatrix}\text{.}\) Which entries of
\(D_{\mathbf c}\) differ from entries of
\(D_{\mathbf a}\text{?}\)
Why can the local matrix change from one base point to another?
Tags. [U3-LO3, U3-LO5, U3-LO7 | C+R | Core]
Checkpoint 3.8.16 . Code interpretation: sigmoid block arrays.
import numpy as np
W1 = np.array([
[1.0, 0.0],
[0.0, 1.0],
[1.0, 1.0],
])
b1 = np.zeros((3, 1))
W2 = np.array([
[1.0, 0.0, -0.5],
[0.0, 1.0, 0.5],
])
b2 = np.zeros((2, 1))
def sigmoid(Z):
return 1 / (1 + np.exp(-Z))
def N(P):
S = W1 @ P + b1
U = sigmoid(S)
return W2 @ U + b2
P = np.array([
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0],
])
Q = N(P)
Q
What is the shape of
\(P\text{?}\)
Are input points stored as rows or columns?
What is the shape of
\(S=W_1P+\mathbf{b}_1\text{?}\)
What is the shape of
\(U=\sigma(S)\text{?}\)
Which line applies the nonlinear operation?
Compute the first column of
\(Q\text{.}\)
Why is the full computation not one matrix multiplication
\(AP\text{?}\)
Tags. [U3-LO5, U3-LO7, U1-LO8 | C+R+T | Core]
Checkpoint 3.8.17 . Softmax weights are data-dependent.
Let
\begin{equation*}
K=
\begin{bmatrix}
3&0\\
0&3\\
-3&-3
\end{bmatrix},
\qquad
V=
\begin{bmatrix}
1&0\\
0&1\\
0&0
\end{bmatrix}.
\end{equation*}
For
\begin{equation*}
\mathbf{q}
=
\begin{bmatrix}
q_1\\
q_2
\end{bmatrix},
\end{equation*}
define
\begin{equation*}
\mathbf{s}=K\mathbf{q},
\qquad
\boldsymbol{\alpha}(\mathbf{q})=\operatorname{softmax}(\mathbf{s}),
\qquad
F(\mathbf{q})=V^T\boldsymbol{\alpha}(\mathbf{q}).
\end{equation*}
Compute
\(\mathbf{s}\) in terms of
\(q_1\) and
\(q_2\text{.}\)
Compute
\(\boldsymbol{\alpha}(\mathbf{0})\text{.}\)
Compute
\(F(\mathbf{0})\text{.}\)
Explain why
\(F\) is not linear.
Explain why
\(F(\mathbf{q})\) is always a weighted average of the rows of
\(V\text{.}\)
Tags. [U3-LO1, U3-LO5, U3-LO7, U1-LO8 | C+R | Core]
Checkpoint 3.8.18 . Code interpretation: softmax square-grid arrays.
import numpy as np
K = np.array([
[3.0, 0.0],
[0.0, 3.0],
[-3.0, -3.0],
])
V = np.array([
[1.0, 0.0],
[0.0, 1.0],
[0.0, 0.0],
])
def softmax_columns(S):
S_shifted = S - S.max(axis=0, keepdims=True)
E = np.exp(S_shifted)
return E / E.sum(axis=0, keepdims=True)
def F(P):
S = K @ P
Alpha = softmax_columns(S)
return V.T @ Alpha
P = np.array([
[0.0, 1.0, 0.0, -1.0],
[0.0, 0.0, 1.0, -1.0],
])
Q = F(P)
Q
What is the shape of
\(P\text{?}\)
Are query vectors stored as rows or columns?
What is the shape of
\(S=KP\text{?}\)
What is the shape of
Alpha?
What is the shape of
\(Q\text{?}\)
Which line applies the nonlinear operation?
Why is the full computation not one matrix multiplication
\(AP\text{?}\)
Tags. [U3-LO5, U3-LO7, U1-LO8 | C+R+T | Core]
Checkpoint 3.8.19 . Reading square-grid behavior.
A square-grid diagram shows an input grid and its image under a map. Match each behavior with the most likely map type.
Grid lines bend smoothly because of a
\(y^2\) term.
Grid bends and compresses smoothly because sigmoid derivatives change with input.
The output points stay inside a triangle formed by three value vectors.
The four corners match a linear shear, but an edge midpoint does not.
The local matrix has form
\(W_2D_{\mathbf a}W_1\text{.}\)
The nonlinear step comes from softmax weights depending on input.
Nonlinear shear
\begin{equation*}
F\left(\begin{bmatrix}x\\y\end{bmatrix}\right)
=
\begin{bmatrix}
x+y^2\\
y
\end{bmatrix}.
\end{equation*}
Two-output sigmoid block
\begin{equation*}
N(\mathbf{x})=W_2\sigma(W_1\mathbf{x}+\mathbf{b}_1)+\mathbf{b}_2.
\end{equation*}
Attention-style softmax map
\begin{equation*}
F_{\mathrm{att}}(\mathbf{q})
=
V^T\operatorname{softmax}(K\mathbf{q}).
\end{equation*}
Match each behavior to Map A, Map B, or Map C.
Which map best shows why four corners alone can miss nonlinear behavior?
Which map best shows the chain rule for Jacobian matrices?
Which map best shows attention-style weighted averages?
What can a square-grid visualization show that four corners alone may miss?
Tags. [U3-LO1, U3-LO5, U3-LO7, U1-LO8 | C+R | Core]