Why the Order Matters in Matrix Multiplication
Why the Order Matters in Matrix Multiplication
Matrix multiplication is a fundamental operation in linear algebra, widely used in various fields such as computer science, physics, and engineering. One of the key properties of matrix multiplication is that the order of the matrices involved matters. This article explores the reasons behind this property and its implications.
Dimensions
For two matrices (A) and (B) to be multiplied, the number of columns in (A) must match the number of rows in (B). This condition is crucial because it ensures that the dimensions of the resulting matrix are well-defined. If (A) is an (m times n) matrix and (B) is an (p times q) matrix, then (n) must equal (p). The resulting matrix (AB) will have dimensions (m times q).
Associativity but not Commutativity
Matrix multiplication is associative, which means that for any three matrices (A), (B), and (C), the equation (ABC (AB)C A(BC)) holds true. However, matrix multiplication is generally not commutative. That is, in general, (AB eq BA). This non-commutativity arises because the way the rows of (A) interact with the columns of (B) is different from how the rows of (B) would interact with the columns of (A).
Geometric Interpretation
In many applications, matrices represent transformations. The order of multiplication reflects the sequence in which these transformations are applied. Consider a rotation matrix (A) and a scaling matrix (B). The product (AB) represents first scaling then rotating, while (BA) represents first rotating then scaling. These transformations will generally yield different results, emphasizing the importance of the order of multiplication.
Element-wise Calculation
The elements of the resulting matrix (C AB) are computed as:
(C_{ij} sum_{k1}^{n} A_{ik} B_{kj})
This operation relies on the specific arrangement of the rows of (A) and the columns of (B). Changing the order of the matrices will change which elements are summed together, leading to different results.
Example
Let’s consider the following two matrices:
A begin{pmatrix} 1 2 3 4 end{pmatrix} B begin{pmatrix} 5 6 7 8 end{pmatrix}
Calculating (AB):
AB begin{pmatrix} 1 cdot 5 2 cdot 7 1 cdot 6 2 cdot 8 3 cdot 5 4 cdot 7 3 cdot 6 4 cdot 8 end{pmatrix} begin{pmatrix} 19 22 43 50 end{pmatrix}
Now calculating (BA):
BA begin{pmatrix} 5 cdot 1 6 cdot 3 5 cdot 2 6 cdot 4 7 cdot 1 8 cdot 3 7 cdot 2 8 cdot 4 end{pmatrix} begin{pmatrix} 23 34 29 50 end{pmatrix}
As shown, (AB) and (BA) yield different results, which further illustrates the importance of the order in matrix multiplication.