# Matrix Multiplication

Matrix multiplication of "m by n matrix" $ A_{m\text{x}n} $ by "p by q matrix" $ B_{p\text{x}q} $ can be defined exactly when the dimensions n and p are equal. (It doesn't make sense otherwise.)

The concise (and possibly confusing) "symbolic" definition defines the product of an "m by n matrix" $ A_{m\text{x}n} $ and a "n by q matrix" $ B_{p\text{x}q} $ (written P=AB) is given entry by entry as

$ P_{ij}=\sum_{k=1}^{n}(A_{mk}*B_{kq}) $.

In other words, to calculate a specific number in row r and column c in AB, look only at the row r in A, and in column c in B. Then multiply the first number in A's row by the first number in B's column, and the second number in B's row by the second number in B's column, and so on. Finally, add these all up to get that specific number in the product matrix.

For example, to mutliply the first matrix **A** by the second matrix **B**, consider only one row and column at a time:

$ \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix} \times \begin{bmatrix} 4 & 6 & 9\\ 2 & 3 & 5\\ 7 & 8 & 1\end{bmatrix} $

By multiplying a **2** by 3 matrix with a 3 by **3** matrix, the result will be a **2** by **3** matrix. To get the entry in the second row and first column of the product, consider only the second row in A, and the first column in B.

$ \begin{bmatrix} ? & ? & ? \\ 4 & 5 & 6 \end{bmatrix} \times \begin{bmatrix} 4 & ? & ?\\ 2 & ? & ?\\ 7 & ? & ?\end{bmatrix} =\begin{bmatrix} ? & ? & ? \\ 68 & ? & ?\end{bmatrix} $

Because $ 4*4+5*2+6*7=68 $, that entry is 68. This can be repeated for all 6 entries to find the product.

Keep in mind that matrix multiplication depends on the order the matrices are multiplied; computing AB is usually not the same as BA. This means matrix multiplication is not commutative.