Matrix Multiplication

Matrix multiplication is an operation where two matrices are multiplied to produce a new matrix. Unlike addition and subtraction, matrix multiplication follows specific rules and is not performed element-wise.

For two matrices \( A \) and \( B \) to be multiplied:

  • The number of columns in the first matrix \( A \) must be equal to the number of rows in the second matrix \( B \).
  • If \( A \) is of size \( m \times n \) and \( B \) is of size \( n \times p \), then their product \( C = A \times B \) will be of size \( m \times p \).
  • The element at position \( C_{ij} \) in the resulting matrix is computed as the dot product of the \( i^{th} \) row of \( A \) and the \( j^{th} \) column of \( B \).

Mathematically, matrix multiplication is expressed as:

\[ C_{ij} = \sum_{k=1}^{n} A_{ik} \cdot B_{kj} \]

Example 1: Multiplying a 2×3 Matrix with a 3×2 Matrix

Consider the following matrices:

\[ A = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix} \]

\[ B = \begin{bmatrix} 7 & 8 \\ 9 & 10 \\ 11 & 12 \end{bmatrix} \]

Matrix \( A \) has 2 rows and 3 columns, and matrix \( B \) has 3 rows and 2 columns. Since the number of columns in \( A \) matches the number of rows in \( B \), we can multiply them.

The result \( C = A \times B \) will be a \( 2 \times 2 \) matrix.

Step 1: Compute \( C_{11} \) (First Row, First Column)

The element \( C_{11} \) is obtained by multiplying the first row of \( A \) with the first column of \( B \) and summing the products:

\[ C_{11} = (1 \times 7) + (2 \times 9) + (3 \times 11) \]

\[ C_{11} = 7 + 18 + 33 = 58 \]

Step 2: Compute \( C_{12} \) (First Row, Second Column)

The element \( C_{12} \) is obtained by multiplying the first row of \( A \) with the second column of \( B \) and summing the products:

\[ C_{12} = (1 \times 8) + (2 \times 10) + (3 \times 12) \]

\[ C_{12} = 8 + 20 + 36 = 64 \]

Step 3: Compute \( C_{21} \) (Second Row, First Column)

The element \( C_{21} \) is obtained by multiplying the second row of \( A \) with the first column of \( B \) and summing the products:

\[ C_{21} = (4 \times 7) + (5 \times 9) + (6 \times 11) \]

\[ C_{21} = 28 + 45 + 66 = 139 \]

Step 4: Compute \( C_{22} \) (Second Row, Second Column)

The element \( C_{22} \) is obtained by multiplying the second row of \( A \) with the second column of \( B \) and summing the products:

\[ C_{22} = (4 \times 8) + (5 \times 10) + (6 \times 12) \]

\[ C_{22} = 32 + 50 + 72 = 154 \]

Final Result

Thus, the product of \( A \) and \( B \) is:

\[ C = \begin{bmatrix} 58 & 64 \\ 139 & 154 \end{bmatrix} \]


Example 2: Multiplication of Two 2×2 Matrices

Consider the two 2×2 matrices:

\[ A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}, \quad B = \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} \]

Since \( A \) is a \( 2 \times 2 \) matrix and \( B \) is also a \( 2 \times 2 \) matrix, their product will be a \( 2 \times 2 \) matrix.

Step 1: Compute \( C_{11} \) (First Row, First Column)

The element \( C_{11} \) is found by taking the dot product of the first row of \( A \) and the first column of \( B \):

\[ C_{11} = (1 \times 5) + (2 \times 7) \]

– Multiply the first element of row 1 of \( A \) by the first element of column 1 of \( B \): \( 1 \times 5 = 5 \)

– Multiply the second element of row 1 of \( A \) by the second element of column 1 of \( B \): \( 2 \times 7 = 14 \)

– Add these values: \( 5 + 14 = 19 \).

Step 2: Compute \( C_{12} \) (First Row, Second Column)

The element \( C_{12} \) is found by taking the dot product of the first row of \( A \) and the second column of \( B \):

\[ C_{12} = (1 \times 6) + (2 \times 8) \]

– Multiply the first element of row 1 of \( A \) by the first element of column 2 of \( B \): \( 1 \times 6 = 6 \)

– Multiply the second element of row 1 of \( A \) by the second element of column 2 of \( B \): \( 2 \times 8 = 16 \)

– Add these values: \( 6 + 16 = 22 \).

Step 3: Compute \( C_{21} \) (Second Row, First Column)

The element \( C_{21} \) is found by taking the dot product of the second row of \( A \) and the first column of \( B \):

\[ C_{21} = (3 \times 5) + (4 \times 7) \]

– Multiply the first element of row 2 of \( A \) by the first element of column 1 of \( B \): \( 3 \times 5 = 15 \)

– Multiply the second element of row 2 of \( A \) by the second element of column 1 of \( B \): \( 4 \times 7 = 28 \)

– Add these values: \( 15 + 28 = 43 \).

Step 4: Compute \( C_{22} \) (Second Row, Second Column)

The element \( C_{22} \) is found by taking the dot product of the second row of \( A \) and the second column of \( B \):

\[ C_{22} = (3 \times 6) + (4 \times 8) \]

– Multiply the first element of row 2 of \( A \) by the first element of column 2 of \( B \): \( 3 \times 6 = 18 \)

– Multiply the second element of row 2 of \( A \) by the second element of column 2 of \( B \): \( 4 \times 8 = 32 \)

– Add these values: \( 18 + 32 = 50 \).

Final Result

The resulting 2×2 matrix is:

\[ C = \begin{bmatrix} 19 & 22 \\ 43 & 50 \end{bmatrix} \]


Example 3: Multiplication of Two 3×3 Matrices

Consider the two 3×3 matrices:

\[ A = \begin{bmatrix} 2 & 3 & 4 \\ 1 & 0 & 5 \\ 7 & 6 & 8 \end{bmatrix}, \quad B = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix} \]

The result \( C = A \times B \) will be a 3×3 matrix. We compute each element as follows:

Step 1: Compute First Row

\[ C_{11} = (2 \times 1) + (3 \times 4) + (4 \times 7) = 2 + 12 + 28 = 42 \]

\[ C_{12} = (2 \times 2) + (3 \times 5) + (4 \times 8) = 4 + 15 + 32 = 51 \]

\[ C_{13} = (2 \times 3) + (3 \times 6) + (4 \times 9) = 6 + 18 + 36 = 60 \]

Step 2: Compute Second Row

\[ C_{21} = (1 \times 1) + (0 \times 4) + (5 \times 7) = 1 + 0 + 35 = 36 \]

\[ C_{22} = (1 \times 2) + (0 \times 5) + (5 \times 8) = 2 + 0 + 40 = 42 \]

\[ C_{23} = (1 \times 3) + (0 \times 6) + (5 \times 9) = 3 + 0 + 45 = 48 \]

Step 3: Compute Third Row

\[ C_{31} = (7 \times 1) + (6 \times 4) + (8 \times 7) = 7 + 24 + 56 = 87 \]

\[ C_{32} = (7 \times 2) + (6 \times 5) + (8 \times 8) = 14 + 30 + 64 = 108 \]

\[ C_{33} = (7 \times 3) + (6 \times 6) + (8 \times 9) = 21 + 36 + 72 = 129 \]

Final Result

The resulting 3×3 matrix is:

\[ C = \begin{bmatrix} 42 & 51 & 60 \\ 36 & 42 & 48 \\ 87 & 108 & 129 \end{bmatrix} \]


Conclusion

Matrix multiplication is a fundamental operation in linear algebra used in various applications such as computer graphics, machine learning, and engineering. The key points to remember are:

  • Matrix multiplication is not commutative (\( A \times B \neq B \times A \) in general).
  • The number of columns in the first matrix must match the number of rows in the second matrix.
  • Each element of the resulting matrix is computed as the dot product of a row from the first matrix and a column from the second matrix.

By following these principles, you can confidently perform matrix multiplication step by step.