# 06. Matrix multiplication, 3

## 06. Matrix multiplication, 3

### Multiplying bigger matrices

(0.00) Suppose $A$ is an $m$ -by-$n$ matrix ($m$ rows and $n$ columns) and $B$ is an $n$ -by-$p$ matrix ($n$ rows and $p$ columns). To save our sanity, suppose $m=2$ , $n=3$ , $p=4$ : $A=\begin{pmatrix}A_{11}&A_{12}&A_{13}\\ A_{21}&A_{22}&A_{23}\end{pmatrix},\qquad B=\begin{pmatrix}B_{11}&B_{12}&B_{13}% &B_{14}\\ B_{21}&B_{22}&B_{23}&B_{24}\\ B_{31}&B_{32}&B_{33}&B_{34}\end{pmatrix}.$

(2.36) I claim that there's an obvious way to define $AB$ given everything we've seen so far.

• To get the top left entry of $AB$ , we multiply the top row of $A$ into the first column of $B$ , giving $A_{11}B_{11}+A_{12}B_{21}+A_{13}B_{31}$ .

• To get the next entry along, we multiply the top row of $A$ into the second column of $B$ .

• We keep going: to get the entry of $AB$ in the $i$ th row and the $j$ th column, we multiply the $i$ th row of $A$ into the $j$ th column of $B$ .

This means we end up with $2$ rows (same number as $A$ ) and $4$ columns (same number as $B$ ).

(4.38) You might ask: what happens if $A$ is $m$ -by-$n$ and $B$ is $k$ -by-$p$ but $n\neq k$ ? For example: $\begin{pmatrix}A_{11}&A_{12}\\ A_{21}&A_{22}\end{pmatrix}\begin{pmatrix}B_{11}&B_{12}\end{pmatrix}$ doesn't make any sense: the rows of $A$ have length 2 and the columns of $B$ have height 1, so we can't multiply rows into columns.

(6.13) This is reasonable: $A$ defines a transformation $\mathbf{R}^{2}\to\mathbf{R}^{2}$ and $B$ defines a transformation $\mathbf{R}^{2}\to\mathbf{R}$ , so while you can define $BA\colon\mathbf{R}^{2}\to\mathbf{R}^{2}\to\mathbf{R}$ , you have no way of composing the transformations as $AB$ (the domain of $A$ is not the target of $B$ ).

(8.15) As an exercise, do the following multiplications: $\begin{pmatrix}0&0&1\\ 1&0&0\\ 0&1&0\end{pmatrix}\begin{pmatrix}x\\ y\\ z\end{pmatrix}$ $\begin{pmatrix}1&2&3\\ -1&1/2&0\end{pmatrix}\begin{pmatrix}2&-3\\ -1&0\\ 0&1\end{pmatrix}$ $\begin{pmatrix}1&-1&1&-1\end{pmatrix}\begin{pmatrix}1\\ 2\\ 3\\ 4\end{pmatrix}$ $\begin{pmatrix}1\\ 2\\ 3\\ 4\end{pmatrix}\begin{pmatrix}1&-1&1&-1\end{pmatrix}$ (see the video for solutions).