Skip to main content

MATH 345: Linear Algebra and Optimization

Section 5.9 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 Directional derivatives and gradient descent

Primary outcomes. U5-LO2, U5-LO3. Competencies. P+C+T.

Subsection Symmetric matrices and quadratic forms

Primary outcomes. U5-LO4, U5-LO5. Competencies. P+C.
  • Nicholson 8.2.5(b,d,f)
     5 
    math.libretexts.org/Bookshelves/Linear_Algebra/Linear_Algebra_with_Applications_(Nicholson)/08%3A_Orthogonality/8.02%3A_Orthogonal_Diagonalization/8.2E%3A_Orthogonal_Diagonalization_Exercises

Subsection Hessians and the second derivative test

Primary outcomes. U5-LO1, U5-LO5. Competencies. P+C.

Subsection Additional applied and computational problems

These exercises connect the main Unit 5 ideas: critical points, directional derivatives, gradient descent, eigenvectors, Hessian eigenvalues, quadratic forms, least squares from gradients, fixed-hidden-layer training, and code interpretation. Solutions are collected in Appendix C.5.

Checkpoint 5.9.2. Directional derivative as a dot product.

Suppose
\begin{equation*} \nabla f(\mathbf{a})= \begin{bmatrix} 6\\ 8 \end{bmatrix}. \end{equation*}
Let
\begin{equation*} \mathbf{v}_1= \begin{bmatrix} 1\\ 0 \end{bmatrix}, \qquad \mathbf{v}_2= \begin{bmatrix} 0\\ 1 \end{bmatrix}, \qquad \mathbf{v}_3= \frac{1}{5} \begin{bmatrix} 3\\ 4 \end{bmatrix}, \qquad \mathbf{v}_4= -\frac{1}{5} \begin{bmatrix} 3\\ 4 \end{bmatrix}. \end{equation*}
  1. Compute \(D_{\mathbf{v}_i}f(\mathbf{a})\) for \(i=1,2,3,4\text{.}\)
  2. Which listed direction gives the largest directional derivative?
  3. Which listed direction gives the smallest directional derivative?
  4. Explain how this uses the Unit 1 dot product.
Tags. [U5-LO2 | P+C+R | Core]

Checkpoint 5.9.3. Reading a gradient descent loop.

Assume grad_f(x) computes \(\nabla f(\mathbf{x})\text{.}\) Consider the code:
x = x0
for k in range(num_steps):
    x = x - alpha * grad_f(x)
  1. What mathematical update rule is represented?
  2. Which quantity is the learning rate?
  3. What shape must grad_f(x) have?
  4. What would change if the minus sign were a plus sign?
  5. Does this code prove that a minimum has been found?
Tags. [U5-LO2, U5-LO3 | C+T | Core]

Checkpoint 5.9.4. Learning-rate diagnosis.

For \(f(x)=x^2\text{,}\) start at \(x_0=4\) and use
\begin{equation*} x_{k+1}=x_k-\alpha f'(x_k). \end{equation*}
The table shows the loss values \(f(x_k)\) for three learning rates.
\begin{equation*} \begin{array}{c|ccc} k \amp \alpha=0.05 \amp \alpha=0.20 \amp \alpha=1.05\\ \hline 0 \amp 16.000 \amp 16.000 \amp 16.000\\ 1 \amp 12.960 \amp 5.760 \amp 19.360\\ 2 \amp 10.498 \amp 2.074 \amp 23.426\\ 3 \amp 8.503 \amp 0.746 \amp 28.345 \end{array} \end{equation*}
  1. Which learning rate is making slow but steady progress?
  2. Which learning rate is making faster useful progress?
  3. Which learning rate appears unstable?
  4. Does a decreasing loss table prove that the global minimum has been found?
Tags. [U5-LO3 | C+T | Core]

Checkpoint 5.9.5. Eigenvectors as special directions.

Let
\begin{equation*} A= \begin{bmatrix} 3\amp1\\ 0\amp2 \end{bmatrix}, \qquad \mathbf{v}_1= \begin{bmatrix} 1\\ 0 \end{bmatrix}, \qquad \mathbf{v}_2= \begin{bmatrix} -1\\ 1 \end{bmatrix}. \end{equation*}
  1. Compute \(A\mathbf{v}_1\text{.}\)
  2. Compute \(A\mathbf{v}_2\text{.}\)
  3. Identify the eigenvalue for each eigenvector.
  4. Explain what the matrix map does to these two special directions.
Tags. [U5-LO4 | P+C+R | Core]

Checkpoint 5.9.6. Quadratic form and definiteness.

Let
\begin{equation*} H= \begin{bmatrix} 4\amp0\\ 0\amp1 \end{bmatrix}. \end{equation*}
  1. Compute \(\mathbf{h}^T H\mathbf{h}\) for
    \begin{equation*} \mathbf{h}= \begin{bmatrix} 1\\ 0 \end{bmatrix}, \qquad \mathbf{h}= \begin{bmatrix} 0\\ 1 \end{bmatrix}, \qquad \mathbf{h}= \begin{bmatrix} 1\\ 1 \end{bmatrix}. \end{equation*}
  2. Write \(\mathbf{h}^T H\mathbf{h}\) for a general vector
    \begin{equation*} \mathbf{h}= \begin{bmatrix} h_1\\ h_2 \end{bmatrix}. \end{equation*}
  3. Is \(H\) positive definite, negative definite, or indefinite?
  4. If \(H\) is the Hessian at a critical point, what does the second derivative test conclude?
Tags. [U5-LO4, U5-LO5 | P+C | Core]

Checkpoint 5.9.7. Hessian eigenvalue classification.

Suppose \(\mathbf{a}\) is a critical point of a scalar-valued function \(f\text{.}\) For each possible list of Hessian eigenvalues, classify the critical point as a local minimum, local maximum, saddle point, or inconclusive.
  1. \(\displaystyle 3,5\)
  2. \(\displaystyle -2,-7\)
  3. \(\displaystyle 4,-1\)
  4. \(\displaystyle 0,2\)
  5. Explain why the zero eigenvalue case is different.
Tags. [U5-LO5 | C+R | Core]

Checkpoint 5.9.8. Least squares from gradients.

Let
\begin{equation*} A= \begin{bmatrix} 1\amp0\\ 1\amp1\\ 1\amp2 \end{bmatrix}, \qquad \mathbf{b}= \begin{bmatrix} 1\\ 2\\ 2 \end{bmatrix}. \end{equation*}
Define
\begin{equation*} h(\mathbf{x})=\|A\mathbf{x}-\mathbf{b}\|^2. \end{equation*}
  1. Compute \(A^T A\) and \(A^T\mathbf{b}\text{.}\)
  2. Use \(\nabla h(\mathbf{x})=2A^T(A\mathbf{x}-\mathbf{b})\) to write the normal equations.
  3. Solve the normal equations.
  4. Compute the residual \(\mathbf{r}=\mathbf{b}-A\hat{\mathbf{x}}\text{.}\)
  5. Check that \(A^T\mathbf{r}=\mathbf{0}\text{.}\)
Tags. [U5-LO6, U4-LO4 | P+C+R | Core]

Checkpoint 5.9.10. Fixed-hidden-layer design matrix.

Let \(\sigma(t)=\tanh(t)\text{,}\) and define
\begin{equation*} N_{\mathbf{c}}(t)=c_0+c_1\sigma(t)+c_2\sigma(t-1)+c_3\sigma(t+1). \end{equation*}
Use the input values \(t=-1,0,1\text{.}\)
  1. Write the design matrix \(A\) for the model \(A\mathbf{c}\approx \mathbf{y}\text{.}\)
  2. Which vector is trained?
  3. Why is this a least-squares problem?
  4. Is the model linear as a function of \(t\text{?}\)
  5. Is the model linear as a function of \(\mathbf{c}\text{?}\)
Tags. [U5-LO6, U5-LO7 | C+M+R | Core]

Checkpoint 5.9.11. Rank-one update.

Let
\begin{equation*} \mathbf{g}= \begin{bmatrix} 1\\ -2\\ 3 \end{bmatrix}, \qquad \mathbf{h}= \begin{bmatrix} 4\\ 0 \end{bmatrix}. \end{equation*}
  1. Compute \(\mathbf{g}\mathbf{h}^T\text{.}\)
  2. What is the shape of \(\mathbf{g}\mathbf{h}^T\text{?}\)
  3. Explain why \(\mathbf{g}\mathbf{h}^T\) has rank at most one.
  4. Interpret the update \(W_{\mathrm{new}}=W-\alpha \mathbf{g}\mathbf{h}^T\text{.}\)
  5. In NumPy, why is np.outer(g, h) appropriate when g and h are stored as one-dimensional arrays?
Tags. [U5-LO7, U2-LO3 | P+C+T | Core]