Different Perspectives on Matrix Multiplication
Introduction
Matrix multiplication is a fundamental operation in linear algebra with a wide range of applications in fields like physics, computer graphics, and data science. While the standard method of calculating a matrix product is a good starting point, understanding it from different conceptual angles can provide deeper insights into its utility and meaning.
Dot Product of Rows and Columns
The most common way to perform matrix multiplication is by taking the dot product of the rows of the first matrix with the columns of the second matrix. For two matrices to be multipliable, the number of columns in the first matrix must equal the number of rows in the second.
If we have a matrix \(A\) of size \(m \times n\) and a matrix \(B\) of size \(n \times p\), their product, \(C = AB\), will be a matrix of size \(m \times p\). The entry in the \(i\)-th row and \(j\)-th column of \(C\), denoted as \(c_{ij}\), is calculated by taking the dot product of the \(i\)-th row of \(A\) and the \(j\)-th column of \(B\).
Example:
Let’s consider two matrices, \(A\) and \(B\):
\(A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}\) and \(B = \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix}\)
To find the element in the first row and first column of the resulting matrix \(C\), we take the dot product of the first row of \(A\) and the first column of \(B\):
\(c_{11} = (1 \times 5) + (2 \times 7) = 5 + 14 = 19\)
For the first row and second column of \(C\):
\(c_{12} = (1 \times 6) + (2 \times 8) = 6 + 16 = 22\)
For the second row and first column of \(C\):
\(c_{21} = (3 \times 5) + (4 \times 7) = 15 + 28 = 43\)
And for the second row and second column of \(C\):
\(c_{22} = (3 \times 6) + (4 \times 8) = 18 + 32 = 50\)
So, the resulting matrix \(C\) is:
\(C = \begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix}\)
Linear Combinations of Columns
Another powerful way to view matrix multiplication is to see the resulting columns as linear combinations of the columns of the first matrix. Each column of the product matrix \(AB\) is a linear combination of the columns of matrix \(A\), with the weights for the combination coming from the corresponding column of matrix \(B\).
Example:
Using the same matrices \(A\) and \(B\):
\(A = \begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}\) and \(B = \begin{pmatrix} 5 & 6 \\ 7 & 8 \end{pmatrix}\)
The first column of the product matrix \(C\) is a linear combination of the columns of \(A\) using the elements of the first column of \(B\) as weights:
First column of \(C = 5 \begin{pmatrix} 1 \\ 3 \end{pmatrix} + 7 \begin{pmatrix} 2 \\ 4 \end{pmatrix} = \begin{pmatrix} 5 \\ 15 \end{pmatrix} + \begin{pmatrix} 14 \\ 28 \end{pmatrix} = \begin{pmatrix} 19 \\ 43 \end{pmatrix}\)
The second column of \(C\) is a linear combination of the columns of \(A\) using the elements of the second column of \(B\) as weights:
Second column of \(C = 6 \begin{pmatrix} 1 \\ 3 \end{pmatrix} + 8 \begin{pmatrix} 2 \\ 4 \end{pmatrix} = \begin{pmatrix} 6 \\ 18 \end{pmatrix} + \begin{pmatrix} 16 \\ 32 \end{pmatrix} = \begin{pmatrix} 22 \\ 50 \end{pmatrix}\)
Assembling these columns gives us the same resulting matrix \(C\):
\(C = \begin{pmatrix} 19 & 22 \\ 43 & 50 \end{pmatrix}\)
This perspective is particularly useful in understanding how a matrix can transform a set of vectors.
Composition of Linear Transformations
Perhaps the most abstract yet insightful way to think about matrix multiplication is as a composition of linear transformations. A matrix can be seen as a representation of a linear transformation, which is a function that maps vectors to other vectors in a linear way. When we multiply two matrices, \(A\) and \(B\), the resulting matrix \(AB\) represents the composite transformation obtained by first applying the transformation represented by \(B\), and then applying the transformation represented by \(A\).
Example:
Let’s consider two linear transformations in a 2D plane. Let transformation \(B\) be a rotation by 90 degrees counterclockwise, and transformation \(A\) be a reflection across the x-axis.
The matrix for a 90-degree counterclockwise rotation is:
\(B = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}\)
The matrix for a reflection across the x-axis is:
\(A = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}\)
To find the matrix that represents the composite transformation of first rotating by 90 degrees and then reflecting across the x-axis, we multiply the matrices \(A\) and \(B\):
\(AB = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix} \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix} = \begin{pmatrix} (1)(0)+(0)(1) & (1)(-1)+(0)(0) \\ (0)(0)+(-1)(1) & (0)(-1)+(-1)(0) \end{pmatrix} = \begin{pmatrix} 0 & -1 \\ -1 & 0 \end{pmatrix}\)
Now, let’s see how a vector, for instance, \(\begin{pmatrix} 2 \\ 1 \end{pmatrix}\), is transformed by this composite transformation.
Applying the composite transformation matrix \(AB\):
\(\begin{pmatrix} 0 & -1 \\ -1 & 0 \end{pmatrix} \begin{pmatrix} 2 \\ 1 \end{pmatrix} = \begin{pmatrix} (0)(2)+(-1)(1) \\ (-1)(2)+(0)(1) \end{pmatrix} = \begin{pmatrix} -1 \\ -2 \end{pmatrix}\)
We can verify this by applying the transformations sequentially. First, the rotation by \(B\):
\(\begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} 2 \\ 1 \end{pmatrix} = \begin{pmatrix} -1 \\ 2 \end{pmatrix}\)
Then, the reflection by \(A\) on the result:
\(\begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix} \begin{pmatrix} -1 \\ 2 \end{pmatrix} = \begin{pmatrix} -1 \\ -2 \end{pmatrix}\)
The results are the same, illustrating that matrix multiplication indeed corresponds to the composition of linear transformations. This perspective is foundational in many areas of mathematics.