Reading settings

Font
Color

Fall 2026 Midterm 2

This page is meant to give you quick access to problems and their solutions. Refer to the original exam PDF, linked above, for test-taking instructions and formatting. Note that we’ve kept the problem text identical, which is why you may see things like “write your answer in the box below” despite there not being a box on this page.


Problems


Problem 1 10 pts

Let

$$ A=\begin{bmatrix}6&\alpha\\\\8&12\end{bmatrix} $$

Each part below is independent. Find the value of \(\alpha\) that satisfies the given condition.

a)

3 pts \(\det(A)=40\).

Solution

For this \(2\times2\) matrix,

$$ \det(A)=6(12)-8\alpha=72-8\alpha $$

Thus,

$$ 72-8\alpha=40\quad\Longrightarrow\quad\boxed{\alpha=4} $$
b)

3 pts \(\text{rank}(A)=1\).

Solution

Since \(A\) is a nonzero \(2\times2\) matrix, it has rank \(1\) exactly when its determinant is \(0\). Therefore,

$$ 72-8\alpha=0\quad\Longrightarrow\quad\boxed{\alpha=9} $$

For this value, the second column is \(3/2\) times the first column.

c)

4 pts \(A^{-1}=\begin{bmatrix}3/2&-1\\-1&3/4\end{bmatrix}\).

Solution

The inverse formula gives

$$ A^{-1}=\frac{1}{72-8\alpha}\begin{bmatrix}12&-\alpha\\\\-8&6\end{bmatrix} $$

Matching the top-left entry gives

$$ \frac{12}{72-8\alpha}=\frac32 \quad\Longrightarrow\quad72-8\alpha=8 \quad\Longrightarrow\quad\boxed{\alpha=8} $$

Substituting \(\alpha=8\) gives all four entries of the specified inverse.


Problem 2 10 pts

Let

$$ B=\begin{bmatrix}2&2&2\\\\3&-3&0\\\\1&1&-2\end{bmatrix} $$
a)

4 pts Find \(BB^T\).

Solution

The entries of \(BB^T\) are the dot products of the rows of \(B\). The three rows are mutually orthogonal, and their squared lengths are

$$ 2^2+2^2+2^2=12,\qquad 3^2+(-3)^2=18,\qquad 1^2+1^2+(-2)^2=6 $$

Hence,

$$ \boxed{BB^T=\begin{bmatrix}12&0&0\\\\0&18&0\\\\0&0&6\end{bmatrix}} $$
b)

6 pts Find \(B^{-1}\). Fully simplify each entry. Hint: Use part (a), not \(\det(B)\) or a \(3\times3\) inverse formula. If \(BB^T=C\), what is \(B^{-1}\)?

Solution

Let \(C=BB^T\). Since \(C\) is invertible,

$$ B(B^TC^{-1})=(BB^T)C^{-1}=CC^{-1}=I $$

Thus, \(B^{-1}=B^TC^{-1}\). Using part (a),

$$ B^{-1} =\begin{bmatrix}2&3&1\\\\2&-3&1\\\\2&0&-2\end{bmatrix} \begin{bmatrix}1/12&0&0\\\\0&1/18&0\\\\0&0&1/6\end{bmatrix} =\boxed{\begin{bmatrix}1/6&1/6&1/6\\\\1/6&-1/6&1/6\\\\1/6&0&-1/3\end{bmatrix}} $$

Problem 3 16 pts

Let \(X=CR\), where \(a,b\) are unknown scalars. Furthermore, suppose that

$$ C=\begin{bmatrix}4&0\\\\-2&5\\\\3&-1\\\\0&6\end{bmatrix},\qquad R=\begin{bmatrix}1&3&a&-2&5\\\\0&4&8&b&0\end{bmatrix},\qquad \begin{bmatrix}-5\\\\0\\\\1\\\\-2\\\\1\end{bmatrix}\in\text{nullsp}(X) $$
a)

4 pts Determine the following values.

\(\text{rank}(X)=\) ______

\(\dim(\text{nullsp}(X))=\) ______

Solution

The columns of \(C\) are independent, and the rows of \(R\) are independent. This CR factorization therefore has \(\text{rank}(X)=2\). Since \(X\) has five columns, rank-nullity gives \(\dim(\text{nullsp}(X))=5-2=3\).

b)

8 pts Find \(a\) and \(b\).

Solution

Let \(\vec v\) be the given vector in \(\text{nullsp}(X)\). Then \(CR\vec v=\vec0\). Since the columns of \(C\) are linearly independent, this requires \(R\vec v=\vec0\). Therefore,

$$ R\vec v=\begin{bmatrix}-5+a+4+5\\\\8-2b\end{bmatrix} =\begin{bmatrix}a+4\\\\8-2b\end{bmatrix}=\vec0 $$

It follows that \(\boxed{a=-4,\ b=4}\).

c)

4 pts Which of the following choices of columns of \(X\) form a basis for \(\text{colsp}(X)\)? Select all that apply.

Columns 1 and 2

Columns 1 and 5

Columns 2 and 3

Columns 3 and 4

Columns 4 and 5

Columns 1, 2, and 3

Solution
Columns 1 and 2 Columns 1 and 5 Columns 2 and 3 Columns 3 and 4 Columns 4 and 5 Columns 1, 2, and 3

Because \(C\) has linearly independent columns, we can check independence using the corresponding columns of \(R\), with \(a=-4\) and \(b=4\). Columns \(1\) and \(5\) are scalar multiples, as are columns \(3\) and \(4\). Each remaining listed pair is independent.

Since \(\text{rank}(X)=2\), the valid bases are columns 1 and 2, columns 2 and 3, and columns 4 and 5. Three columns cannot form a basis for this two-dimensional space.


Problem 4 16 pts

Let

$$ A=\begin{bmatrix} 0&0&1&0\\\\ 1&0&0&0\\\\ 0&1&0&0\\\\ 0&0&0&-1 \end{bmatrix},\qquad \vec v=\begin{bmatrix}1\\\\2\\\\3\\\\4\end{bmatrix} $$
a)

2 pts Find \(A\vec v\).

Solution

Multiplying by \(A\) cycles the first three components and negates the fourth:

$$ A\begin{bmatrix}v_1\\\\v_2\\\\v_3\\\\v_4\end{bmatrix} =\begin{bmatrix}v_3\\\\v_1\\\\v_2\\\\-v_4\end{bmatrix} \quad\Longrightarrow\quad \boxed{A\vec v=\begin{bmatrix}3\\\\1\\\\2\\\\-4\end{bmatrix}} $$
b)

2 pts What is the smallest positive integer \(k\) such that \(A^k=I\)?

2 3 4 6 8 12
Solution
2 3 4 6 8 12

The first three components return to their original positions after a multiple of \(3\) applications of \(A\). The fourth returns to its original sign after an even number of applications. The smallest positive integer divisible by both \(3\) and \(2\) is \(\boxed{k=6}\).

c)

6 pts Give one basis for \(\text{nullsp}(A-I)\).

Solution

A vector is in \(\text{nullsp}(A-I)\) exactly when \(A\vec x=\vec x\). Componentwise,

$$ x_3=x_1,\qquad x_1=x_2,\qquad x_2=x_3,\qquad -x_4=x_4 $$

Thus, \(x_1=x_2=x_3\) and \(x_4=0\). Every vector in the null space is a multiple of \(\begin{bmatrix}1\\1\\1\\0\end{bmatrix}\), so one basis is

$$ \boxed{\left\{\begin{bmatrix}1\\\\1\\\\1\\\\0\end{bmatrix}\right\}} $$

Recall,

$$ A=\begin{bmatrix} 0&0&1&0\\\\ 1&0&0&0\\\\ 0&1&0&0\\\\ 0&0&0&-1 \end{bmatrix} $$
d)

6 pts Applying \(A\) to a vector \(\vec x\) changes its components by the amounts shown below:

$$ A\vec x-\vec x=\begin{bmatrix}m\\\\-3\\\\5\\\\2\end{bmatrix} $$
  1. 4 pts Find \(m\). Your answer should be a number with no variables.

    Solution

    Applying \(A\) rearranges the first three components, so their sum does not change. Their changes must therefore sum to zero:

    $$ m+(-3)+5=0\quad\Longrightarrow\quad\boxed{m=-2} $$
  2. 2 pts For this value of \(m\), how many vectors \(\vec x\) satisfy \(A\vec x-\vec x=\begin{bmatrix}m\\-3\\5\\2\end{bmatrix}\)?

    0 1 2 3 4 Infinitely many
    Solution
    0 1 2 3 4 Infinitely many

    There are infinitely many solutions. One particular solution is \(\begin{bmatrix}0\\3\\-2\\-1\end{bmatrix}\). Adding any vector in \(\text{nullsp}(A-I)\) preserves the product with \(A-I\), giving

    $$ \vec x=\begin{bmatrix}0\\\\3\\\\-2\\\\-1\end{bmatrix} +t\begin{bmatrix}1\\\\1\\\\1\\\\0\end{bmatrix},\qquad t\in\mathbb R $$

Problem 5 16 pts

Let

$$ X=\begin{bmatrix}1&4\\\\2&3\\\\2&4\\\\0&2\end{bmatrix},\qquad \vec q_1=\frac13\begin{bmatrix}1\\\\2\\\\2\\\\0\end{bmatrix} $$

We would like to find orthogonal unit vectors \(\vec q_1,\vec q_2\in\mathbb R^4\) such that

$$ \text{span}(\{\vec q_1,\vec q_2\})=\text{colsp}(X) $$
a)

6 pts Find one possible \(\vec q_2\).

Solution

Let \(\vec x_2\) be the second column of \(X\). Remove its component in the direction of \(\vec q_1\):

$$ \vec q_1\cdot\vec x_2=\frac{4+6+8}{3}=6 $$
$$ \vec u_2=\vec x_2-6\vec q_1 =\begin{bmatrix}4\\\\3\\\\4\\\\2\end{bmatrix} -\begin{bmatrix}2\\\\4\\\\4\\\\0\end{bmatrix} =\begin{bmatrix}2\\\\-1\\\\0\\\\2\end{bmatrix} $$

Since \(|\vec u_2|=\sqrt{4+1+4}=3\), one answer is

$$ \boxed{\vec q_2=\frac13\begin{bmatrix}2\\\\-1\\\\0\\\\2\end{bmatrix}} $$

This is a unit vector orthogonal to \(\vec q_1\). The first column of \(X\) is \(3\vec q_1\), and its second column is \(6\vec q_1+3\vec q_2\), so the two unit vectors span \(\text{colsp}(X)\). The negative of this \(\vec q_2\) is also valid.

For the remaining parts, suppose \(Q\) has orthonormal columns \(\vec q_1,\vec q_2\in\mathbb R^4\). You do not need your answer to part (a). Let

$$ Q=\begin{bmatrix}|&|\\\\\vec q_1&\vec q_2\\\\|&|\end{bmatrix},\qquad Z=\begin{bmatrix}|&|\\\\\vec q_1+\vec q_2&\vec q_1-\vec q_2\\\\|&|\end{bmatrix} $$

and suppose \(\vec y\in\mathbb R^4\) satisfies

$$ Q^T\vec y=\begin{bmatrix}3\\\\1\end{bmatrix} $$
b)

2 pts Is \(\vec y\in\text{colsp}(Q)\)?

Yes No Impossible to tell
Solution
Yes No Impossible to tell

Impossible to tell. The vector \(\vec y_0=3\vec q_1+\vec q_2\) is in \(\text{colsp}(Q)\) and has the specified product with \(Q^T\).

There are also nonzero vectors \(\vec r\) orthogonal to \(\text{colsp}(Q)\), since this is a two-dimensional subspace of \(\mathbb R^4\). Then \(\vec y_0+\vec r\) is outside \(\text{colsp}(Q)\) but has the same product with \(Q^T\), because \(Q^T\vec r=\vec0\). Both possibilities are consistent with the information given.

Recall that \(Q\) has orthonormal columns, and

$$ Z=\begin{bmatrix}|&|\\\\\vec q_1+\vec q_2&\vec q_1-\vec q_2\\\\|&|\end{bmatrix},\qquad Q^T\vec y=\begin{bmatrix}3\\\\1\end{bmatrix} $$
c)

4 pts Which choice gives both the vector \(\vec w^\ast\) that minimizes \(|\vec y-Z\vec w|^2\) and the resulting projection, \(\vec p=Z\vec w^\ast\)?

A. \(\vec w^\ast=\begin{bmatrix}3\\1\end{bmatrix},\quad \vec p=3\vec q_1+\vec q_2\)

B. \(\vec w^\ast=\begin{bmatrix}2\\1\end{bmatrix},\quad \vec p=3\vec q_1+\vec q_2\)

C. \(\vec w^\ast=\begin{bmatrix}3\\1\end{bmatrix},\quad \vec p=4\vec q_1+2\vec q_2\)

D. \(\vec w^\ast=\begin{bmatrix}2\\1\end{bmatrix},\quad \vec p=2\vec q_1+\vec q_2\)

E. \(\vec w^\ast=\begin{bmatrix}1\\2\end{bmatrix},\quad \vec p=3\vec q_1+\vec q_2\)

Solution
A. \(\vec w^\ast=\begin{bmatrix}3\\1\end{bmatrix},\quad \vec p=3\vec q_1+\vec q_2\) B. \(\vec w^\ast=\begin{bmatrix}2\\1\end{bmatrix},\quad \vec p=3\vec q_1+\vec q_2\) C. \(\vec w^\ast=\begin{bmatrix}3\\1\end{bmatrix},\quad \vec p=4\vec q_1+2\vec q_2\) D. \(\vec w^\ast=\begin{bmatrix}2\\1\end{bmatrix},\quad \vec p=2\vec q_1+\vec q_2\) E. \(\vec w^\ast=\begin{bmatrix}1\\2\end{bmatrix},\quad \vec p=3\vec q_1+\vec q_2\)

B. Adding and subtracting the columns of \(Z\) recovers \(2\vec q_1\) and \(2\vec q_2\), so \(Z\) and \(Q\) have the same column space. Hence,

$$ \boxed{\vec p=QQ^T\vec y=3\vec q_1+\vec q_2} $$

But \(Z\vec w=(w_1+w_2)\vec q_1+(w_1-w_2)\vec q_2\). Independence of \(\vec q_1,\vec q_2\) therefore requires

$$ w_1^\ast+w_2^\ast=3,\qquad w_1^\ast-w_2^\ast=1 \quad\Longrightarrow\quad \boxed{\vec w^\ast=\begin{bmatrix}2\\\\1\end{bmatrix}} $$

\(Q^T\vec y\) gives coefficients in \(Q\)’s columns, while \(\vec w^\ast\) gives coefficients in \(Z\)’s columns.

d)

4 pts Identify whether each statement is true or false.

  1. 2 pts For every \(\vec x\in\mathbb R^2\), \(Q^TQ\vec x=\vec x\).

    True False
    Solution
    True False

    True. Orthonormal columns give \(Q^TQ=I_2\), so \(Q^TQ\vec x=\vec x\) for every \(\vec x\in\mathbb R^2\).

  2. 2 pts \(QQ^T\) is invertible.

    True False
    Solution
    True False

    False. \(QQ^T\) is \(4\times4\), and its columns lie in the two-dimensional space \(\text{colsp}(Q)\). Its rank is at most \(2\), so it is not invertible.


Problem 6 14 pts

Suppose we’d like to fit a multiple linear regression model to predict the daily electricity use of household \(i\), \(y_i\), in kilowatt-hours.

For each household \(i\), the feature vector is \(\vec x_i=\begin{bmatrix}x_i^{(1)}\\x_i^{(2)}\end{bmatrix}\), where:

  • \(x_i^{(1)}\) is the number of residents.

  • \(x_i^{(2)}\) is \(2\) if the household uses a heat pump and \(0\) if it uses gas heating.

Our model is

$$ h(\vec x_i)=w_0+w_1x_i^{(1)}+w_2x_i^{(2)} $$

The dataset below has two unknown values, \(a\) and \(b\).

\(i\)Residents (\(x_i^{(1)}\))Heating source (\(x_i^{(2)}\))Electricity use (\(y_i\))
12\(a\)12
25230
32216
440\(b\)
53016
a)

4 pts Write the design matrix \(X\). Your answer should be a matrix in terms of \(a\) and constants.

Solution

The intercept contributes a column of ones, followed by the residents and heating-source features:

$$ \boxed{X=\begin{bmatrix}1&2&a\\\\1&5&2\\\\1&2&2\\\\1&4&0\\\\1&3&0\end{bmatrix}} $$

Recall, our model is \(h(\vec x_i)=w_0+w_1x_i^{(1)}+w_2x_i^{(2)}\), where \(x_i^{(1)}\) is the number of residents and \(x_i^{(2)}\) is \(2\) for a heat pump and \(0\) for gas heating.

\(i\)Residents (\(x_i^{(1)}\))Heating source (\(x_i^{(2)}\))Electricity use (\(y_i\))
12\(a\)12
25230
32216
440\(b\)
53016
b)

10 pts The parameter vector that minimizes mean squared error is \(\vec w^\ast=\begin{bmatrix}3\\4\\3\end{bmatrix}\).

Find \(a\) and \(b\). Your answers should be numbers with no variables.

Hint: What properties must the error vector satisfy?

Solution

The predictions and errors are

$$ X\vec w^\ast=\begin{bmatrix}11+3a\\\\29\\\\17\\\\19\\\\15\end{bmatrix},\qquad \vec e=\vec y-X\vec w^\ast=\begin{bmatrix}1-3a\\\\1\\\\-1\\\\b-19\\\\1\end{bmatrix} $$

At a least-squares solution, \(\vec e\) is orthogonal to every column of \(X\). Orthogonality to the intercept column gives

$$ (1-3a)+1-1+(b-19)+1=0\quad\Longrightarrow\quad b-17-3a=0 $$

Orthogonality to the residents column gives

$$ 2(1-3a)+5-2+4(b-19)+3=0\quad\Longrightarrow\quad4b-68-6a=0 $$

Substituting \(b=17+3a\) into the second equation gives \(6a=0\). Thus,

$$ \boxed{a=0,\qquad b=17} $$

These values give \(\vec e=\begin{bmatrix}1\\1\\-1\\-2\\1\end{bmatrix}\), which is also orthogonal to the heating-source column: \(2(1)+2(-1)=0\). All the normal equations are satisfied.


Problem 7 18 pts

Let \(\vec x\in\mathbb R^2\), and consider

$$ A=\begin{bmatrix}2&1\\\\1&2\end{bmatrix},\qquad f(\vec x)=\left(\vec x^TA\vec x-1\right)^2 $$
a)

6 pts

  1. 2 pts Which of the following is the fully simplified expression for \(\nabla f(\vec x)\)?

    \(2(\vec x^TA\vec x-1)A\vec x\) \(4(\vec x^TA\vec x-1)\vec x\) \(4(\vec x^TA\vec x-1)A\vec x\) \(4(\vec x^TA\vec x)A\vec x\)
    Solution
    \(2(\vec x^TA\vec x-1)A\vec x\) \(4(\vec x^TA\vec x-1)\vec x\) \(4(\vec x^TA\vec x-1)A\vec x\) \(4(\vec x^TA\vec x)A\vec x\)

    The third expression is correct.

  2. 4 pts Justify your answer.

    Solution

    Let \(g(\vec x)=\vec x^TA\vec x-1\), so \(f(\vec x)=g(\vec x)^2\). Since \(A\) is symmetric,

    $$ \nabla g(\vec x)=(A+A^T)\vec x=2A\vec x $$

    The chain rule gives

    $$ \boxed{\nabla f(\vec x)=2g(\vec x)\nabla g(\vec x)=4(\vec x^TA\vec x-1)A\vec x} $$
b)

4 pts Identify whether each statement is true or false. Hint: There is no need to think about second partial derivatives.

  1. 2 pts \(f\) is convex.

    True False
    Solution
    True False

    False. Consider

    $$ \vec u=\begin{bmatrix}1/\sqrt2\\\\0\end{bmatrix},\qquad \vec v=\begin{bmatrix}-1/\sqrt2\\\\0\end{bmatrix} $$

    Both satisfy \(\vec x^TA\vec x=1\), so \(f(\vec u)=f(\vec v)=0\).

    Their midpoint is \(\vec0\), but

    $$ f\left(\frac{\vec u+\vec v}{2}\right)=f(\vec0)=1> \frac{f(\vec u)+f(\vec v)}{2}=0 $$

    This violates the defining inequality for a convex function.

  2. 2 pts \(f\) attains its global minimum at exactly one vector.

    True False
    Solution
    True False

    False. Since \(f\) is a square, it is always nonnegative. The two vectors from part (i) both attain \(0\), so the global minimizer is not unique.

Recall, \(\vec x\in\mathbb R^2\) and

$$ A=\begin{bmatrix}2&1\\\\1&2\end{bmatrix},\qquad f(\vec x)=\left(\vec x^TA\vec x-1\right)^2 $$
c)

8 pts We run gradient descent on \(f\) twice, starting from the same unknown vector \(\vec x^{(0)}\).

  • With step size \(\alpha=\frac14\), the first iteration gives \(\vec x^{(1)}=\frac14\begin{bmatrix}-14\\1\end{bmatrix}\).

  • With step size \(\alpha=\frac34\), the first iteration gives \(\vec x^{(1)}=\frac14\begin{bmatrix}-54\\11\end{bmatrix}\).

Find \(\vec x^{(0)}\). Your answer should be a vector with no variables. You can answer this part without using your answer to part (a).

Solution

Let \(\vec g=\nabla f(\vec x^{(0)})\). Both runs have the same gradient at their starting point. The update rule gives

$$ \vec x^{(0)}-\frac14\vec g=\frac14\begin{bmatrix}-14\\\\1\end{bmatrix},\qquad \vec x^{(0)}-\frac34\vec g=\frac14\begin{bmatrix}-54\\\\11\end{bmatrix} $$

Multiply the first equation by \(3\) and subtract the second to eliminate \(\vec g\):

$$ 2\vec x^{(0)}=\frac14\left(3\begin{bmatrix}-14\\\\1\end{bmatrix}-\begin{bmatrix}-54\\\\11\end{bmatrix}\right) =\begin{bmatrix}3\\\\-2\end{bmatrix} $$

Therefore,

$$ \boxed{\vec x^{(0)}=\begin{bmatrix}3/2\\\\-1\end{bmatrix}} $$