Matrices and vectors - Your turn#
Note
Click the and open this notebook in Colab to enable interactivity.
Note
To save your progress, make a copy of this notebook in Colab File > Save a copy in Drive
and you’ll find it in My Drive > Colab Notebooks
.
Part (a)#
Find the dot product between the first and second rows of matrix \( C = \begin{bmatrix} 5 & 2 & 1 \\ 5 & 3 & -1 \end{bmatrix}\).
# TODO: Write your solution below
Part (b)#
Compute \(B^T A^T - B^T\) using the matrices \(A = \begin{bmatrix} 1 & 2 \\ -1 & 3 \end{bmatrix}\) and \(B = \begin{bmatrix} 1 & 0 & 1 \\ 2 & 1 & 0 \end{bmatrix}\).
# TODO: Write your solution below
Part (c)#
A rectangle is formed by the four vertices: \((1,0)\), \((3,0)\), \((3,2)\), and \((1,2)\). Compute the coordinates of each vertex after a rotation of \(60^{\circ}\) (or \(\frac{\pi}{3}\) rad) using a rotation matrix \(R\). Plot the rectangle before and after the rotation.
Hint 1: For a counter-clockwise rotation from point \(A\,(x_A, y_A)\) to \(B\,(x_B, y_B)\) about the origin through an angle \(\theta\), it is given by:
Hint 2: To plot any set of points linked together in Python, create a matrix whose first row contains the \(x\)-components of each point and the second row the \(y\)-components. Then plot the first line versus the second one. To close your rectangles, use the first vertex as first and last point.
Hint 3: You may want to add the line ax.set(aspect='equal')
for your axes, just so you get the rectangle you expect!
# TODO: Write your solution below
Part (d)#
Each year, a college accepts \(1000\) freshmen and \(200\) sophomores into the school. Also, \(10\%\) of the freshmen, \(25\%\) of the sophomores, \(5\%\) of the juniors, and \(5\%\) of the seniors repeat their year. The rest continue their studies. If there are \(1160\) freshmen, \(1057\) sophomores, \(1183\) juniors, and \(1028\) seniors this year and the trend holds, what is the school population in \(10\) years? The system of equations to use is as follows:
where the number is indicative of the student’s year in college (\(1\) = freshmen, \(2\) = sophomore, etc). From the equations, we can derive an equation \(x^{(t+1)} = A x^{(t)} + b\) with
Hint: When displaying the final population vector, use the np.round()
function to display integral values.
We cannot have partial students.
# TODO: Write your solution below
Exporting your work#
When you’re ready, the easiest way to export the notebook is to File > Print
it and save it as a PDF.
Remove any excessively long, unrelated outputs first by clicking the arrow → next to the output box and then Show/hide output
.
Obviously don’t obscure any necessary output or graphs!