# Section 2.3 Matrix Multiplication

Definition: Let $\vec{x}$ be a vector in $\mathbb{R}^p$ and $A$ be a $m \times n$ matrix and $B$ be a $n \times p$ matrix then $B\vec{x}$ is a vector in $\mathbb{R}^n$ and then $A(B\vec{x})$ is a vector in $\mathbb{R}^m$. We call $A(B\vec{x})$ the composition of mappings.

Notice: $A(B\vec{x})$ is only defined that the number of columns of $A$ is the number of rows of $B$.

Question: The composition $A(B\vec{x})$ is a matrix transformation that map from $\mathbb{R}^p$ to $\mathbb{R}^m$. What is the matrix of the transformation?

Let $A = \begin{bmatrix}\vec{a_{1}} & \cdots & \vec{a_{n}} \end{bmatrix}$ and $B = \begin{bmatrix}\vec{b_{1}} & \cdots & \vec{b_{p}} \end{bmatrix}$, and $\vec{x} = \begin{bmatrix}x_{1}\\\vdots\\x_{p}\end{bmatrix}$ then $B\vec{x} = x_{1}\vec{b_{1}}+\cdots+x_{p}\vec{b_{p}}$. We have

$A(B\vec{x}) = A(x_{1}\vec{b_{1}} + \cdots + x_{p}\vec{b_{p}})\\ = x_{1}A\vec{b_{1}} + \cdots +x_{p}A\vec{b_{p}}\\ = \begin{bmatrix}A\vec{b_{1}}\cdots A\vec{b_{p}}\end{bmatrix}\begin{bmatrix}x_{1}\\\vdots\\x_{p}\end{bmatrix}\\ = (AB)\vec{x}$

It is naturally that we call the matrix $\begin{bmatrix}A\vec{b_{1}}\cdots A\vec{b_{p}}\end{bmatrix}$ the product of the matrices $A$ and $B$ which is written $AB$.

Definition: Let $A$ be a $m \times n$ matrix and $B$ be a $n \times p$ matrix with column vectors $\vec{b_{1}}, \cdots, \vec{b_{p}}$, then the product of $A$ and $B$ which is written $AB$ is the $m \times p$ matrix $\begin{bmatrix}A\vec{b_{1}}\cdots A\vec{b_{p}}\end{bmatrix}$.

Example 1: Find $AB$ and $BA$ if they are defined, where $A = \begin{bmatrix} 1 & 2 & 3\\ 2 & -1 & 4 \end{bmatrix}$ and $B = \begin{bmatrix} 2 & 0 & -1 & 3\\ 0 & 4 & 6 & 2\\ 3 & 1 & 0 & 1 \end{bmatrix}$.

Exercise 1: Find $AB$ and $BA$ if they are defined, where $A = \begin{bmatrix} 1 & -2 & 0\\ 2 & 1 & 1\\ 3 & -2 & 0\\ 0 & 1 & 2\\ \end{bmatrix}$ and $B = \begin{bmatrix} 2 & 0 & -1 & 3\\ 0 & 4 & 6 & 2 \end{bmatrix}$.

Definition: Given two vectors $\vec{u}$ and $\vec{v}$ in $\mathbb{R}^n$. The scalar product or the dot product or inner product of $\vec{u}$ and $\vec{v}$ is $(\vec{u})^T\vec{v}$. The outer product of $\vec{u}$ and $\vec{v}$ is $(\vec{u}\vec{v})^T$.

Example 2: Find the inner product and the outer product of $\vec{u}=\begin{bmatrix}2\\1\end{bmatrix}$ and $\vec{v}=\begin{bmatrix}2\\1 \end{bmatrix}$.

Exercise 2: Find the inner product and the outer product of $\vec{u}=\begin{bmatrix}0\\1\\2\end{bmatrix}$ and $\vec{v}=\begin{bmatrix}-1\\0\\3\end{bmatrix}$.

Theorem: (Dot Product Rule) Let $A$ and $B$ be matrices of sizes $m \times n$ and $n \times p$, respectively. Then the $(i, j)$-entry of $AB$ is the dot product of row $i$ of $A$ with column $j$ of $B$.

Example 3: Find $AB$ and $BA$ where $A = \begin{bmatrix}1 & -1\\2 & 3\end{bmatrix}$, and $B = \begin{bmatrix}0 & 2\\4 & 5\end{bmatrix}$. What can you say about the relationship of $AB$ and $BA$?

Exercise 3: Find $AB$ and $AC$ where $A = \begin{bmatrix}3 & -6\\-1 & 2\end{bmatrix}$, $B = \begin{bmatrix}0 & 2\\4 & 5\end{bmatrix}$, $C = \begin{bmatrix}-3 & -5\\2 & 1\end{bmatrix}$. What can you say about the relationship of $AB$ and $AC$? The relationship of $B$ and $C$?

Remark: 1. In general $AB \neq BA$.

2. When $AB = AC$, we cannot conclude that $B = C$ as in exercise 3.

3. When $AB = 0$, we cannot conclude that $A$ or $B$ is 0.

Theorem: Let $A$ be a $m \times n$ matrix, $B$ and $C$ be matrices of the same size such that the products with $A$ are defined, and $r$ be a scalar. Then

a. $A(BC)=(AB)C$

b. $A(B + C)=AB + AC$

c. $(B + C)A=BA + CA$

d. $r(AB)=(rA)B=A(rB)$

e. $I_{m}A = A = AI_{n}$ where I_{m} is the $m \times m$ identity matrix and $I_{n}$ is the $n \times n$ identity matrix.

f. $(AB)^T=B^T A^T$

Example 4: Find $A^T$, $B^T$ and $(BA)^T$ where $A = \begin{bmatrix}1 & 2 & 3\\-1 & 3 & 2\\0 & -1 & 1\end{bmatrix}$, and $B = \begin{bmatrix}2 & -1 & 3\\1 & 3 & 2\end{bmatrix}$.

Exercise 4: Find $A^T$, $B^T$ and $(BA)^T$ where $A = \begin{bmatrix}2 & 3\\0 & 4\\-1 & 2\end{bmatrix}$, and $B = \begin{bmatrix}2 & -1\\1 & 3\end{bmatrix}$.

Definition: Let $A$ be a $n \times n$ matrix then $A^k$ denotes the product of $k$ copies of $A$, i.e. $A^k = A...A$ for $k$ times

Example 5: Find $A^3$ where $A = \begin{bmatrix}1 & 0 & 3\\-1 & 3 & 2\\0 & -1 & 1\end{bmatrix}$.

Exercise 5: Find $B^4$ where $B = \begin{bmatrix}2 & -1\\1 & 3\end{bmatrix}$.

Group Work 1: Mark each statement True or False. Justify each answer.

a. If $A$ and $B$ are $2 \times 2$ matrix with columns $\vec{a_{1}}, \vec{a_{2}}$ and $\vec{b_{1}}, \vec{b_{2}}$. Then the product $AB = \begin{bmatrix}\vec{a_{1}}\vec{b_{1}} & \vec{a_{2}}\vec{b_{2}}\end{bmatrix}$.

b. $A(B+C) = AB + BC$.

c. $A^T + B^T = (A + B)^T$.

d. The transpose of a product of matrices equals the product of their
transposes in the same order.

e. The first row of $AB$ is the first row of $A$ multiplied on the right by $B$.

f. $A$ is an $n \times n$ matrix , then $(A^2)^T = (A^T)^2$.

g. $(ABC)^T=C^T A^T B^T$.

Group Work 2: Find $2 \times 2$ nonzero matrices $A$ and $B$ such that

a. $A^2 = 0$

b. $A^2 = A$

Group Work 3: If $A$ is any matrix, show that both $AA^T$ and $A^T A$ are symmetric.

Group Work 4: In each case either show the statement is true, or give an example showing that it is false.

a. If $A^2 = I$, then $A = I$.

b. If $AJ = A$, then $J = I$.

c. If $A$ is symmetric, then $I + A$ is symmetric.

d. If $AB = AC$ and $A \neq 0$, then $B = C$.

e. If $A \neq 0$, then $A^2 \neq 0$.

f. If $A$ has a row of zeros, so also does $BA$ for all $B$.

g. If $B$ has a column of zeros, so also does $AB$.

h. If $A$ has a row of zeros, so also does $AB$.