**Matrix multiplication** is an [[operation]] that takes an ordered pair $(A,B)$ of *compatible* [[matrix|matrices]] and outputs another matrix $M$.
Let $A\in K^{m\times n}$
Let $B\in K^{n\times s}$
Let $M\in K^{m\times s}$ be the product of $A$ and $B$ (in this order)
$M=AB=(m_{ik})$
$\begin{aligned}
m_{ik}&=\mathbf a_{i©}\cdot\mathbf b_{®k}\\
&=\sum_{j=1}^{n} a_{i j} b_{j k}\\
&=a_{i 1} b_{1 k}+a_{i 2} b_{2 k}+\cdots+a_{i n} b_{n k}
\end{aligned}$
$M=A B=\left(\begin{array}{ccc}\mathbf a_{1©}\cdot\mathbf b_{®1} & \cdots & \mathbf a_{1©}\cdot\mathbf b_{®s} \\ \vdots & \ddots& \vdots \\ \mathbf a_{m©}\cdot\mathbf b_{®1} & \cdots & \mathbf a_{m©}\cdot\mathbf b_{®s}\end{array}\right)$
- *Compatibility* is equivalent to equality of:
- the number of columns, $n,$ from the first (left) matrix $A$
- the number of rows, $n,$ from the second (right) matrix $B$
- Matrices need to be compatible, because the product's elements $m_{ik}$ are defined using:
- a [[dot product]] $\mathbf a_{i©}\cdot\mathbf b_{®k}$ of the corresponding
- $i^{\text{th}}$ row of $A$
- written here as $\mathbf a_{i©}$
- $j^{\text{th}}$ row of $B$
- written here as $\mathbf b_{®k}$
- and these two vectors need to be from the same [[vector space]]