Matrix multiplication memorisation So I'm writing an exam about matrices in a few weeks time, and I'd like to know if anybody has any tips about multiplying matrices.
 A: There are a couple of different ways to think about matrix multiplication. Here is what I usually do.
To multiply two matrices $A$ and $B$, you should see $A$ as a stack of rows and $B$ as a sequence of columns. I.e. think in the following way:
$$
A = \begin{pmatrix}
a_1 \\ a_2 \\ \vdots \\a_n
\end{pmatrix}
~~~~
B = \begin{pmatrix}
b_1 & b_2 & \cdots & b_k
\end{pmatrix}
$$
Note that $k$ can be different from $n$, but the $a$ and $b$-vectors need to have the same length for the multiplication to be valid.
Now you only have to remember how to do a dot product since your matrix product will be:
$$AB = \begin{pmatrix}
a_1 \cdot b_1 & a_1 \cdot b_2 & \cdots & a_1 \cdot b_k \\
a_2 \cdot b_1 & a_2 \cdot b_2 & \cdots & a_2 \cdot b_k \\
\vdots & \vdots & \vdots & \vdots \\
a_n \cdot b_1 & a_n \cdot b_2 & \cdots & a_n \cdot b_k 
\end{pmatrix}
$$
and the rule to remember is that the element at row $i$ and column $j$ will be the dot product of $a_i$ and $b_j$. I usually then calculate $AB$ row by row, keeping the $a$-vector fixed and changing the $b$-vector as I progress over the column. Then I pick the next $a$, calculate the dot product with each $b$ over the columns, etc.
An example. Let
$$A =
\begin{pmatrix}
1 & 2 \\ -1 & 1
\end{pmatrix}
~~~~
B =
\begin{pmatrix}
2 & 3 & -1 \\ 1 & 1 & 1
\end{pmatrix}
$$
so with the notation above (I don't suggest you do this when doing the calculations, this is just for clarity):
$$\begin{align}
a_1 &= \begin{pmatrix} 1 & 2 \end{pmatrix} \\
a_2 &= \begin{pmatrix} -1 & 1 \end{pmatrix}
\end{align}$$
and
$$\begin{align}
b_1 &= \begin{pmatrix} 2 \\ 1 \end{pmatrix} \\
b_2 &= \begin{pmatrix} 3 \\ 1 \end{pmatrix} \\
b_3 &= \begin{pmatrix} -1 \\ 1 \end{pmatrix}
\end{align}$$
So, the first row of $AB$ will be (note that we only use $a_1$ here):
$$\begin{align}
(AB)_{1,1} &= a_1 \cdot b_1 = 1 \cdot 2 + 2 \cdot 1 = 4 \\
(AB)_{1,2} &= a_1 \cdot b_2 = 1 \cdot 3 + 2 \cdot 1 = 5 \\
(AB)_{1,3} &= a_1 \cdot b_3 = 1 \cdot (-1) + 2 \cdot 1 = 1
\end{align}$$
Then we move on to the second row (here we only use $a_2$):
$$\begin{align}
(AB)_{2,1} &= a_2 \cdot b_1 = -1 \\
(AB)_{2,2} &= a_2 \cdot b_2 = -2 \\
(AB)_{2,3} &= a_2 \cdot b_3 = 2
\end{align}$$
I usually do these dot products in my head as I go along. As a more physical remainder of how to do things, I usually trace over the $a$-row I am using with the pencil (moving the pencil horizontally), then trace over the $b$-column I am using (moving the pencil vertically).
I like this method because you only need to keep one accumulating value in your head at a time. When you're done with a dot product, write it down and move to the next.
Also, if you think you have calculated the element at row $i$ and column $j$ of $AB$ wrong, it's easy to think in reverse: $(AB)_{i,j}$ is just the dot product of row $a_i$ and column $b_j$. Calculate it again and check the result.
