2023-04-16 17:29:46 -07:00

219 lines
3.7 KiB
TeX

\section{Matrices}
\definition{}
A \textit{matrix} is a two-dimensional array of numbers: \\
$$
A =
\begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6
\end{bmatrix}
$$
The above matrix has two rows and three columns. It is thus a $2 \times 3$ matrix.
\definition{}<matvec>
We can define the product of a matrix $A$ and a vector $v$:
$$
Av =
\begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6
\end{bmatrix}
\begin{bmatrix}
a \\ b \\ c
\end{bmatrix}
=
\begin{bmatrix}
1a + 2b + 3c \\
4a + 5b + 6c
\end{bmatrix}
$$
Note that each element of the resulting $2 \times 1$ matrix is the dot product of a row of $A$ with $v$:
$$
Av =
\begin{bmatrix}
\text{---} a_1 \text{---} \\
\text{---} a_2 \text{---}
\end{bmatrix}
\begin{bmatrix}
| \\
v \\
| \\
\end{bmatrix}
=
\begin{bmatrix}
r_1v \\
r_2v
\end{bmatrix}
$$
Naturally, a vector can only be multiplied by a matrix if the number of rows in the vector equals the number of columns in the matrix.
\problem{}
Say you multiply a size-$m$ vector by an $m \times n$ matrix. What is the size of your result?
\vfill
\problem{}
Compute the following:
$$
\begin{bmatrix}
1 & 2 \\
3 & 4 \\
5 & 6
\end{bmatrix}
\begin{bmatrix}
5 \\ 3
\end{bmatrix}
$$
\vfill
\pagebreak
\definition{}
We also multiply a matrix by a matrix:
$$
AB =
\begin{bmatrix}
1 & 2 \\
3 & 4
\end{bmatrix}
\begin{bmatrix}
10 & 20 \\
100 & 200
\end{bmatrix}
=
\begin{bmatrix}
210 & 420 \\
430 & 860
\end{bmatrix}
$$
Note each element of the resulting matrix is dot product of a row of $A$ and a column of $B$:
$$
AB =
\begin{bmatrix}
\text{---} a_1 \text{---} \\
\text{---} a_2 \text{---}
\end{bmatrix}
\begin{bmatrix}
| & | \\
v_1 & v_2 \\
| & | \\
\end{bmatrix}
=
\begin{bmatrix}
r_1v_1 & r_1v_2 \\
r_2v_1 & r_2vm_2 \\
\end{bmatrix}
$$
\begin{center}
\begin{tikzpicture}[>=stealth,thick,baseline]
\begin{scope}[layer = nodes]
\matrix[
matrix of math nodes,
left delimiter={[},
right delimiter={]}
] (A) at (0, 0){
1 & 2 \\
3 & 4 \\
};
\matrix[
matrix of math nodes,
left delimiter={[},
right delimiter={]}
] (B) at (2, 0) {
10 & 20 \\
100 & 200 \\
};
\node at (3.25, 0) {$=$};
\matrix[
matrix of math nodes,
left delimiter={[},
right delimiter={]}
] (C) at (4.5, 0) {
210 & 420 \\
430 & 860 \\
};
\end{scope}
\draw[rounded corners,fill=black!30!white,draw=none] ([xshift=-2mm,yshift=3mm]A-1-1) rectangle ([xshift=2mm,yshift=-3mm]A-2-1) {};
\draw[rounded corners,fill=black!30!white,draw=none] ([xshift=-3mm,yshift=2mm]B-1-1) rectangle ([xshift=3mm,yshift=-2mm]B-1-2) {};
\draw[rounded corners,fill=black!30!white,draw=none] ([xshift=-4mm,yshift=2mm]C-1-1) rectangle ([xshift=4mm,yshift=-2mm]C-1-1) {};
\draw[rounded corners] ([xshift=-2mm,yshift=3mm]A-1-2) rectangle ([xshift=2mm,yshift=-3mm]A-2-2) {};
\draw[rounded corners] ([xshift=-3mm,yshift=2mm]B-2-1) rectangle ([xshift=3mm,yshift=-2mm]B-2-2) {};
\draw[rounded corners] ([xshift=-4mm,yshift=2mm]C-2-2) rectangle ([xshift=4mm,yshift=-2mm]C-2-2) {};
\end{tikzpicture}
\end{center}
\problem{}
Compute the following matrix product. \\
$$
\begin{bmatrix}
1 & 2 \\
3 & 4 \\
5 & 6
\end{bmatrix}
\begin{bmatrix}
9 & 8 & 7 \\
6 & 5 & 4
\end{bmatrix}
$$
\vfill
\problem{}
Consider the following matrix product. \\
Compute it or explain why you can't.
$$
\begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6
\end{bmatrix}
\begin{bmatrix}
10 & 20 \\
30 & 40
\end{bmatrix}
$$
\vfill
\problem{}
If $A$ is an $m \times n$ matrix and $B$ is a $p \times q$ matrix, when does the product $AB$ exist?
\vfill
\pagebreak
\problem{}
Look back to \ref{matvec}. \\
Convince yourself that vectors are matrices. \\
Can you multiply a matrix by a vector, as in $vA$? \\
How does the dot prouduct relate to matrix multiplication? (transpose)
\vfill
\pagebreak