Homework 5

Table of Contents

The following assignment is due Thursday 10/10 by 11:59 PM. You should submit all your written solutions to Gradescope as a single pdf. Follow the instructions in the programming problem for code solutions.

1. Matrix Multiplication

Compute each of the following matrix multiplications. Show your work and/or explain your answer. Your work and/or explanation cannot include using sympy.rref() (but, as usual, you can use it to check your answer.)

1.1. (3 points)

\begin{align*} \begin{bmatrix} 2 & 3 & -1 \\ 7 & 4 & 3 \\ 0 & -1 & 2 \end{bmatrix} \begin{bmatrix} 1 & 4 & 1 \\ 0 & 2 & 1 \\ 0 & 0 & 3 \end{bmatrix} \end{align*}

1.2. (3 points)

\begin{align*} \begin{bmatrix} 1 & 0 & 1 & 0 & 1 \\ 0 & 1 & 0 & 1 & 0 \\ 1 & 0 & 1 & 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 2 & 3 \\ 2 & 3 & 4 \\ 3 & 4 & 5 \\ 4 & 5 & 6 \\ 5 & 6 & 7 \end{bmatrix} \end{align*}

1.3. (3 points)

\begin{align*} \begin{bmatrix} 1 & 2 & 3 & 4 & 5 & 6 \end{bmatrix} \begin{bmatrix} 1 \\ 2 \\ 3 \\ 4 \\ 5 \\ 6 \end{bmatrix} \end{align*}

1.4. (3 points)

\begin{align*} \begin{bmatrix} 1 \\ 2 \\ 3 \\ 4 \\ 5 \\ 6 \end{bmatrix} \begin{bmatrix} 1 & 2 & 3 & 4 & 5 & 6 \end{bmatrix} \end{align*}

1.5. (3 points)

\begin{align*} \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix} \end{align*}

Hint: Don't work through the entire sequence multiplication. Try to find a pattern.

2. One-to-one/Onto

For each of the following matrices determine if the matrix transformation it defines is (1) one-to-one, (2) onto, (3) both, or (4) neither.1 Justify your answer for each part. Your justification cannot include using sympy.rref() (but, as usual, you can use it to check your answer). Hint: There's one of each. (Errata: 10/6 9:00PM, There was an incorrect number in one of the matrices. The updated number below is in \textcolor{red}{red}.)

2.1. (3 points)

\begin{bmatrix} 1 & 2 & 3 & 4 \\ -13 & 6 & -39 & 4 \\ 2 & 9 & 6 & 7 \\ 5 & 4 & 15 & 16 \\ 0 & 1 & 0 & 65 \\ 1 & 1 & \textcolor{red}{3} & 1 \\ -12 & 3 & -36 & 33 \\ 0 & 0 & 0 & 0 \end{bmatrix}

2.2. (3 points)

\begin{bmatrix} 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \end{bmatrix}

2.3. (3 points)

\begin{bmatrix} 2 & 1 & 3 & 0 \\ 1 & 4 & 3 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix}

2.4. (3 points)

\begin{bmatrix} 12 & 45 & -3 & 20 & 1 \\ 0 & 24 & 121 & 0 & -47 \\ 0 & 0 & 252 & 44 & 46 \\ 0 & 0 & 0 & 21 & -44 \\ 0 & 0 & 0 & 0 & 11 \end{bmatrix}

3. Matrix of a Transformation

For each of the following parts, you must show your work.

3.1. (3 points)

Determine the matrix which implements the transformation \(T : \mathbb R^4 \to \mathbb R^4\) that swaps the first and second entries of its input, e.g.,

\begin{align*} T \left( \begin{bmatrix} 1 \\ 2 \\ 3 \\ 4 \end{bmatrix} \right) = \begin{bmatrix} 2 \\ 1 \\ 3 \\ 4 \end{bmatrix} \end{align*}

3.2. (3 points)

Determine the matrix which implements the transformation

\begin{align*} \begin{bmatrix} x_1 \\ x_2 \\ x_3 \\ x_4 \end{bmatrix} \mapsto \begin{bmatrix} -2x_2 + x_3 + x_4 \\ x_1 + x_3 \\ -3x_3 - 3x_4\\ 9x_4 \end{bmatrix} \end{align*}

In addition, write down the domain and the codomain of this transformation.

3.3. (3 points)

Determine the matrix which implements the transformation with the following input-output behavior.

\begin{align*} T \left( \begin{bmatrix} -7 \\ -3 \end{bmatrix} \right) = \begin{bmatrix} -4 \\ 3 \\ 4 \\ 0 \\ 1 \end{bmatrix} \qquad T \left( \begin{bmatrix} 9 \\ 4 \end{bmatrix} \right) = \begin{bmatrix} 13 \\ 0 \\ 0 \\ 8 \\ 3 \end{bmatrix} \end{align*}

In addition, write down the domain and codomain of this transformation.

4. Reflection

4.1. (5 points EC)

Extra Credit. Determine the matrix which implements the transformation \(T : \mathbb R^3 \to \mathbb R^3\) that reflects vectors across the plane defined by the linear equation \(x + y + z = 0\). You must show your work.

4.2. (5 points)

Determine the matrix which implements the transformation \(T : \mathbb R^2 \to \mathbb R^2\) that reflects vectors across the line \(y = \left(\tan\frac{3\pi}{8}\right)x\). You must show your work.

5. Matrix Tweets (Programming)

(12 points) We're going to have to wait one more week before we can get into some more interesting applications of linear algebra. For now, we continue to practice using NumPy. One of the most important skills we need to develop is the ability to construct and and combine NumPy arrays.

You're given start code in the file hw05.py. Please do not change the name of this file when you submit it, nor the names of the variables included in the starter code. Also, please do not include any additional functions or comments. You must only fill in the TODO items in the starter code.

There are six matrices listed below which you have to build as NumPy arrays. Your goal is to build these matrices as NumPy arrays as concisely as possible, specifically in fewer than 140 characters. In particular, you should not build the matrices explicitly. This may require reading through some of the NumPy documentation…

You'll upload a single python file hw05.py to Gradescope with your implementation of the TODO items. There are no tests this week. We'll simply be checking that your matrices are correct, and that you are within the character limit.

  • a0 (Hint: numpy.eye and np.zeros and numpy.vstack)

    \begin{bmatrix} -3 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & -3 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & -3 & 0 & 0 & 0 &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a3 (Hint: np.arange and np.reshape, this is the longest one)

    \begin{bmatrix} 0 & 1 & -1 & -1 & -1 & -1 & -1 \\ 2 & 3 & -1 & -1 & -1 & -1 & -1 \\ 4 & 5 & -1 & -1 & -1 & -1 & -1 \\ 6 & 7 & -1 & -1 & -1 & -1 & -1 \\ 8 & 9 & -1 & -1 & -1 & -1 & -1 \\ 2 & 2 & 2 & 2 & 1 & 0 & 0 \\ 2 & 2 & 2 & 2 & 0 & 1 & 0 \\ 2 & 2 & 2 & 2 & 0 & 0 & 1 \end{bmatrix}
  • a4 (Hint: numpy.diag and array slicing and matrix addition)

    \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 10 \\ 0 & 2 & 0 & 0 & 0 & 0 & 0 & 0 & 9 & 0 \\ 0 & 0 & 3 & 0 & 0 & 0 & 0 & 8 & 0 & 0 \\ 0 & 0 & 0 & 4 & 0 & 0 & 7 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 5 & 6 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 5 & 6 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 4 & 0 & 0 & 7 & 0 & 0 & 0 \\ 0 & 0 & 3 & 0 & 0 & 0 & 0 & 8 & 0 & 0 \\ 0 & 2 & 0 & 0 & 0 & 0 & 0 & 0 & 9 & 0 \\ 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 10 \end{bmatrix}
  • a5 (Hint: numpy.tril and numpy.triu, see the examples in the documentation)

    \begin{bmatrix} 0 & 3 & 3 & 3 & 3 & 3 & 3 \\ 2 & 0 & 3 & 3 & 3 & 3 & 3 \\ 2 & 2 & 0 & 3 & 3 & 3 & 3 \\ 2 & 2 & 2 & 0 & 3 & 3 & 3 \\ 2 & 2 & 2 & 2 & 0 & 3 & 3 \\ 2 & 2 & 2 & 2 & 2 & 0 & 3 \\ 2 & 2 & 2 & 2 & 2 & 2 & 0 \\ \end{bmatrix}

Footnotes:

1

You should write your answer in words, e.g., write "one-to-one", not "(1)".