Matrix multiplication
Important condition
Suppose we have two matrices \(A (m \times n) \)and \( B (n \times p)\). They can be multiplied because the number of columns of \(A\) is equal to the number of rows of \(B\). The resulting matrix is
$$C = AB$$
and its size will be \( (m \times p) \). In general: \( (m \times n)(n \times p) = (m \times p) \).
Computing entries
Each element of the resulting matrix is obtained by taking the dot product of a row of \(A\) with a column of \(B\).
$$c_{ij} = a_{i1}b_{1j} + a_{i2}b_{2j} + \ldots + a_{in}b_{nj}$$
This means that to calculate the element at position \((i, j)\) of the resulting matrix, you take row \(i\) of \(A\) and column \(j\) of \(B\), multiply the corresponding elements, and sum the products. As in the following steps:
- Take row \(i\) of matrix \(A\)
- Take column \(j\) of matrix \(B\)
- Multiply corresponding entries
- Add the results
Observe the following example
$$A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix} \quad B = \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix}$$
Then
$$AB = \begin{pmatrix} 1·5 + 2·7 & 1·6 + 2·8 \\ 3·5 + 4·7 & 3·6 + 4·8 \end{pmatrix}$$
$$AB = \begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix}$$
Important Properties
- Not commutative
- Associative
- Distributive over addition
$$AB \neq BA$$
In many cases the product \(BA\) may not even exist.
$$ (AB)C = A(BC) $$
$$A(B + C) = AB + AC$$
$$ (A + B)C = AC + BC $$
Identity Matrix
For every square matrix of size \(n \times n\) there exists a special matrix called the identity matrix, denoted by \(I_n\). The identity matrix has the following properties:
- All entries on the main diagonal are \(1\)
- All other entries are \(0\)
For example, when \(n = 3\), the identity matrix is:
$$I_3 = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix}$$
The identity matrix acts as the multiplicative identity for matrices. If \(A\) is an \(m \times n\) matrix, then
$$I_m A = A$$
$$A I_n = A$$
Therefore, multiplying a matrix by the appropriate identity matrix leaves the matrix unchanged.
Instructions
In this applet you will find examples of matrix multiplication. Press the “New” button to generate a different example, move the point on the slider to go through the multiplication process step by step, or press the Play button to automatically display the steps one by one. You can also use the up and down arrow buttons to change the number of rows or columns of the matrices and explore different matrix multiplication cases.