Two matrices can be multiplied together as the number of columns in the first matrix equals the number of rows in the second matrix. The resultant matrix size is the number of rows from the first matrix and the number of columns from the second matrix. >[!example]- >Multiplying a 2 x 3 matrix with a 3 x 4 matrix will result in a 2 x 4 matrix. Each element of the resulting matrix ($\mathbf{C}$) is calculated by: - Taking a row from the first matrix - Taking a column from the second matrix - Multiplying the row and column element by element - Adding all of the results together $\mathbf{C}=\mathbf{A}\mathbf{B}$ $c_{ij}=\sum_0^n a_{in}b_{nj}$ In other words; the resultant matrix element in row 1, column 1, is calculated by multiplying row 1 of the first matrix and column 1 of the second matrix. Then the resultant matrix element in row 1, column 2, is calculated by multiplying row 1 of the first matrix and column 2 of the second matrix, etc. >[!example]- >- Consider multiplying the following 3 x 2 and 2 x 3 matrices. >- These two matrices can be multiplied because the number of columns in the first matrix equals the number of rows in the second matrix. >- The resultant matrix size is 3 x 3. >$\begin{bmatrix}-2& 1\\1 &0\\3&2\end{bmatrix}\begin{bmatrix}3& 4 & 5\\ 2 & 4 & -1\end{bmatrix}$ >Then the element in row 1, column 1 will be calculated from row 1 of the first matrix and column 1 of the second matrix: >$-2(3)+1(2)=-4$ >The element in row 1, column 2 is calculated from row 1 of the first matrix and column 2 of the second matrix: >$-2(4)+1(4)=-4$ >Row 1, column 3: >$-2(5)+1(-1)=-11$ >Following this trend you can calculate the following matrix: >$\begin{bmatrix}-2& 1\\1 &0\\3&2\end{bmatrix}\begin{bmatrix}3& 4 & 5\\ 2 & 4 & -1\end{bmatrix}=\begin{bmatrix}-4 &-4 &-11\\ 3 & 4 & 5\\ 13 & 20 & 13 \end{bmatrix}$ When multiplying matrices the order in which the matrices matters (non-[[Commutative|commutative]]). Consider matrices $\mathbf{A}$ and $\mathbf{B}$: $\mathbf{A}\mathbf{B}\ne\mathbf{B}\mathbf{A}$ Multiplication of matrices also follows the [[Distributive|distributive]] property: $\mathbf{A}(\mathbf{B}+\mathbf{C})=\mathbf{A}\mathbf{B}+\mathbf{A}\mathbf{C}$ Multiplication of matrices is also [[Associative|associative]]: $(\mathbf{A}\mathbf{B})\mathbf{C}=\mathbf{A}(\mathbf{B}\mathbf{C})$