1) Introduction to Matrix Multiplication 🔢✖️
Welcome back to our journey into matrices! In Part 1, we explored the basics of matrices: their definition, types, and operations like addition, subtraction, and scalar multiplication. Now, in Part 2, we will tackle a fundamental and powerful operation: Matrix Multiplication. Matrix multiplication is a cornerstone of linear algebra and has wide-ranging applications in mathematics, physics, computer science, and engineering. It's a bit more involved than addition or scalar multiplication, but understanding it unlocks a new level of matrix manipulation.
Matrix Multiplication is an operation that produces a new matrix from two matrices. If \(A\) is an \(m \times n\) matrix and \(B\) is an \(n \times p\) matrix, their product \(C = AB\) is an \(m \times p\) matrix.
Notice the dimensions! For matrix multiplication \(AB\) to be defined, the number of columns in \(A\) must be equal to the number of rows in \(B\).
1.1 Compatibility of Dimensions
The key to matrix multiplication is the compatibility of dimensions. If matrix \(A\) has dimensions \(m \times n\) and matrix \(B\) has dimensions \(q \times p\), then the product \(AB\) is defined only if \(n = q\). In this case, the resulting matrix \(C = AB\) will have dimensions \(m \times p\).
Example 1: Compatible Dimensions
If \(A\) is a \(2 \times 3\) matrix and \(B\) is a \(3 \times 4\) matrix:
- Dimensions of \(A\): \(2 \times \textbf{3}\)
- Dimensions of \(B\): \(\textbf{3} \times 4\)
Example 2: Incompatible Dimensions
If \(P\) is a \(2 \times 3\) matrix and \(Q\) is a \(2 \times 2\) matrix:
- Dimensions of \(P\): \(2 \times \textbf{3}\)
- Dimensions of \(Q\): \(\textbf{2} \times 2\)
2) How to Multiply Matrices ⚙️
Matrix multiplication is performed by calculating the "dot product" of rows of the first matrix with columns of the second matrix. Let's break down the process.
2.1 The Dot Product
Before we multiply matrices, let's understand the dot product of two vectors. The dot product of a row vector and a column vector of the same length is calculated by multiplying corresponding entries and then summing up these products.
The dot product of a row vector \( \begin{bmatrix} a_1 & a_2 & \cdots & a_n \end{bmatrix} \) and a column vector \( \begin{bmatrix} b_1 \\ b_2 \\ \vdots \\ b_n \end{bmatrix} \) is: \( a_1b_1 + a_2b_2 + \cdots + a_nb_n \).
Example 3: Dot Product
Let \( u = \begin{bmatrix} 2 & 3 & 4 \end{bmatrix} \) and \( v = \begin{bmatrix} 5 \\ -1 \\ 2 \end{bmatrix} \). Calculate the dot product of \(u\) and \(v\).
Dot product of \(u\) and \(v\) = \( (2 \times 5) + (3 \times -1) + (4 \times 2) = 10 - 3 + 8 = 15 \).
2.2 Steps for Matrix Multiplication
Now, let's use the dot product to multiply matrices \(A\) (of size \(m \times n\)) and \(B\) (of size \(n \times p\)) to get \(C = AB\) (of size \(m \times p\)). The element \(c_{ij}\) in the \(i\)-th row and \(j\)-th column of matrix \(C\) is found by taking the dot product of the \(i\)-th row of matrix \(A\) and the \(j\)-th column of matrix \(B\).
For matrices \(A\) (\(m \times n\)) and \(B\) (\(n \times p\)), the element \(c_{ij}\) of the product \(C = AB\) is given by: \( c_{ij} = a_{i1}b_{1j} + a_{i2}b_{2j} + \cdots + a_{in}b_{nj} = \sum_{k=1}^{n} a_{ik}b_{kj} \).
Example 4: Matrix Multiplication - 2x2 by 2x2
Let \( A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \) and \( B = \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} \). Calculate \(C = AB\).
Matrix \(A\) is \(2 \times 2\) and matrix \(B\) is \(2 \times 2\). The product \(C = AB\) will be a \(2 \times 2\) matrix. Let's find each element of \(C\):
- \(c_{11}\) (1st row, 1st column of \(C\)): Dot product of 1st row of \(A\) and 1st column of \(B\). \( c_{11} = (1 \times 5) + (2 \times 7) = 5 + 14 = 19 \).
- \(c_{12}\) (1st row, 2nd column of \(C\)): Dot product of 1st row of \(A\) and 2nd column of \(B\). \( c_{12} = (1 \times 6) + (2 \times 8) = 6 + 16 = 22 \).
- \(c_{21}\) (2nd row, 1st column of \(C\)): Dot product of 2nd row of \(A\) and 1st column of \(B\). \( c_{21} = (3 \times 5) + (4 \times 7) = 15 + 28 = 43 \).
- \(c_{22}\) (2nd row, 2nd column of \(C\)): Dot product of 2nd row of \(A\) and 2nd column of \(B\). \( c_{22} = (3 \times 6) + (4 \times 8) = 18 + 32 = 50 \).
Thus, \( C = AB = \begin{bmatrix} 19 & 22 \\ 43 & 50 \end{bmatrix} \).
Example 5: Matrix Multiplication - 2x3 by 3x2
Let \( P = \begin{bmatrix} 2 & 0 & -1 \\ 4 & 1 & 3 \end{bmatrix} \) (a \(2 \times 3\) matrix) and \( Q = \begin{bmatrix} 2 & 5 \\ -3 & 1 \\ 0 & -2 \end{bmatrix} \) (a \(3 \times 2\) matrix). Calculate \(R = PQ\).
Since \(P\) is \(2 \times 3\) and \(Q\) is \(3 \times 2\), the product \(R = PQ\) is defined and will be a \(2 \times 2\) matrix.
- \(r_{11}\) = \( (2 \times 2) + (0 \times -3) + (-1 \times 0) = 4 + 0 + 0 = 4 \).
- \(r_{12}\) = \( (2 \times 5) + (0 \times 1) + (-1 \times -2) = 10 + 0 + 2 = 12 \).
- \(r_{21}\) = \( (4 \times 2) + (1 \times -3) + (3 \times 0) = 8 - 3 + 0 = 5 \).
- \(r_{22}\) = \( (4 \times 5) + (1 \times 1) + (3 \times -2) = 20 + 1 - 6 = 15 \).
Therefore, \( R = PQ = \begin{bmatrix} 4 & 12 \\ 5 & 15 \end{bmatrix} \).
Important Note: To get the element in the \(i\)-th row and \(j\)-th column of the product \(AB\), you use the \(i\)-th row of \(A\) and the \(j\)-th column of \(B\). Visualize "moving across the row of \(A\) and down the column of \(B\), multiplying corresponding elements and summing up".
3) Properties of Matrix Multiplication 🔑
Matrix multiplication has several important properties that are different from multiplication of ordinary numbers.
3.1 Non-Commutativity
Matrix multiplication is generally not commutative. That is, in most cases, \(AB \neq BA\).
The order in which you multiply matrices matters significantly. In fact, even if \(AB\) is defined, \(BA\) might not be defined, or if both are defined, they might be of different dimensions, or even if they are of the same dimensions, they are generally not equal.
Example 6: Non-Commutativity
Let \( A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \) and \( B = \begin{bmatrix} 0 & 1 \\ 2 & 0 \end{bmatrix} \). Let's calculate \(AB\) and \(BA\).
\( AB = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \begin{bmatrix} 0 & 1 \\ 2 & 0 \end{bmatrix} = \begin{bmatrix} (1\times 0 + 2\times 2) & (1\times 1 + 2\times 0) \\ (3\times 0 + 4\times 2) & (3\times 1 + 4\times 0) \end{bmatrix} = \begin{bmatrix} 4 & 1 \\ 8 & 3 \end{bmatrix} \)
\( BA = \begin{bmatrix} 0 & 1 \\ 2 & 0 \end{bmatrix} \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} = \begin{bmatrix} (0\times 1 + 1\times 3) & (0\times 2 + 1\times 4) \\ (2\times 1 + 0\times 3) & (2\times 2 + 0\times 4) \end{bmatrix} = \begin{bmatrix} 3 & 4 \\ 2 & 4 \end{bmatrix} \)
Clearly, \( AB = \begin{bmatrix} 4 & 1 \\ 8 & 3 \end{bmatrix} \) and \( BA = \begin{bmatrix} 3 & 4 \\ 2 & 4 \end{bmatrix} \) are not equal, so \(AB \neq BA\).
3.2 Associativity
Matrix multiplication is associative. That is, for matrices \(A\), \(B\), and \(C\) for which the products are defined, \( (AB)C = A(BC) \).
This property means that when you multiply three or more matrices, the way you group them does not change the result, as long as the order of matrices is maintained.
3.3 Distributivity
Matrix multiplication is distributive over matrix addition. That is,
- \( A(B + C) = AB + AC \)
- \( (B + C)A = BA + CA \)
Distributive property allows you to "distribute" a matrix product over a sum of matrices.
3.4 Identity Matrix in Multiplication
The Identity Matrix \(I\) (from Part 1) plays a role similar to '1' in scalar multiplication. For any square matrix \(A\) of size \(n \times n\), and the identity matrix \(I_n\) of the same size:
- \( AI_n = A \)
- \( I_nA = A \)
For an \(n \times n\) Identity Matrix \(I_n\), and any \(n \times n\) matrix \(A\): \( AI_n = I_nA = A \).
Example 7: Identity Matrix Multiplication
Let \( A = \begin{bmatrix} 3 & -2 \\ 1 & 5 \end{bmatrix} \) and \( I_2 = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \). Let's verify \(AI_2 = A\).
\( AI_2 = \begin{bmatrix} 3 & -2 \\ 1 & 5 \end{bmatrix} \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} = \begin{bmatrix} (3\times 1 + -2\times 0) & (3\times 0 + -2\times 1) \\ (1\times 1 + 5\times 0) & (1\times 0 + 5\times 1) \end{bmatrix} = \begin{bmatrix} 3 & -2 \\ 1 & 5 \end{bmatrix} = A \)
Thus, \(AI_2 = A\) is confirmed. Similarly, \(I_2A = A\) would also hold.
4) Scalar Multiplication and Matrix Multiplication 🤝
Scalar multiplication can be combined with matrix multiplication in several ways. For a scalar \(k\) and matrices \(A\) and \(B\) (for which \(AB\) is defined):
- \( (kA)B = k(AB) = A(kB) \)
Example 8: Combining Scalar and Matrix Multiplication
Let \( k = 2 \), \( A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \), and \( B = \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} \). Let's calculate \( (kA)B \) and \( k(AB) \).
Method 1: Calculate \( (kA)B = (2A)B \) first.
\( 2A = 2 \times \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} = \begin{bmatrix} 2 & 4 \\ 6 & 8 \end{bmatrix} \)
\( (2A)B = \begin{bmatrix} 2 & 4 \\ 6 & 8 \end{bmatrix} \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} = \begin{bmatrix} (2\times 5 + 4\times 7) & (2\times 6 + 4\times 8) \\ (6\times 5 + 8\times 7) & (6\times 6 + 8\times 8) \end{bmatrix} = \begin{bmatrix} 38 & 44 \\ 86 & 100 \end{bmatrix} \)
Method 2: Calculate \( k(AB) = 2(AB) \) after finding \(AB\).
From Example 4, we know \( AB = \begin{bmatrix} 19 & 22 \\ 43 & 50 \end{bmatrix} \).
\( 2(AB) = 2 \times \begin{bmatrix} 19 & 22 \\ 43 & 50 \end{bmatrix} = \begin{bmatrix} 38 & 44 \\ 86 & 100 \end{bmatrix} \)
Both methods give the same result: \( (kA)B = k(AB) = \begin{bmatrix} 38 & 44 \\ 86 & 100 \end{bmatrix} \).
5) Practice Questions 🎯
5.1 Fundamental – Build Skills
1. Are matrices \(A = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix}\) and \(B = \begin{bmatrix} 7 & 8 \\ 9 & 10 \\ 11 & 12 \end{bmatrix}\) compatible for multiplication \(AB\)? What are the dimensions of the product if it's defined?
2. For matrices \(A\) and \(B\) from question 1, is the product \(BA\) defined? If yes, what are its dimensions?
3. Calculate the dot product of row vector \(u = \begin{bmatrix} 1 & -2 & 3 \end{bmatrix}\) and column vector \(v = \begin{bmatrix} 4 \\ 0 \\ -1 \end{bmatrix}\).
4. Given \(A = \begin{bmatrix} 2 & 1 \\ 0 & -1 \end{bmatrix}\) and \(B = \begin{bmatrix} 3 & -2 \\ 1 & 4 \end{bmatrix}\), calculate \(AB\).
5. Using \(A\) and \(B\) from question 4, calculate \(BA\). Is \(AB = BA\) in this case?
6. Let \(P = \begin{bmatrix} 1 & 0 & -1 \\ 2 & 1 & 0 \end{bmatrix}\) and \(Q = \begin{bmatrix} 2 & 3 \\ -1 & 1 \\ 0 & -2 \end{bmatrix}\). Calculate \(PQ\).
7. Given matrix \(A = \begin{bmatrix} 3 & 0 \\ 0 & 3 \end{bmatrix}\) and \(I_2 = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\), calculate \(AI_2\) and \(I_2A\).
8. Let \(C = \begin{bmatrix} 4 & -1 \\ 2 & 3 \end{bmatrix}\). Calculate \(C^2 = CC\).
9. If \(A = \begin{bmatrix} 1 & 2 \\ 0 & 1 \end{bmatrix}\) and \(B = \begin{bmatrix} 2 & 0 \\ 1 & 1 \end{bmatrix}\), calculate \(2AB\).
10. Given \(A = \begin{bmatrix} 1 & 1 \\ 1 & 1 \end{bmatrix}\), calculate \(A^2\) and \(A^3 = AAA\).
5.2 Challenging – Push Limits 💪🚀
1. If \(AB = \begin{bmatrix} 7 & 2 \\ 15 & 4 \end{bmatrix}\) and \(B = \begin{bmatrix} 1 & 0 \\ 2 & 1 \end{bmatrix}\), find matrix \(A\).
2. Solve for matrix \(X\): \( X \begin{bmatrix} 2 & 1 \\ 3 & 2 \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\). (Hint: Think about what matrix multiplied by another gives the identity matrix).
3. Let \(A = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}\). Calculate \(A^n\) for a general positive integer \(n\). Look for a pattern in \(A^1, A^2, A^3, \dots\).
4. (Conceptual) Explain why matrix multiplication is defined in terms of dot products of rows and columns. What does this operation represent in terms of linear transformations (if you have some background in that)?
5. (Application) A company produces two products, Product 1 and Product 2, at two factories, Factory A and Factory B. The production cost per unit is given by matrix \(C = \begin{bmatrix} 10 & 12 \\ 15 & 18 \end{bmatrix}\) (rows are factories, columns are products). The number of units produced in a week is given by matrix \(U = \begin{bmatrix} 200 & 250 \\ 300 & 350 \end{bmatrix}\) (rows are factories, columns are products). Use matrix multiplication to find the total production cost for each factory.
6) Summary 🎉
- Matrix Multiplication \(AB\) is defined if the number of columns in \(A\) is equal to the number of rows in \(B\). If \(A\) is \(m \times n\) and \(B\) is \(n \times p\), then \(AB\) is \(m \times p\).
- Calculation: The element in the \(i\)-th row and \(j\)-th column of \(AB\) is the dot product of the \(i\)-th row of \(A\) and the \(j\)-th column of \(B\).
- Properties:
- Non-Commutative: In general, \(AB \neq BA\).
- Associative: \( (AB)C = A(BC) \).
- Distributive: \( A(B + C) = AB + AC \) and \( (B + C)A = BA + CA \).
- Identity Matrix: \( AI = IA = A \).
- Scalar Multiplication: \( (kA)B = k(AB) = A(kB) \).
Excellent work! You have now mastered the basics of matrix multiplication, a key operation in linear algebra. Understanding matrix multiplication opens the door to many advanced topics and applications. Continue to Part 3 (coming soon!) to explore more about matrices and their uses in various fields. Keep practicing, and you will become proficient in matrix operations! 🌟
← Back to Previous Topic (Part 1 - Basic Matrices) Continue to Topic 13 (Basic Matrices Part 3 - Coming Soon!) → View Level 2 Topics Overview →