2.2: Matrix Multiplication
- Page ID
- 63384
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)- T/F: Column vectors are used more in this text than row vectors, although some other texts do the opposite.
- T/F: To multiply \(A\times B\), the number of rows of \(A\) and \(B\) need to be the same.
- T/F: The entry in the 2nd row and 3rd column of the product \(AB\) comes from multipling the 2nd row of \(A\) with the 3rd column of \(B\).
- Name two properties of matrix multiplication that also hold for “regular multiplication” of numbers.
- Name a property of “regular multiplication” of numbers that does not hold for matrix multiplication.
- T/F: \(A^{3} = A\cdot A\cdot A\)
In the previous section we found that the definition of matrix addition was very intuitive, and we ended that section discussing the fact that eventually we’d like to know what it means to multiply matrices together.
In the spirit of the last section, take another wild stab: what do you think
\[\left[\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}\right]\:\times\:\left[\begin{array}{cc}{1}&{-1}\\{2}&{2}\end{array}\right] \nonumber \]
means?
You are likely to have guessed
\[\left[\begin{array}{cc}{1}&{-2}\\{6}&{8}\end{array}\right] \nonumber \]
but this is, in fact, not right.\(^{1}\) The actual answer is
\[\left[\begin{array}{cc}{5}&{3}\\{11}&{5}\end{array}\right] . \nonumber \]
If you can look at this one example and suddenly understand exactly how matrix multiplication works, then you are probably smarter than the author. While matrix multiplication isn’t hard, it isn’t nearly as intuitive as matrix addition is.
To further muddy the waters (before we clear them), consider
\[\left[\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}\right]\:\times\:\left[\begin{array}{ccc}{1}&{-1}&{0}\\{2}&{2}&{-1}\end{array}\right] . \nonumber \]
Our experience from the last section would lend us to believe that this is not defined, but our confidence is probably a bit shaken by now. In fact, this multiplication is defined, and it is
\[\left[\begin{array}{ccc}{5}&{3}&{-2}\\{11}&{5}&{-4}\end{array}\right] . \nonumber \]
You may see some similarity in this answer to what we got before, but again, probably not enough to really figure things out.
So let’s take a step back and progress slowly. The first thing we’d like to do is define a special type of matrix called a vector.
A \(m\times 1\) matrix is called a column vector.
A \(1\times n\) matrix is called a row vector.
While it isn’t obvious right now, column vectors are going to become far more useful to us than row vectors. Therefore, we often omit the word “column” when referring to column vectors, and we just call them “vectors.”\(^{2}\)
We have been using upper case letters to denote matrices; we use lower case letters with an arrow overtop to denote row and column vectors. An example of a row vector is
\[\vec{u}=\left[\begin{array}{cccc}{1}&{2}&{-1}&{0}\end{array}\right] \nonumber \]
and an example of a column vector is
\[\vec{v}=\left[\begin{array}{c}{1}\\{7}\\{8}\end{array}\right] . \nonumber \]
Before we learn how to multiply matrices in general, we will learn what it means to multiply a row vector by a column vector.
Let \(\vec{u}\) be an \(1\times n\) row vector with entries \(u_{1},\: u_{2},\cdots ,\: u_{n}\) and let \(\vec{v}\) be an \(n\times 1\) column vector with entries \(v_{1},\: v_{2},\cdots ,\: v_{n}\). The product of\(\vec{u}\) and \(\vec{v}\), denoted \(\vec{u}\cdot\vec{v}\) or \(\vec{u}\vec{v}\), is
\[\sum_{i=1}^{n}u_{i}v_{i}=u_{1}v_{1}+u_{2}v_{2}+\cdots +u_{n}v_{n} . \nonumber \]
Don’t worry if this definition doesn’t make immediate sense. It is really an easy concept; an example will make things more clear.
Let
\[\vec{u}=\left[\begin{array}{ccc}{1}&{2}&{3}\end{array}\right],\:\vec{v}=\left[\begin{array}{cccc}{2}&{0}&{1}&{-1}\end{array}\right],\:\vec{x}=\left[\begin{array}{c}{-2}\\{4}\\{3}\end{array}\right],\:\vec{y}=\left[\begin{array}{c}{1}\\{2}\\{5}\\{0}\end{array}\right] .\nonumber \]
Find the following products.
- \(\vec{u}\vec{x}\)
- \(\vec{v}\vec{y}\)
- \(\vec{u}\vec{y}\)
- \(\vec{u}\vec{v}\)
- \(\vec{x}\vec{u}\)
Solution
- \(\vec{u}\vec{x}=\left[\begin{array}{ccc}{1}&{2}&{3}\end{array}\right]\) \(\left[\begin{array}{c}{-2}\\{4}\\{3}\end{array}\right]=1(-2)+2(4)+3(3)=15\)
- \(\vec{v}\vec{y}=\left[\begin{array}{cccc}{2}&{0}&{1}&{-1}\end{array}\right]\) \(\left[\begin{array}{c}{1}\\{2}\\{5}\\{0}\end{array}\right]=2(1)+0(2)+1(5)-1(0)=7\)
- \(\vec{u}\vec{y}\) is not defined; Definition Multiply a Row Vector by a Column Vector specifies that in order to multiply a row vector and column vector, they must have the same number of entries.
- \(\vec{u}\vec{v}\) is not defined; we only know how to multiply row vectors by column vectors. We haven’t defined how to multiply two row vectors (in general, it can’t be done).
- The product \(\vec{x}\vec{u}\) is defined, but we don’t know how to do it yet. Right now, we only know how to multiply a row vector times a column vector; we don’t know how to multiply a column vector times a row vector. (That’s right: \(\vec{u}\vec{x}\neq\vec{x}\vec{u}\)!
Now that we understand how to multiply a row vector by a column vector, we are ready to define matrix multiplication.
Let \(A\) be an \(m\times r\) matrix, and let \(B\) be an \(r\times n\) matrix. The matrix product of \(A\) and \(B\), denoted \(A\cdot B\), or simply \(AB\), is the \(m\times n\) matrix \(M\) whose entry in the \(i^{\text{th}}\) row and \(j^{\text{th}}\) column is the product of the \(i^{\text{th}}\) row of \(A\) and the \(j^{\text{th}}\) column of \(B\).
It may help to illustrate it in this way. Let matrix \(A\) have rows \(\vec{a_1}\), \(\vec{a_2}\), \(\cdots\), \(\vec{a_m}\) and let \(B\) have columns \(\vec{b_1}\), \(\vec{b_2}\), \(\cdots\), \(\vec{b_n}\). Thus \(A\) looks like
\[\left[\begin{array}{ccc}{-}&{\vec{a_{1}}}&{-}\\{-}&{\vec{a_{2}}}&{-}\\{}&{\vdots}&{}\\{-}&{\vec{a_{m}}}&{-}\end{array}\right] \nonumber \]
where the “\(-\)” symbols just serve as reminders that the \(\vec{a_i}\) represent rows, and \(B\) looks like
\[\left[\begin{array}{cccc}{|}&{|}&{}&{|}\\{\vec{b_{1}}}&{\vec{b_{2}}}&{\cdots}&{\vec{b_{n}}}\\{|}&{|}&{}&{|}\end{array}\right] \nonumber \]
where again, the “\(|\)” symbols just remind us that the \(\vec{b_{i}}\) represent column vectors. Then
\[AB=\left[\begin{array}{cccc}{\vec{a_{1}}\vec{b_{1}}}&{\vec{a_{1}}\vec{b_{2}}}&{\cdots}&{\vec{a_{1}}\vec{b_{n}}} \\ {\vec{a_{2}}\vec{b_{1}}}&{\vec{a_{2}}\vec{b_{2}}}&{\cdots}&{\vec{a_{2}}\vec{b_{n}}} \\ {\vdots}&{\vdots}&{\ddots}&{\vdots}\\{\vec{a_{m}}\vec{b_{1}}}&{\vec{a_{m}}\vec{b_{2}}}&{\cdots}&{\vec{a_{m}}\vec{b_{n}}}\end{array}\right] \nonumber \]
Two quick notes about this definition. First, notice that in order to multiply \(A\) and \(B\), the number of columns of \(A\) must be the same as the number of rows of \(B\) (we refer to these as the “inner dimensions”). Secondly, the resulting matrix has the same number of rows as \(A\) and the same number of columns as \(B\) (we refer to these as the “outer dimensions”).
\[\begin{array}{c}{\text{final dimensions are the outer}}\\{\text{dimensions}}\\{\overbrace{(m\times \underbrace{r)\times (r}\times n)}}\\{\text{these inner dimensions}}\\{\text{must match}}\end{array}\nonumber \]
Of course, this will make much more sense when we see an example.
Revisit the matrix product we saw at the beginning of this section; multiply
\[\left[\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}\right]\:\left[\begin{array}{ccc}{1}&{-1}&{0}\\{2}&{2}&{-1}\end{array}\right] \nonumber \]
Solution
Let’s call our first matrix \(A\) and the second \(B\). We should first check to see that we can actually perform this multiplication. Matrix \(A\) is \(2\times 2\) and \(B\) is \(2\times 3\). The “inner” dimensions match up, so we can compute the product; the “outer” dimensions tell us that the product will be \(2\times 3\). Let
\[AB=\left[\begin{array}{ccc}{m_{11}}&{m_{12}}&{m_{13}}\\{m_{21}}&{m_{22}}&{m_{23}}\end{array}\right] . \nonumber \]
Let’s find the value of each of the entries.
The entry \(m_{11}\) is in the first row and first column; therefore to find its value, we need to multiply the first row of \(A\) by the first column of \(B\). Thus
\[m_{11}=\left[\begin{array}{cc}{1}&{2}\end{array}\right]\:\left[\begin{array}{c}{1}\\{2}\end{array}\right] \nonumber \]=1(1)+2(2)=5. \nonumber \]
So now we know that
\[AB=\left[\begin{array}{ccc}{5}&{m_{12}}&{m_{13}}\\{m_{21}}&{m_{22}}&{m_{23}}\end{array}\right] . \nonumber \]
Finishing out the first row, we have
\[m_{12}=\left[\begin{array}{cc}{1}&{2}\end{array}\right]\:\left[\begin{array}{c}{-1}\\{2}\end{array}\right]=1(-1)+2(2)=3 \nonumber \]
using the first row of \(A\) and the second column of \(B\), and
\[m_{13}=\left[\begin{array}{cc}{1}&{2}\end{array}\right]\:\left[\begin{array}{c}{0}\\{-1}\end{array}\right]=1(0)+2(-1)=-2 \nonumber \]
using the first row of \(A\) and the third column of \(B\). Thus we have
\[AB=\left[\begin{array}{ccc}{5}&{3}&{-2}\\{m_{21}}&{m_{22}}&{m_{23}}\end{array}\right] . \nonumber \]
To compute the second row of \(AB\), we multiply with the second row of \(A\). We find
\[m_{21}=\left[\begin{array}{cc}{3}&{4}\end{array}\right]\:\left[\begin{array}{c}{1}\\{2}\end{array}\right]=11, \nonumber \]
\[m_{22}=\left[\begin{array}{cc}{3}&{4}\end{array}\right]\:\left[\begin{array}{c}{-1}\\{2}\end{array}\right]=5, \nonumber \]
and
\[m_{23}=\left[\begin{array}{cc}{3}&{4}\end{array}\right]\:\left[\begin{array}{c}{0}\\{-1}\end{array}\right]=-4 . \nonumber \]
Thus
\[AB=\left[\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}\right]\:\left[\begin{array}{ccc}{1}&{-1}&{0}\\{2}&{2}&{-1}\end{array}\right]=\left[\begin{array}{ccc}{5}&{3}&{-2}\\{11}&{5}&{-4}\end{array}\right] . \nonumber \]
Multiply
\[\left[\begin{array}{cc}{1}&{-1}\\{5}&{2}\\{-2}&{3}\end{array}\right]\:\left[\begin{array}{cccc}{1}&{1}&{1}&{1}\\{2}&{6}&{7}&{9}\end{array}\right] . \nonumber \]
Solution
Let’s first check to make sure this product is defined. Again calling the first matrix \(A\) and the second \(B\), we see that \(A\) is a \(3\times 2\) matrix and \(B\) is a \(2\times4\) matrix; the inner dimensions match so the product is defined, and the product will be a \(3\times 4\) matrix,
\[AB=\left[\begin{array}{cccc}{m_{11}}&{m_{12}}&{m_{13}}&{m_{14}}\\{m_{21}}&{m_{22}}&{m_{23}}&{m_{24}} \\ {m_{31}}&{m_{32}}&{m_{33}}&{m_{34}}\end{array}\right] . \nonumber \]
We will demonstrate how to compute some of the entries, then give the final answer. The reader can fill in the details of how each entry was computed.
\[m_{11}=\left[\begin{array}{cc}{1}&{-1}\end{array}\right]\:\left[\begin{array}{c}{1}\\{2}\end{array}\right]=-1 . \nonumber \]
\[m_{13}=\left[\begin{array}{cc}{1}&{-1}\end{array}\right]\:\left[\begin{array}{c}{1}\\{7}\end{array}\right]=-6 . \nonumber \]
\[m_{23}=\left[\begin{array}{cc}{5}&{2}\end{array}\right]\:\left[\begin{array}{c}{1}\\{7}\end{array}\right]=19 . \nonumber \]
\[m_{24}=\left[\begin{array}{cc}{5}&{2}\end{array}\right]\:\left[\begin{array}{c}{1}\\{9}\end{array}\right]=23 . \nonumber \]
\[m_{32}=\left[\begin{array}{cc}{-2}&{3}\end{array}\right]\:\left[\begin{array}{c}{1}\\{6}\end{array}\right]=16 . \nonumber \]
\[m_{34}=\left[\begin{array}{cc}{-2}&{3}\end{array}\right]\:\left[\begin{array}{c}{1}\\{9}\end{array}\right]=25 . \nonumber \]
So far, we’ve computed this much of \(AB\):
\[AB=\left[\begin{array}{cccc}{-1}&{m_{12}}&{-6}&{m_{14}}\\{m_{21}}&{m_{22}}&{19}&{23}\\{m_{31}}&{16}&{m_{33}}&{25}\end{array}\right] . \nonumber \]
The final product is
\[AB=\left[\begin{array}{cccc}{-1}&{-5}&{-6}&{-8}\\{9}&{17}&{19}&{23}\\{4}&{16}&{19}&{25}\end{array}\right] . \nonumber \]
Multiply, if possible
\[\left[\begin{array}{ccc}{2}&{3}&{4}\\{9}&{8}&{7}\end{array}\right]\:\left[\begin{array}{cc}{3}&{6}\\{5}&{-1}\end{array}\right] . \nonumber \]
Solution
Again, we’ll call the first matrix \(A\) and the second \(B\). Checking the dimensions of each matrix, we see that \(A\) is a \(2\times 3\) matrix, whereas \(B\) is a \(2\times2\) matrix. The inner dimensions do not match, therefore this multiplication is not defined.
In Example \(\PageIndex{1}\), we were told that the product \(\vec{x}\vec{u}\) was defined, where
\[\vec{x}=\left[\begin{array}{c}{-2}\\{4}\\{3}\end{array}\right]\quad\text{and}\quad\vec{u}=\left[\begin{array}{ccc}{1}&{2}&{3}\end{array}\right] , \nonumber \]
although we were not shown what the product was. Find \(\vec{x}\vec{u}\).
Solution
Again, we need to check to make sure the dimensions work correctly (remember that even though we are referring to \(\vec{u}\) and \(\vec{x}\) as vectors, they are, in fact, just matrices).
The column vector \(\vec{x}\) has dimensions \(3\times1\), whereas the row vector \(\vec{u}\) has dimensions \(1\times 3\). Since the inner dimensions do match, the matrix product is defined; the outer dimensions tell us that the product will be a \(3\times3\) matrix, as shown below:
\[\vec{x}\vec{u}=\left[\begin{array}{ccc}{m_{11}}&{m_{12}}&{m_{13}}\\{m_{21}}&{m_{22}}&{m_{23}}\\{m_{31}}&{m_{32}}&{m_{33}}\end{array}\right] . \nonumber \]
To compute the entry \(m_{11}\), we multiply the first row of \(\vec{x}\) by the first column of \(\vec{u}\). What is the first row of \(\vec{x}\)? Simply the number \(-2\). What is the first column of \(\vec{u}\)? Just the number 1. Thus \(m_{11} = -2\). (This does seem odd, but through checking, you can see that we are indeed following the rules.)
What about the entry \(m_{12}\)? Again, we multiply the first row of \(\vec{x}\) by the first column of \(\vec{u}\); that is, we multiply \(-2(2)\). So \(m_{12} = -4\).
What about \(m_{23}\)? Multiply the second row of \(\vec{x}\) by the third column of \(\vec{u}\); multiply \(4(3)\), so \(m_{23} = 12\).
One final example: \(m_{31}\) comes from multiplying the third row of \(\vec{x}\), which is 3, by the first column of \(\vec{u}\), which is 1. Therefore \(m_{31} = 3\).
So far we have computed
\[\vec{x}\vec{u}=\left[\begin{array}{ccc}{-2}&{-4}&{m_{13}}\\{m_{21}}&{m_{22}}&{12}\\{3}&{m_{32}}&{m_{33}}\end{array}\right] . \nonumber \]
After performing all 9 multiplications, we find
\[\vec{x}\vec{u}=\left[\begin{array}{ccc}{-2}&{-4}&{-6}\\{4}&{8}&{12}\\{3}&{6}&{9}\end{array}\right] . \nonumber \]
In this last example, we saw a “nonstandard” multiplication (at least, it felt nonstandard). Studying the entries of this matrix, it seems that there are several different patterns that can be seen amongst the entries. (Remember that mathematicians like to look for patterns. Also remember that we often guess wrong at first; don’t be scared and try to identify some patterns.)
In Section 2.1, we identified the zero matrix \(\mathbf{0}\) that had a nice property in relation to matrix addition (i.e., \(A+\mathbf{0}=A\) for any matrix \(A\)). In the following example we’ll identify a matrix that works well with multiplication as well as some multiplicative properties. For instance, we’ve learned how \(1\cdot A=A\); is there a matrix that acts like the number 1? That is, can we find a matrix \(X\) where \(X\cdot A=A\)?\(^{3}\)
Let
\[\begin{array}{cc}{A=\left[\begin{array}{ccc}{1}&{2}&{3}\\{2}&{-7}&{5}\\{-2}&{-8}&{3}\end{array}\right],}&{B=\left[\begin{array}{ccc}{1}&{1}&{1}\\{1}&{1}&{1}\\{1}&{1}&{1}\end{array}\right]}\\ {C=\left[\begin{array}{ccc}{1}&{0}&{2}\\{2}&{1}&{0}\\{0}&{2}&{1}\end{array}\right],} &{I=\left[\begin{array}{ccc}{1}&{0}&{0}\\{0}&{1}&{0}\\{0}&{0}&{1}\end{array}\right] .}\end{array}\nonumber \]
Find the following products.
- \(AB\)
- \(BA\)
- \(A\mathbf{0}_{3\times 4}\)
- \(AI\)
- \(IA\)
- \(I^{2}\)
- \(BC\)
- \(B^{2}\)
Solution
We will find each product, but we leave the details of each computation to the reader.
- \(AB=\left[\begin{array}{ccc}{1}&{2}&{3}\\{2}&{-7}&{5}\\{-2}&{-8}&{3}\end{array}\right]\:\left[\begin{array}{ccc}{1}&{1}&{1}\\{1}&{1}&{1}\\{1}&{1}&{1}\end{array}\right]=\left[\begin{array}{ccc}{6}&{6}&{6}\\{0}&{0}&{0}\\{-7}&{-7}&{-7}\end{array}\right]\)
- \(BA=\left[\begin{array}{ccc}{1}&{1}&{1}\\{1}&{1}&{1}\\{1}&{1}&{1}\end{array}\right]\:\left[\begin{array}{ccc}{1}&{2}&{3}\\{2}&{-7}&{5}\\{-2}&{-8}&{3}\end{array}\right]=\left[\begin{array}{ccc}{1}&{-13}&{11}\\{1}&{-13}&{11}\\{1}&{-13}&{11}\end{array}\right]\)
- \(A\mathbf{0}_{3\times 4}=\mathbf{0}_{3\times 4}\).
- \(AI=\left[\begin{array}{ccc}{1}&{2}&{3}\\{2}&{-7}&{5}\\{-2}&{-8}&{3}\end{array}\right]\:\left[\begin{array}{ccc}{1}&{0}&{0}\\{0}&{1}&{0}\\{0}&{0}&{1}\end{array}\right]=\left[\begin{array}{ccc}{1}&{2}&{3}\\{2}&{-7}&{5}\\{-2}&{-8}&{3}\end{array}\right]\)
- \(IA=\left[\begin{array}{ccc}{1}&{0}&{0}\\{0}&{1}&{0}\\{0}&{0}&{1}\end{array}\right]\:\left[\begin{array}{ccc}{1}&{2}&{3}\\{2}&{-7}&{5}\\{-2}&{-8}&{3}\end{array}\right]=\left[\begin{array}{ccc}{1}&{2}&{3}\\{2}&{-7}&{5}\\{-2}&{-8}&{3}\end{array}\right]\)
- We haven't formally defined what \(I^{2}\) means, but we could probably make the reasonable guess that \(I^{2}=I\cdot I\). Thus
\[I^{2}=\left[\begin{array}{ccc}{1}&{0}&{0}\\{0}&{1}&{0}\\{0}&{0}&{1}\end{array}\right]\:\left[\begin{array}{ccc}{1}&{0}&{0}\\{0}&{1}&{0}\\{0}&{0}&{1}\end{array}\right]=\left[\begin{array}{ccc}{1}&{0}&{0}\\{0}&{1}&{0}\\{0}&{0}&{1}\end{array}\right]\nonumber \] - \(BC=\left[\begin{array}{ccc}{1}&{1}&{1}\\{1}&{1}&{1}\\{1}&{1}&{1}\end{array}\right]\:\left[\begin{array}{ccc}{1}&{0}&{2}\\{2}&{1}&{0}\\{0}&{2}&{1}\end{array}\right]=\left[\begin{array}{ccc}{3}&{3}&{3}\\{3}&{3}&{3}\\{3}&{3}&{3}\end{array}\right]\)
- \(B^{2}=BB=\left[\begin{array}{ccc}{1}&{1}&{1}\\{1}&{1}&{1}\\{1}&{1}&{1}\end{array}\right]\:\left[\begin{array}{ccc}{1}&{1}&{1}\\{1}&{1}&{1}\\{1}&{1}&{1}\end{array}\right]=\left[\begin{array}{ccc}{3}&{3}&{3}\\{3}&{3}&{3}\\{3}&{3}&{3}\end{array}\right]\)
This example is simply chock full of interesting ideas; it is almost hard to think about where to start.
Interesting Idea #1: Notice that in our example, \(AB\neq BA\)! When dealing with numbers, we were used to the idea that \(ab = ba\). With matrices, multiplication is not commutative. (Of course, we can find special situations where it does work. In general, though, it doesn’t.)
Interesting Idea #2: Right before this example we wondered if there was a matrix that “acted like the number 1,” and guessed it may be a matrix of all 1s. However, we found out that such a matrix does not work in that way; in our example, \(AB\neq A\). We did find that \(AI=IA=A\). There is a Multiplicative Identity; it just isn’t what we thought it would be. And just as \(1^2 = 1\), \(I^{2}=I\).
Interesting Idea #3: When dealing with numbers, we are very familiar with the notion that “If \(ax = bx\), then \(a=b\).” (As long as \(x\neq 0\).) Notice that, in our example, \(BB=BC\), yet \(B\neq C\). In general, just because \(AX=BX\), we cannot conclude that \(A=B\).
Matrix multiplication is turning out to be a very strange operation. We are very used to multiplying numbers, and we know a bunch of properties that hold when using this type of multiplication. When multiplying matrices, though, we probably find ourselves asking two questions, “What does work?” and “What doesn’t work?” We’ll answer these questions; first we’ll do an example that demonstrates some of the things that do work.
Let
\[A=\left[\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}\right],\quad B=\left[\begin{array}{cc}{1}&{1}\\{1}&{-1}\end{array}\right]\quad\text{and}\quad C=\left[\begin{array}{cc}{2}&{1}\\{1}&{2}\end{array}\right] . \nonumber \]
Find the following:
- \(A(B+C)\)
- \(AB+AC\)
- \(A(BC)\)
- \((AB)C\)
Solution
We’ll compute each of these without showing all the intermediate steps. Keep in mind order of operations: things that appear inside of parentheses are computed first.
- \[\begin{aligned}A(B+C)&=\left[\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}\right]\left(\left[\begin{array}{cc}{1}&{1}\\{1}&{-1}\end{array}\right]+\left[\begin{array}{cc}{2}&{1}\\{1}&{2}\end{array}\right]\right) \\ &=\left[\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}\right]\left[\begin{array}{cc}{3}&{2}\\{2}&{1}\end{array}\right] \\ &=\left[\begin{array}{cc}{7}&{4}\\{17}&{10}\end{array}\right]\end{aligned} \nonumber \]
- \[\begin{aligned}AB+AC&=\left[\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}\right]\left[\begin{array}{cc}{1}&{1}\\{1}&{-1}\end{array}\right]+\left[\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}\right]\left[\begin{array}{cc}{2}&{1}\\{1}&{2}\end{array}\right] \\ &=\left[\begin{array}{cc}{3}&{-1}\\{7}&{-1}\end{array}\right]+\left[\begin{array}{cc}{4}&{5}\\{10}&{11}\end{array}\right] \\ &=\left[\begin{array}{cc}{7}&{4}\\{17}&{10}\end{array}\right]\end{aligned} \nonumber \]
- \[\begin{aligned}A(BC)&=\left[\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}\right]\left(\left[\begin{array}{cc}{1}&{1}\\{1}&{-1}\end{array}\right]\left[\begin{array}{cc}{2}&{1}\\{1}&{2}\end{array}\right]\right) \\ &=\left[\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}\right]\left[\begin{array}{cc}{3}&{3}\\{1}&{-1}\end{array}\right] \\ &=\left[\begin{array}{cc}{5}&{1}\\{13}&{5}\end{array}\right]\end{aligned} \nonumber \]
- \[\begin{aligned}(AB)C&=\left(\left[\begin{array}{cc}{1}&{2}\\{3}&{4}\end{array}\right]\left[\begin{array}{cc}{1}&{1}\\{1}&{-1}\end{array}\right]\right) \left[\begin{array}{cc}{2}&{1}\\{1}&{2}\end{array}\right] \\ &=\left[\begin{array}{cc}{3}&{-1}\\{7}&{-1}\end{array}\right]\left[\begin{array}{cc}{2}&{1}\\{1}&{2}\end{array}\right] \\ &=\left[\begin{array}{cc}{5}&{1}\\{13}&{5}\end{array}\right]\end{aligned} \nonumber \]
In looking at our example, we should notice two things. First, it looks like the “distributive property” holds; that is, \(A(B+C)=AB+AC\). This is nice as many algebraic techniques we have learned about in the past (when doing “ordinary algebra”) will still work. Secondly, it looks like the “associative property” holds; that is, \(A(BC)=(AB)C\). This is nice, for it tells us that when we are multiplying several matrices together, we don’t have to be particularly careful in what order we multiply certain pairs of matrices together.\(^{4}\)
In leading to an important theorem, let’s define a matrix we saw in an earlier example.\(^{5}\)
The \(n\times n\) matrix with 1’s on the diagonal and zeros elsewhere is the \(n\times n\) identity matrix, denoted \(I_{n}\). When the context makes the dimension of the identity clear, the subscript is generally omitted.
Note that while the zero matrix can come in all different shapes and sizes, the identity matrix is always a square matrix. We show a few identity matrices below.
\[I_{2}=\left[\begin{array}{cc}{1}&{0}\\{0}&{1}\end{array}\right],\quad I_{3}=\left[\begin{array}{ccc}{1}&{0}&{0}\\{0}&{1}&{0}\\{0}&{0}&{1}\end{array}\right],\quad I_{4}=\left[\begin{array}{cccc}{1}&{0}&{0}&{0}\\{0}&{1}&{0}&{0}\\{0}&{0}&{1}&{0}\\{0}&{0}&{0}&{1}\end{array}\right] \nonumber \]
In our examples above, we have seen examples of things that do and do not work. We should be careful about what examples prove, though. If someone were to claim that \(AB=BA\) is always true, one would only need to show them one example where they were false, and we would know the person was wrong. However, if someone claims that \(A(B+C)=AB+AC\) is always true, we can’t prove this with just one example. We need something more powerful; we need a true proof.
In this text, we forgo most proofs. The reader should know, though, that when we state something in a theorem, there is a proof that backs up what we state. Our justification comes from something stronger than just examples.
Now we give the good news of what does work when dealing with matrix multiplication.
Properties of Matrix Multiplication
Let \(A\), \(B\) and \(C\) be matrices with dimensions so that the following operations make sense, and let \(k\) be a scalar. The following equalities hold:
- \(A(BC) = (AB)C\) (Associative Property)
- \(A(B + C) = AB + AB\) and
\((B + C)A = BA + CA\) (Distributive Property) - \(k(AB) = (kA)B = A(kB)\)
- \(AI = IA = A\)
The above box contains some very good news, and probably some very surprising news. Matrix multiplication probably seems to us like a very odd operation, so we probably wouldn’t have been surprised if we were told that \(A(BC)\neq (AB)C\). It is a very nice thing that the Associative Property does hold.
As we near the end of this section, we raise one more issue of notation. We define \(A^{0}=I\). If \(n\) is a positive integer, we define
\[\begin{array}{c}{A^{n}=\underbrace{A\cdot A\cdot\cdots\cdot A.}} \\ {\quad n\text{ times}}\end{array} \nonumber \]
With numbers, we are used to \(a^{-n} = \frac{1}{a^n}\). Do negative exponents work with matrices, too? The answer is yes, sort of. We’ll have to be careful, and we’ll cover the topic in detail once we define the inverse of a matrix. For now, though, we recognize the fact that \(A^{-1}\neq\frac{1}{A}\), for \(\frac{1}{A}\) makes no sense; we don’t know how to “divide” by a matrix.
We end this section with a reminder of some of the things that do not work with matrix multiplication. The good news is that there are really only two things on this list.
- Matrix multiplication is not commutative; that is, \(AB\neq BA\).
- In general, just because \(AX=BX\), we cannot conclude that \(A=B\).
The bad news is that these ideas pop up in many places where we don’t expect them. For instance, we are used to \[(a+b)^2 = a^2+2ab+b^2. \nonumber \] What about \((A+B)^{2}\)? All we’ll say here is that
\[(A+B)^{2}\neq A^{2}+2AB+B^{2}; \nonumber \]
we leave it to the reader to figure out why.
The next section is devoted to visualizing column vectors and “seeing” how some of these arithmetic properties work together.
Footnotes
[1] I guess you could define multiplication this way. If you’d prefer this type of multiplication, write your own book.
[2] In this text, row vectors are only used in this section when we discuss matrix multiplication, whereas we’ll make extensive use of column vectors. Other texts make great use of row vectors, but little use of column vectors. It is a matter of preference and tradition: “most” texts use column vectors more.
[3] We made a guess in Section 2.1 that maybe a matrix of all 1s would work.
[4] Be careful: in computing \(ABC\) together, we can first multiply \(AB\) or \(BC\), but we cannot change the order in which these matrices appear. We cannot multiply \(BA\) or \(AC\), for instance.
[5] The following definition uses a term we won’t define until Definition The Diagonal, a Diagonal Matrix, Triangular Matrices in Section 3.1: diagonal. In short, a “diagonal matrix” is one in which the only nonzero entries are the “diagonal entries.” The examples given here and in the exercises should suffice until we meet the full definition later.