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×n and B is of size n×p, then their product C=A×B will be of size m×p.
  • The element at position Cij in the resulting matrix is computed as the dot product of the ith row of A and the jth column of B.

Mathematically, matrix multiplication is expressed as:

Cij=k=1nAikBkj

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

Consider the following matrices:

A=[123456]

B=[789101112]

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×B will be a 2×2 matrix.

Step 1: Compute C11 (First Row, First Column)

The element C11 is obtained by multiplying the first row of A with the first column of B and summing the products:

C11=(1×7)+(2×9)+(3×11)

C11=7+18+33=58

Step 2: Compute C12 (First Row, Second Column)

The element C12 is obtained by multiplying the first row of A with the second column of B and summing the products:

C12=(1×8)+(2×10)+(3×12)

C12=8+20+36=64

Step 3: Compute C21 (Second Row, First Column)

The element C21 is obtained by multiplying the second row of A with the first column of B and summing the products:

C21=(4×7)+(5×9)+(6×11)

C21=28+45+66=139

Step 4: Compute C22 (Second Row, Second Column)

The element C22 is obtained by multiplying the second row of A with the second column of B and summing the products:

C22=(4×8)+(5×10)+(6×12)

C22=32+50+72=154

Final Result

Thus, the product of A and B is:

C=[5864139154]


Example 2: Multiplication of Two 2×2 Matrices

Consider the two 2×2 matrices:

A=[1234],B=[5678]

Since A is a 2×2 matrix and B is also a 2×2 matrix, their product will be a 2×2 matrix.

Step 1: Compute C11 (First Row, First Column)

The element C11 is found by taking the dot product of the first row of A and the first column of B:

C11=(1×5)+(2×7)

– Multiply the first element of row 1 of A by the first element of column 1 of B: 1×5=5

– Multiply the second element of row 1 of A by the second element of column 1 of B: 2×7=14

– Add these values: 5+14=19.

Step 2: Compute C12 (First Row, Second Column)

The element C12 is found by taking the dot product of the first row of A and the second column of B:

C12=(1×6)+(2×8)

– Multiply the first element of row 1 of A by the first element of column 2 of B: 1×6=6

– Multiply the second element of row 1 of A by the second element of column 2 of B: 2×8=16

– Add these values: 6+16=22.

Step 3: Compute C21 (Second Row, First Column)

The element C21 is found by taking the dot product of the second row of A and the first column of B:

C21=(3×5)+(4×7)

– Multiply the first element of row 2 of A by the first element of column 1 of B: 3×5=15

– Multiply the second element of row 2 of A by the second element of column 1 of B: 4×7=28

– Add these values: 15+28=43.

Step 4: Compute C22 (Second Row, Second Column)

The element C22 is found by taking the dot product of the second row of A and the second column of B:

C22=(3×6)+(4×8)

– Multiply the first element of row 2 of A by the first element of column 2 of B: 3×6=18

– Multiply the second element of row 2 of A by the second element of column 2 of B: 4×8=32

– Add these values: 18+32=50.

Final Result

The resulting 2×2 matrix is:

C=[19224350]


Example 3: Multiplication of Two 3×3 Matrices

Consider the two 3×3 matrices:

A=[234105768],B=[123456789]

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

Step 1: Compute First Row

C11=(2×1)+(3×4)+(4×7)=2+12+28=42

C12=(2×2)+(3×5)+(4×8)=4+15+32=51

C13=(2×3)+(3×6)+(4×9)=6+18+36=60

Step 2: Compute Second Row

C21=(1×1)+(0×4)+(5×7)=1+0+35=36

C22=(1×2)+(0×5)+(5×8)=2+0+40=42

C23=(1×3)+(0×6)+(5×9)=3+0+45=48

Step 3: Compute Third Row

C31=(7×1)+(6×4)+(8×7)=7+24+56=87

C32=(7×2)+(6×5)+(8×8)=14+30+64=108

C33=(7×3)+(6×6)+(8×9)=21+36+72=129

Final Result

The resulting 3×3 matrix is:

C=[42516036424887108129]


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×BB×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.