Homework 10: Diagonalization

due Sunday, December 6th, 2026 at 11:59PM Ann Arbor Time

Other than the video link for Problem 1 and the notebook for Problem 8, write your solutions by hand, on paper or on a tablet, and submit them as one PDF. Include your Problem 7f screenshot in that PDF. Submit your Problem 1 video link and your Problem 8 notebook separately on Pensive. Note that you are not allowed to use LaTeX, Google Docs, or any other digital document creation software to type your answers. Homeworks are due to Pensive by 11:59PM on the due date. See the syllabus for details on the slip day policy.

Homework will be evaluated not only on the correctness of your answers, but on your ability to present your ideas clearly and logically. You should always explain and justify your conclusions, using sound reasoning. Your goal should be to convince the reader of your assertions. If a question does not require explanation, it will be explicitly stated.

Before proceeding, make sure you’re familiar with the collaboration policy.


Problems


Total Points: \(8 + 8 + 8 + 15 + 12 + 15 + 22 + 12 = 100\)


Problem 1: Homework 9 Concept Video (8 pts)

Record a 2- to 5-minute video answering one of the prompts below. These prompts are related to the ideas in Homework 9.

  1. You fit two polynomial regression models to the same training data, one of degree 2 and one of degree 20. Explain why the higher-degree model can have lower training mean squared error and higher test mean squared error at the same time.

  2. Suppose you one-hot encode a categorical feature and fit a linear regression model with an intercept. What happens to the design matrix if you keep every one-hot-encoded column? Explain why dropping one of those columns can fix that dependence without changing the predictions the model can represent.

  3. Suppose a real matrix has an eigenvector with eigenvalue \(-2\). Explain what multiplying by the matrix does to that vector and to any nonzero scalar multiple of it. What happens to the original eigenvector when you multiply by the matrix twice?

The video should be just you speaking into the camera. Your face must be visible while you are talking for the entire video. Do not include slides, a screen recording, written work, or any other visuals.

Submit your video link to the separate assignment on Pensive called Homework 10, Problem 1 Video Link. You can upload your video to YouTube as unlisted, share a Zoom recording link, or share a Google Drive link; whatever works. Make sure the course staff can view the video using that link.

Your submission time for Homework 10 is the latest of your three submission times: your Problem 1 video link, your PDF, and your Problem 8 notebook.

This problem is graded on completion. Record a video of the required length and make an honest effort to explain the question, and you will receive full credit. Your explanation does not need to be polished or perfect.


Note: Repeatedly, you’ll be asked to find eigenvalues and eigenvectors. As usual, you’re expected to show all of your work. But, you’re encouraged to verify your answers by using np.linalg.eig in Python, as is demonstrated in Chapter 9.1. (Resist the urge to use ChatGPT...)


Problem 2: Rank One Projection Matrices (8 pts)

Consider the unit vector \(\vec u = \begin{bmatrix} 1/6 \\ 1/6 \\ 3/6 \\ 5/6 \end{bmatrix}\), and the corresponding rank one projection matrix \(P = \vec u \vec u^T\).

a)

(2 pts) Show that \(\vec u\) is an eigenvector of \(P\). What is its corresponding eigenvalue?

b)

(2 pts) Show that if \(\vec v\) is orthogonal to \(\vec u\), then \(\vec v\) is an eigenvector of \(P\). What is its corresponding eigenvalue?

c)

(4 pts) Find three different linearly independent eigenvectors of \(P\), all corresponding to the eigenvalue 0.

These three eigenvectors form a basis of the eigenspace of \(P\) corresponding to eigenvalue 0.


Problem 3: Recovering Eigenvector Components (8 pts)

Suppose \(S\) is a \(2 \times 2\) symmetric matrix whose eigenvalues are \(1\) and \(3\). You are given a vector \(\vec x\) and the result of multiplying it by \(S\):

$$ \vec x=\begin{bmatrix}2\\\\4\end{bmatrix} \qquad S\vec x=\begin{bmatrix}6\\\\4\end{bmatrix} $$

Write \(\vec x=\vec v_1+\vec v_2\), where \(\vec v_1\) is an eigenvector corresponding to \(\lambda=1\) and \(\vec v_2\) is an eigenvector corresponding to \(\lambda=3\).

a)

(2 pts) Express \(S\vec x\) as a linear combination of \(\vec v_1\) and \(\vec v_2\).

b)

(4 pts) Use the two given vectors to find \(\vec v_1\) and \(\vec v_2\). Verify that \(\vec v_1\) and \(\vec v_2\) are orthogonal, as the Spectral Theorem in Chapter 9.5 guarantees.

c)

(2 pts) Find \(S^4\vec x\) using your vectors from part b).


Problem 4: Algebraic and Geometric Multiplicities (15 pts)

For each matrix below:

  1. Find its characteristic polynomial in factored form.

  2. State all eigenvalues along with their algebraic multiplicities.

  3. For each eigenvalue, find a basis for the eigenspace corresponding to that eigenvalue, and state its geometric multiplicity.

Some advice:

  • There are multiple examples of what you’re asked to do in Chapter 9.4.

  • Recall the trace and determinant tricks from Chapter 9.2, and the fact that the determinant of an upper triangular matrix is the product of the diagonal entries.

  • Work efficiently: this problem is quicker than it seems.

a)

(3 pts) \(A = \begin{bmatrix} 3 & 0 & 0 \\ 0 & 4 & 0 \\ 0 & 0 & 4 \end{bmatrix}\)

b)

(3 pts) \(A = \begin{bmatrix} 3 & 1 \\ 0 & 3 \end{bmatrix}\)

c)

(3 pts) \(A = \begin{bmatrix} 2 & 0 & 1 \\ 0 & 2 & 1 \\ 0 & 0 & 3 \end{bmatrix}\)

d)

(3 pts) \(A = \begin{bmatrix} 5 & 0 & 0 & 0 \\ 0 & 3 & 1 & 0 \\ 0 & 0 & 3 & 0 \\ 0 & 0 & 0 & 5 \end{bmatrix}\)

e)

(3 pts) \(A = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 \end{bmatrix}\)


Problem 5: Diagonalization (12 pts)

Before proceeding, it’s wise to read Chapter 9.4.

a)

(3 pts) In each statement, fill in the blanks and provide a brief justification. Each answer is more than just one word or number.

  1. \(A\) is diagonalizable if and only if it has ____ eigenvectors.

  2. \(A\) is diagonalizable if and only if the geometric multiplicity of each eigenvalue is ____.

b)

(9 pts) For each matrix \(A\) in Problem 4:

  • if it is diagonalizable, find matrices \(V\) and \(\Lambda\) such that \(A = V \Lambda V^{-1}\). (As we saw in Chapter 9.4, this matrix is constructed by placing the eigenvectors of \(A\) as the columns of \(V\) and the eigenvalues of \(A\) as the diagonal entries of \(\Lambda\). You should have already done most of the work for this; this problem is just a matter of organizing your work.)

  • if not, explain why it is not diagonalizable.


Problem 6: Adjacency Matrices (15 pts)

Consider the matrix

$$ A = \begin{bmatrix} 0.6 & 0.2 & 0.4 \\\\ 0.3 & 0.7 & 0.2 \\\\ 0.1 & 0.1 & 0.4 \end{bmatrix} $$

\(A\) represents the adjacency matrix of a Markov chain with three states; see Chapter 9.3 for details.

a)

(3 pts) Draw the corresponding state diagram for \(A\). Label the states 1, 2, and 3.

b)

(3 pts) Diagonalize \(A\) by finding matrices \(V\) and \(\Lambda\) such that \(A = V \Lambda V^{-1}\). Do this by hand, but then include a screenshot of numpy code that verifies that you found the correct \(V\) and \(\Lambda\).

c)

(3 pts) Compute \(A^{10}\) using the diagonalization you found in part b). Hint: You should not have to multiply ten matrices by hand: only three. State what the three matrices are, and then you can use numpy to actually multiply them. Include a screenshot of any code you write and its output.

d)

(3 pts) Let \(\vec x_0 = \begin{bmatrix} 0.6 \\ 0.3 \\ 0.1 \end{bmatrix}\) be an initial state vector. Using numpy, compute \(A^{10} \vec x_0\). Include a screenshot of any code you write and its output.

e)

(3 pts) As \(k \to \infty\), what does \(A^k \vec x_0\) converge to, and why? Make sure your answer references the diagonalization you found in part b).


Problem 7: Regularization (22 pts)

Suppose we’d like to perform multiple linear regression using the \(n \times (d+1)\) design matrix \(X\), observation vector \(\vec y \in \mathbb{R}^n\), and parameter vector \(\vec w \in \mathbb{R}^{d+1}\).

Instead of minimizing mean squared error to find \(\vec w^{\ast}\), suppose we’d like to minimize the following regularized objective function:

$$ R_\text{ridge}(\vec w) = \lVert \vec y - X \vec w \rVert^2 + \lambda \lVert \vec w \rVert^2 $$

where \(\lambda \geq 0\) is a constant. The \(+ \lambda \lVert \vec w \rVert^2\) term is called the regularization term.

The vector \(\vec w_\text{ridge}^{\ast}\) that minimizes \(R_\text{ridge}(\vec w)\) will be, in general, different than the vector \(\vec w^{\ast}\) that minimizes mean squared error without the added \(+ \lambda \lVert \vec w \rVert^2\) term, and will thus have a higher mean squared error on the training data.

But, it turns out that \(\vec w_\text{ridge}^{\ast}\) may make better predictions on unseen test data, if we choose \(\lambda\) carefully, by forcing the model to be simpler and less overfit to the training data. Let’s explore this idea in more depth.

a)

(5 pts) Find \(\nabla R_\text{ridge}(\vec w)\), the gradient of \(R_\text{ridge}(\vec w)\).

Hint: Most of the steps involved were done in Chapter 8.2, but you’ll need to redo the work yourself and extend it slightly.

b)

(3 pts) Find \(\vec w_\text{ridge}^{\ast}\), the vector that minimizes \(R_\text{ridge}(\vec w)\).

Hint: Your answer should be such that if \(\lambda = 0\) and \(X\) has full column rank, then \(\vec w_\text{ridge}^{\ast}\) is the same as the vector \(\vec w^{\ast}\) that minimizes mean squared error without the added \(+ \lambda \lVert \vec w \rVert^2\) term.

One of the side benefits of adding this regularization term is that a unique solution for \(\vec w_\text{ridge}^{\ast}\) exists for all \(\lambda > 0\), even if \(X\) is not full rank. That’s a bold claim: let’s prove it.

c)

(4 pts) Prove that all of the eigenvalues of \(X^TX\) are non-negative. (This means that \(X^TX\) is positive semidefinite.)

Hint: Suppose \(\vec v_i\) is an eigenvector of \(X^TX\) with eigenvalue \(\lambda_i\). From there, if you get stuck, take a look at this seemingly unrelated proof from Chapter 5.4 for inspiration.

d)

(3 pts) Suppose \(\vec v_i\) is an eigenvector of \(X^TX\) with eigenvalue \(\lambda_i\). Show that \(\vec v_i\) is also an eigenvector of \(X^TX + \lambda I\). What is its corresponding eigenvalue?

e)

(3 pts) Putting parts c) and d) together, why is it guaranteed that \(X^TX+ \lambda I\) is invertible for all \(\lambda > 0\), even if \(X\) is not full rank? (\(X^TX + \lambda I\) is said to be positive definite for all \(\lambda > 0\).)

f)

(4 pts) Now, let’s explore how adding the regularization term \(\lambda \lVert \vec w \rVert^2\) to the objective function affects the shape of the loss surface.

Open the supplemental Jupyter Notebook we’ve created for Homework 10, which can either be found here in the course GitHub repository or here on DataHub.

This problem is not autograded. Instead,

  1. Read through the entire walkthrough, all the way through the end of Problem 7f).

  2. In this PDF, include a screenshot of the diagram with a slider, showing that you’ve moved it all the way to the right, at \(\lambda = 100000\).

  3. In this PDF, include answers to both of the following questions:

    • Why is it called ridge regression?

    • How does the inclusion of the \(\lambda \lVert \vec w \rVert^2\) term change the convexity of the loss surface?

If you’d like to read more about regularization, and how we actually choose the value of \(\lambda\) in practice, read more from EECS 398 here.


Problem 8: PageRank (12 pts)

This problem involves writing code and submitting it to the Pensive autograder. The goal of this problem is to allow you to implement Google’s PageRank algorithm in code and think through some of its pitfalls and variants.

There are two ways to access the supplemental Jupyter Notebook:

  • Option 1: Set up a Jupyter Notebook environment locally, use git to clone our course repository, and open homeworks/hw10/hw10.ipynb. For instructions on how to do this, see the Tech Support page of the course website.

  • Option 2: Click here to open hw10.ipynb on DataHub. Before doing so, read the instructions on the Tech Support page on how to use the DataHub.

This problem is entirely autograded. Submit your completed notebook to Homework 10, Problem 8 Code on Pensive.