General Matrix Multiply
Matrix Multiplication Basics
The Rules of Engagement
Multiplying matrices isn't like multiplying regular numbers. You can't just multiply corresponding elements. Instead, there's a specific set of rules to follow, starting with a crucial condition for whether two matrices can be multiplied at all.
To multiply two matrices, the number of columns in the first matrix must be equal to the number of rows in the second matrix.
Think of it like a compatibility check. If you have an matrix (m rows, n columns) and want to multiply it by a matrix (p rows, q columns), the multiplication is only possible if . The inner dimensions must match.
The resulting matrix will have dimensions equal to the outer numbers: . So, multiplying a matrix by a matrix is possible, and the result will be a matrix. However, you can't multiply a matrix by a matrix.
The Row-by-Column Method
Once you confirm the dimensions are compatible, the actual multiplication involves a process of multiplying rows from the first matrix by columns from the second.
To find the element in the -th row and -th column of the new matrix, you take the -th row of the first matrix and the -th column of the second. Then, you multiply their corresponding elements and add up the results. This is also known as the dot product.
Let's walk through a numerical example. We'll multiply a matrix by a matrix. The inner dimensions (3 and 3) match, so we can proceed. The result will be a matrix.
Let's do the arithmetic. The top-left entry is $7 + 18 + 33 = 58$. The top-right is $8 + 20 + 36 = 64$. The bottom-left is $28 + 45 + 66 = 139$. And the bottom-right is $32 + 50 + 72 = 154$.
Important Properties
Matrix multiplication has several properties, but it's crucial to know that it is not commutative. In general, . The order you multiply matrices in matters immensely. In our last example, we found . If we tried to compute , we'd be multiplying a matrix by a matrix. The result would be a matrix, which is a completely different size and shape!
However, matrix multiplication is associative. This means that when you multiply three matrices, the grouping doesn't matter: . It's also distributive, meaning .
Just like the number 1 in regular multiplication, there is an identity matrix, denoted as . It's a square matrix with 1s on the main diagonal and 0s everywhere else. Multiplying any matrix by the identity matrix leaves it unchanged: and .
Similarly, the zero matrix is a matrix filled entirely with zeros. Multiplying any matrix by a zero matrix (of compatible dimensions) results in a zero matrix.
Now, let's test your understanding of these core concepts.
If matrix A is a matrix and matrix B is a matrix, what are the dimensions of the product matrix ?
Which of the following properties does NOT apply to matrix multiplication in general?
Mastering these rules is the first step to unlocking the power of matrices in fields from computer graphics to data science.
