AcademyMatrix Algebra
Academy
Matrix Multiplication
Level 1 - Linear Algebra topic page in Matrix Algebra.
Principle
Matrix multiplication combines rows of the first matrix with columns of the second matrix using scalar products. It is designed so that matrices can represent composition of linear maps.
The order matters: usually \(AB\ne BA\), and sometimes one product exists while the other does not.
Notation
\(AB\)
the product of matrix A followed by matrix B in algebraic order
\(a_{ik}\)
entry of A in row i and column k
\(b_{kj}\)
entry of B in row k and column j
\((AB)_{ij}\)
entry of AB in row i and column j
\(\mathbf r_i\)
row i of A
\(\mathbf c_j\)
column j of B
The Core Method
If \(A\) is \(m\) by \(n\) and \(B\) is \(n\) by \(p\), then \(AB\) is defined and has size \(m\) by \(p\):
Shape rule
\[(m\times n)(n\times p)=m\times p\]
The entry in row \(i\), column \(j\) is
Entry formula
\[(AB)_{ij}=a_{i1}b_{1j}+a_{i2}b_{2j}+\cdots+a_{in}b_{nj}\]
Equivalently, take the scalar product of row \(i\) of \(A\) with column \(j\) of \(B\).
Matrix multiplication is associative and distributive:
Associativity
\[(AB)C=A(BC)\]
Left distributivity
\[A(B+C)=AB+AC\]
but it is not generally commutative.
Worked Cases
Question
Compute \(\begin{pmatrix}1&2&0\\-1&3&4\end{pmatrix}\begin{pmatrix}2&1\\0&-2\\5&3\end{pmatrix}\).
Answer
The first matrix is \(2\) by \(3\), and the second is \(3\) by \(2\), so the product is \(2\) by \(2\). Entry \((1,1)\): \(1\cdot2+2\cdot0+0\cdot5=2\). Entry \((1,2)\): \(1\cdot1+2(-2)+0\cdot3=-3\). Entry \((2,1)\): \((-1)2+3\cdot0+4\cdot5=18\). Entry \((2,2)\): \((-1)1+3(-2)+4\cdot3=5\). Therefore the product is \(\begin{pmatrix}2&-3\\18&5\end{pmatrix}\).
Examples
Question
Let \(A=\begin{pmatrix}1&1\\0&1\end{pmatrix}\) and \(B=\begin{pmatrix}1&0\\2&1\end{pmatrix}\). Compare \(AB\) and \(BA\).
Answer
Compute \(AB=\begin{pmatrix}1\cdot1+1\cdot2&1\cdot0+1\cdot1\\0\cdot1+1\cdot2&0\cdot0+1\cdot1\end{pmatrix}=\begin{pmatrix}3&1\\2&1\end{pmatrix}\). Compute \(BA=\begin{pmatrix}1\cdot1+0\cdot0&1\cdot1+0\cdot1\\2\cdot1+1\cdot0&2\cdot1+1\cdot1\end{pmatrix}=\begin{pmatrix}1&1\\2&3\end{pmatrix}\). The products are different, so \(AB\ne BA\).