# Matrix Multiplication

### From bio-physics-wiki

In the articles on Matrices it is explained where matrices come from. We have discussed the column picture and later the row operations with matrices, they are an intuitive way to think about matrix multiplication. Now we want to focus on more general concepts of matrix multiplication.

\begin{align} \begin{bmatrix} a_{11} & a_{12} & a_{13}\\ a_{21} & a_{22} & a_{23}\\ a_{31} & a_{32} & a_{33} \end{bmatrix} \begin{bmatrix} b_{11} & b_{12} & b_{13}\\ b_{21} & b_{22} & b_{23}\\ b_{31} & b_{32} & b_{33} \end{bmatrix} =\begin{bmatrix} c_{11} & c_{12} & c_{13}\\ c_{21} & c_{22} & c_{23}\\ c_{31} & c_{32} & c_{33} \end{bmatrix} \end{align} In short notation we can write \begin{align} \mathbf{AB}=\mathbf{C} \end{align} The entry of the row $i$ and column $j$ is called $c_{ij}$. How do we calculate the $c_{ij}$ entry? We can calculate $c_{ij}$ by multiplying the $i$th row of $\mathbf{A}$ by the $j$th column of matrix $\mathbf{B}$ \begin{align} \sum_k a_{ik}b_{kj}=c_{ij} \end{align} For our example above and say the $c_{23}$ entry we have \begin{align} c_{23}=\sum_k a_{2k}b_{k3}=a_{21}b_{13}+a_{22}b_{23}+a_{23}b_{33} \end{align} which is row $2$ times column $3$. A nice schema that helps to compute the $ij$'s entry is the following \begin{align} &\hspace{3.26cm} \begin{bmatrix} \color{green}{b_{11}} & \color{red}{b_{12}} & \color{blue}{b_{13}}\\ \color{green}{b_{21}} & \color{red}{b_{22}} & \color{blue}{b_{23}}\\ \color{green}{b_{31}} & \color{red}{b_{32}} & \color{blue}{b_{33}} \end{bmatrix}\\ &\begin{bmatrix} \color{red}{a_{11}} & \color{red}{a_{12}} & \color{red}{a_{13}}\\ \color{blue}{a_{21}} & \color{blue}{a_{22}} & \color{blue}{a_{23}}\\ \color{green}{a_{31}} & \color{green}{a_{32}} & \color{green}{a_{33}} \end{bmatrix} \begin{bmatrix} c_{11} & \color{red}{c_{12}} & c_{13}\\ c_{21} & c_{22} & \color{blue}{c_{23}}\\ \color{green}{c_{31}} & c_{32} & c_{33} \end{bmatrix} \end{align} write the second matrix ($\mathbf{B}$) above on the right. Now if you choose a row of $\mathbf{A}$ and a column of $\mathbf{B}$ and multiply them, this gives the $c_{ij}$ entry where lines drawn along the chosen row and columns meet. For example a line through the green row $a_{3k}$ and the green column $b_{k1}$ intersect at the $c_{31}$ entry. Similarly we get entries from the blue and red columns and rows. You can do this mentally if you want to find a certain entry.

So far we only looked at matrices that had two columns and two rows $2 \times 2$-matrices ($rows \, \times \, columns$-matrices) and three columns and rows $3 \times 3$ matrices. Can we also multiply matrices with arbitrary dimensions? For example, think about \begin{align} \begin{bmatrix} a_{11} & a_{12} & a_{13}\\ a_{21} & a_{22} & a_{23}\\ \end{bmatrix} \begin{bmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \end{bmatrix} \end{align} Multiplying the first row with the first column we immediately find, that the dimensions (number of entries in column or row) do not match, so we aren't able to multiply the matrices. In general we require, that the dimension of a row of $\mathbf{A}$ equals the dimension of the column of $\mathbf{B}$. So if matrix $\mathbf{A}$ has dimensions $m \times n$ than matrix $\mathbf{B}$ must have dimensions $n \times p$. The result of multiplication will be a $m \times p$-matrix \begin{align} (m \times \underline{n)(n} \times p)=m \times p \end{align}

Video Lectures:

- Gilbert Strang - Introduction to Linear Algebra Lec. 3