Row-column & matrix multiplication
- The row-column product of $a$ and $b$ is defined by \[\!\!\!\!\!\!\!\!\!\!ab=[\begin{smallmatrix}a_1&a_2&\dots&a_n\end{smallmatrix}]\left[\begin{smallmatrix}b_1\\b_2\\\vdots\\b_n\end{smallmatrix}\right]=a_1b_1+a_2b_2+\dots+a_nb_n.\]
- $AB=$ matrix of all “row-of-$A$ times col-of-$B$” products
- \[\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \def\r{\left[\begin{smallmatrix}1&0&5\end{smallmatrix}\right]}\def\rr{\left[\begin{smallmatrix}2&-1&3\end{smallmatrix}\right]}\left[\begin{smallmatrix}1&0&5\\2&-1&3\end{smallmatrix}\right]\left[\begin{smallmatrix} 1&2\\3&4\\5&6\end{smallmatrix}\right]\def\s{\left[\begin{smallmatrix}1\\3\\5\end{smallmatrix}\right]}\def\ss{\left[\begin{smallmatrix}2\\4\\6\end{smallmatrix}\right]}=\left[\begin{smallmatrix}{\r\s}&{\r\ss}\\{\rr\s}&{\rr\ss}\end{smallmatrix}\right]=\left[\begin{smallmatrix}26&32\\14&18\end{smallmatrix}\right].\]
Matrix multiplication: the definition
- Let $A,B$ be matrices, with sizes
- $A$: $n\times m$
- $B$: $m\times k$
- The product $AB$ is: the $n\times k$ matrix whose $(i,j)$ entry is \[ (AB)_{i,j} = \text{row}_i(A)\cdot \text{col}_j(B)\]
- So the entries of $AB$ are all possible row-column products of a row of $A$ with a column of $B$
"Compatible" sizes for $AB$ to be defined
- We need the sizes of $A$ and $B$ to be “compatible” for $AB$ to be defined
- Need $A$: $n\times m$ and $B$: $m\times k$ (same numbers “in the middle”)
- If $A,B$ are matrices, with sizes
- $A$: $n\times m$
- $B$: $\ell\times k$ with $\ell\ne m$,
- then the matrix product $AB$ is undefined.
Example 1
If $\newcommand{\mat}[1]{\left[\begin{smallmatrix}#1\end{smallmatrix}\right]} A=\mat{1&0&5\\2&-1&3}$ and $B=\mat{1&2\\3&4\\5&6}$,
- $AB=\mat{26&32\\14&18}$
- $BA=\mat{5&-2&11\\11&-4&27\\17&-6&43}$.
- Note that $AB$ and $BA$ are both defined, but $AB\ne BA$
- $AB$ and $BA$ don't even have the same size.
Example 2
If $A=\mat{1&2\\3&4\\5&6}$, $B=\mat{2&1&1\\1&2&0\\1&0&2\\2&2&1}$ and $C=\mat{1&3&0&7\\0&4&6&8}$,
- $A$ is $3\times 2$, $B$ is $4\times 3$ and $C$ is $2\times 4$, so
- $AB$, $CA$ and $BC$ don't exist (undefined);
- $AC$ exists and is $3\times 4$;
- $BA$ exists and is $4\times 2$; and
- $CB$ exists and is $2\times 2$.
- In particular, $AB\ne BA$ and $AC\ne CA$ and $BC\ne CB$ (undefined vs defined!)
Example 3
If $A=\mat{0&1\\0&0}$ and $B=\mat{0&0\\1&0}$, then
- $AB=\mat{1&0\\0&0}$
- $BA=\mat{0&0\\0&1}$.
- So $AB$ and $BA$ are both defined and have the same size, but they are not equal matrices: $AB\ne BA$.
Example 4
If $A=0_{n\times n}$ is the $n\times n$ zero matrix and $B$ is any $n\times n$ matrix, then
- $AB=0_{n\times n}$, and
- $BA=0_{n\times n}$.
- So in this case, we do have $AB=BA$.
Example 5
If $A=\mat{1&2\\3&4}$ and $B=\mat{7&10\\15&22}$, then
- $AB=\mat{37&54\\81&118}$
- $BA=\mat{37&54\\81&118}$
- So $AB=BA$ for these particular matrices $A$ and $B$.
Example 6
If $A=\mat{1&2\\3&4}$ and $B=\mat{6&10\\15&22}$, then
- $AB=\mat{36&54\\78&118}$
- $BA= \mat{36&52\\81&118}$
- So $AB\ne BA$.
Commuting matrices I
We say that matrices $A$ and $B$ commute if $AB=BA$.
- Because it's true that $AB=BA$ for every choice of matrices $A$ and $B$, we say that matrix multiplication is not commutative.
Commuting matrices II
- What can we say about a pair of commuting matrices?
- Suppose $AB=BA$ and think about sizes.
- $A$: $n\times m$
- $B$: $\ell\times k$
- $AB$ is defined, so $m=\ell$.
- $BA$ is defined, so $k=n$.
- $AB$ is $n\times k$ and $BA$ is $\ell\times m$, so $n=\ell$ and $k=m$. So $n=\ell=m=k$!
- $A$ and $B$ must both be $n\times n$: they're square matrices of the same size.
Commuting matrices III
- If $A$ and $B$ commute, they must be square matrices of the same size.
- Some pairs of square matrices $A$ and $B$ of the same size do commute…
- ….but not all!
- See examples above.
The $n\times n$ identity matrix
The $n\times n$ identity matrix is the $n\times n$ matrix $I_n$ with $1$s in every diagonal entry (that is, in the $(i,i)$ entry for every $i$ between $1$ and $n$), and $0$s in every other entry. So \[ I_n=\begin{bmatrix} 1&0&0&\dots&0\\0&1&0&\dots&0\\0&0&1&\dots&0\\\vdots & & &\ddots & \vdots\\0&0&0&\dots&1\end{bmatrix}.\]
Examples
- $I_1=[1]$
- $I_2=\mat{1&0\\0&1}$
- $I_3=\mat{1&0&0\\0&1&0\\0&0&1}$
- $I_4=\mat{1&0&0&0\\0&1&0&0\\0&0&1&0\\0&0&0&1}$, and so on!
Properties of $I_n$
- $I_nA=A$ for any $n\times m$ matrix $A$;
- $AI_m=A$ for any $n\times m$ matrix $A$; and
- $I_nB=B=BI_n$ for any $n\times n$ matrix $B$.
- In particular, $I_n$ commutes with every other square $n\times n$ matrix $B$.
Proof that $I_nA=A$ for $A$: $n\times m$
- $I_nA$ is $n\times m$ (from definition of matrix multiplication)
- So $I_nA$ has same size as $A$
- $\text{row}_i(I_n)=[0~0~\dots~0~1~0~\dots~0]$, with $1$ in $i$th place
- $\text{col}_j(A)=\mat{a_{1j}\\a_{2j}\\\vdots\\a_{nj}}$
- So $(i,j)$ entry of $I_nA$ is \[\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\text{row}_i(I_n)\cdot \text{col}_j(A)= 0a_{1j}+0a_{2j}+\dots+1a_{ij}+\dots+0a_{nj} =a_{ij}\]
- same as $(i,j)$ entry of $A$.
- So $I_nA=A$
More proofs
- Proof that $A=AI_m$ for $A$: $n\times m$ is very similar (exercise)
- Now if $B$ is $n\times n$, take $n=m$ and $A=B$ above:
- $I_nB=B$ and $BI_n=B$
- So $I_nB=B=BI_n$
- So $I_n$ commutes with $B$, for any $n\times n$ matrix $B$.

