# Product of matrices

In a strict sense, the rule to multiply matrices is:

"The matrix product of two matrixes $$A$$ and $$B$$ is a matrix $$C$$ whose elements $$a_{ij}$$ are formed by the sums of the products of the elements of the row $$i$$ of the matrix $$A$$ by those of the column $$j$$ of the matrix $$B$$."

Actually, this is not a very encouraging statement, but in the end it is simple and only requires a little practice, since it is a question of multiplying the rows of the first matrix by the columns of the second one.

$$\left( \begin{array}{ccc} 5 & 2 & 1 \end{array} \right) \cdot \left( \begin{array}{c} 4 \\ -3 \\ 6 \end{array} \right) = 5\cdot4+2\cdot(-3)+1\cdot6=20-6+6=20$$$That is, we have to multiply the first element of the row in the first matrix by the first element from the column in the second matrix, then add up this product and the product of the second element in the row by the second element in the column, and finally add up the product of the third element in the row by the third element in the column. This is easier done than said! $$\left( \begin{array}{ccc} 2 & 3 & 5 \end{array} \right) \cdot \left( \begin{array}{c} 3 \\ 2 \\ 4 \end{array} \right) = 2\cdot3+3\cdot2+5\cdot4=6+6+20=32$$$

Let's see a product of two square matrices $$2\times2$$

$$\left( \begin{array}{cc} 1 & 5 \\ 2 & 2 \end{array} \right) \cdot \left( \begin{array}{cc} 3 & 4 \\ 1 & 6 \end{array} \right) = \left( \begin{array}{cc} 1\cdot3+5\cdot1 & 1\cdot4+5\cdot6 \\ 2\cdot3+2\cdot1 & 2\cdot4+2\cdot6 \end{array} \right) = \left( \begin{array}{cc} 8 & 34 \\ 8 & 20 \end{array} \right)$$$Every element $$a_{ij}$$ is obtained by adding the products of the elements of row $$i$$ by those of column $$j$$. For example, $$8$$, the element of the first row and the first column of the resultant matrix, is obtained by multiplying the first row of the first matrix by the first column of the second matrix. Number $$8$$, which is the element of the second row and the first column in the final matrix, is obtained by multiplying the second row in the first matrix by the first column in the second matrix, and so on with the rest of the elements. To clarify this process we are going to mark the corresponding rows and columns of the product matrix: $$\left( \begin{array}{cc} \fbox{1} & \fbox{5} \\ 2 & 2 \end{array} \right) \cdot \left( \begin{array}{cc} \fbox{3} & 4 \\ \fbox{1} & 6 \end{array} \right) = \left( \begin{array}{cc} \fbox{8} & 34 \\ 8 & 20 \end{array} \right)$$$

$$\left( \begin{array}{cc} \fbox{1} & \fbox{5} \\ 2 & 2 \end{array} \right) \cdot \left( \begin{array}{cc} 3 & \fbox{4} \\ 1 & \fbox{6} \end{array} \right) = \left( \begin{array}{cc} 8 & \fbox{34} \\ 8 & 20 \end{array} \right)$$$$$\left( \begin{array}{cc} 1 & 5 \\ \fbox{2} & \fbox{2} \end{array} \right) \cdot \left( \begin{array}{cc} \fbox{3} & 4 \\ \fbox{1} & 6 \end{array} \right) = \left( \begin{array}{cc} 8 & 34 \\ \fbox{8} & 20 \end{array} \right)$$$

$$\left( \begin{array}{cc} 1 & 5 \\ \fbox{2} & \fbox{2} \end{array} \right) \cdot \left( \begin{array}{cc} 3 & \fbox{4} \\ 1 & \fbox{6} \end{array} \right) = \left( \begin{array}{cc} 8 & 34 \\ 8 & \fbox{20} \end{array} \right)$$$In fact, we only need to remember that we must multiply "row by column". For example, let's calculate the value of the marked element in the following product matrix: $$\left( \begin{array}{ccccc} 1 & 3 & -2 & 5 & 0 \\ 8 & 1 & 0 & -1 & 2 \\ 4 & 2 & 5 & 3 & 1 \\ 0 & -2 & 3 & 5 & 3 \\ 7 & 1 & 0 & 3 & 7 \end{array} \right) \cdot \left( \begin{array}{ccccc} 2 & 6 & 3 & -1 & 0 \\ 8 & 2 & 4 & 6 & 1 \\ 0 & 2 & 1 & 4 & 3 \\ 1 & 5 & 3 & 7 & 2 \\ 5 & 8 & 3 & 9 & 2 \end{array} \right) = \left( \begin{array}{ccccc} \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } \\ \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } \\ \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } \\ \fbox{ } & \fbox{ } & \fbox{?} & \fbox{ } & \fbox{ } \\ \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } \end{array} \right)$$$

We have to multiply the fourth row by the third column:

$$\left( \begin{array}{ccccc} 1 & 3 & -2 & 5 & 0 \\ 8 & 1 & 0 & -1 & 2 \\ 4 & 2 & 5 & 3 & 1 \\ \fbox{0} & \fbox{-2} & \fbox{3} & \fbox{5} & \fbox{3} \\ 7 & 1 & 0 & 3 & 7 \end{array} \right) \cdot \left( \begin{array}{ccccc} 2 & 6 & \fbox{3} & -1 & 0 \\ 8 & 2 & \fbox{4} & 6 & 1 \\ 0 & 2 & \fbox{1} & 4 & 3 \\ 1 & 5 & \fbox{3} & 7 & 2 \\ 5 & 8 & \fbox{3} & 9 & 2 \end{array} \right) =$$$$$= \left( \begin{array}{ccccc} \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } \\ \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } \\ \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } \\ \fbox{ } & \fbox{ } & 0\cdot3+(-2)\cdot4+3\cdot1+5\cdot3+3\cdot3 & \fbox{ } & \fbox{ } \\ \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } & \fbox{ } \end{array} \right)$$$

So, the element we were looking for in the product matrix is $$a_{43}=19$$.

Let's see another example. We will do the product of two $$3\times3$$ matrices (this will be the most complicated case that we will see).

$$\left( \begin{array}{ccc} 2 & 5 & 1 \\ 4 & -2 & 0 \\ 1 & 6 & 2 \end{array} \right) \cdot \left( \begin{array}{ccc} 1 & 2 & 3 \\ 3 & 4 & 1 \\ 1 & -4 & 2 \end{array} \right) = \left( \begin{array}{ccc} 18 & 20 & 13 \\ -2 & 0 & 10 \\ 21 & 18 & 13 \end{array} \right)$$$We are going to give a detailed analysis of how some of its elements have been calculated. The element $$a_{11}$$ is obtained by multiplying the first row by the the first column: $$\left( \begin{array}{ccc} \fbox{2} & \fbox{5} & \fbox{1} \\ 4 & -2 & 0 \\ 1 & 6 & 2 \end{array} \right) \cdot \left( \begin{array}{ccc} \fbox{1} & 2 & 3 \\ \fbox{3} & 4 & 1 \\ \fbox{1} & -4 & 2 \end{array} \right) = \left( \begin{array}{ccc} \fbox{18} & 20 & 13 \\ -2 & 0 & 10 \\ 21 & 18 & 13 \end{array} \right)$$$

$$2\cdot1+5\cdot3+1\cdot1=2+15+1=18$$$The element $$a_{23}$$ is obtained by multiplying the second row by the third column: $$\left( \begin{array}{ccc} 2 & 5 & 1 \\ \fbox{4} & \fbox{-2} & \fbox{0} \\ 1 & 6 & 2 \end{array} \right) \cdot \left( \begin{array}{ccc} 1 & 2 & \fbox{3} \\ 3 & 4 & \fbox{1} \\ 1 & -4 & \fbox{2} \end{array} \right) = \left( \begin{array}{ccc} 18 & 20 & 13 \\ -2 & 0 & \fbox{10} \\ 21 & 18 & 13 \end{array} \right)$$$

$$4\cdot3+(-2)\cdot1+0\cdot2=12-2+0=10$$$The element $$a_{31}$$ is obtained by multiplying the third row by the the first column: $$\left( \begin{array}{ccc} 2 & 5 & 1 \\ 4 & -2 & 0 \\ \fbox{1} & \fbox{6} & \fbox{2} \end{array} \right) \cdot \left( \begin{array}{ccc} \fbox{1} & 2 & 3 \\ \fbox{3} & 4 & 1 \\ \fbox{1} & -4 & 2 \end{array} \right) = \left( \begin{array}{ccc} 18 & 20 & 13 \\ -2 & 0 & 10 \\ \fbox{21} & 18 & 13 \end{array} \right)$$$

$$1\cdot1+6\cdot3+1\cdot2=1+18+2=21$$$The element $$a_{22}$$ is obtained by multiplying the second row by the second column: $$\left( \begin{array}{ccc} 2 & 5 & 1 \\ \fbox{4} & \fbox{-2} & \fbox{0} \\ 1 & 6 & 2 \end{array} \right) \cdot \left( \begin{array}{ccc} 1 & \fbox{2} & 3 \\ 3 & \fbox{4} & 1 \\ 1 & \fbox{-4} & 2 \end{array} \right) = \left( \begin{array}{ccc} 18 & 20 & 13 \\ -2 & \fbox{0} & 10 \\ 21 & 18 & 13 \end{array} \right)$$$

$$4\cdot2+(-2)\cdot4+0\cdot2=8-8+0=0$$\$

The rest of the elements of the product of matrices are calculated using the same method.

At this point, we have realized that multiplying matrices is somewhat tiresome. Let's think, for example, that the product of two $$4\times4$$ matrices entails carrying out $$128$$ arithmetical operations.

Fortunately, most scientific calculators currently on the market include a matricial calculation. Nevertheless, it is advisable to do the product of $$3\times3$$ matrices "by hand" at least once in order to understand the mechanics of the operations.