Lesson Preview

Under certain conditions, we can multiply two matrices together. We'll start with two square matrices.

Consider the two matrices:

A=[1132],B=[1246]A = \begin{bmatrix} 1 & -1 \\ 3 & 2 \end{bmatrix}, \quad B = \begin{bmatrix} -1 & -2 \\ -4 & 6 \end{bmatrix}

When multiplying ABAB, the output will be another 2×22 \times 2 matrix.

The element (AB)ij(AB)_{ij} is calculated by taking the dot product between the ithi^{th} row of AA with the jthj^{th} column of BB. For the two matrices above:

AB=[1132][1246]=[1(1)+(1)(4)1(2)+(1)(6) 3(1)+2(4)3(2)+2(6)]=[1+426386+12]=[38116].\begin{align*} \textcolor{red}{A} \textcolor{blue}{B} &= \textcolor{red}{\begin{bmatrix} 1 & -1 \\ 3 & 2 \end{bmatrix}} \textcolor{blue}{\begin{bmatrix} -1 & -2 \\ -4 & 6 \end{bmatrix}} \\ &= \begin{bmatrix} \textcolor{red}{1}\textcolor{blue}{(-1)} + \textcolor{red}{(-1)}\textcolor{blue}{(-4)} & \textcolor{red}{1}\textcolor{blue}{(-2)} + \textcolor{red}{(-1)}\textcolor{blue}{(6)} \\  \textcolor{red}{3}\textcolor{blue}{(-1)} + \textcolor{red}{2}\textcolor{blue}{(-4)} & \textcolor{red}{3}\textcolor{blue}{(-2)} + \textcolor{red}{2}\textcolor{blue}{(6)} \end{bmatrix} \\ &= \begin{bmatrix} -1 + 4 & -2 - 6 \\ -3 - 8 & -6 + 12 \end{bmatrix} \\ &= \begin{bmatrix} 3 & -8 \\ -11 & 6 \end{bmatrix} \end{align*}.

It can be helpful to think of computing ABAB by starting with the first row of AA. We complete the first row of the output matrix by taking the dot product of the first row of AA with each column of BB.  

Then we move on to the second row of AA and compute the dot product with each column of BB to fill the second row of the output matrix.  

We continue this process row by row, always taking the dot product of the current row of AA with every column of BB, until all rows of the output matrix are filled.

Finally, a very important property of matrix multiplication in general is that it's not commutative, i.e., ABBAAB \neq BA. Indeed, for the matrices above:

\begin{align*} \textcolor{blue}{B} \textcolor{red}{A} &= ...

... continued in the full lesson.

Ready to Start Learning?

Sign up now to access the full Multiplying Matrices lesson and our entire curriculum!