How to Multiply Matrices: A Comprehensive Guide

Matrices are fundamental tools in mathematics, computer science, and many other fields. Understanding how to perform operations with matrices, especially matrix multiplication, is crucial. This guide will break down the process of multiplying matrices in a clear and easy-to-understand way, ensuring you grasp not just the how, but also the why behind each step.

Scalar Multiplication: Multiplying a Matrix by a Number

Let’s start with the basics. Multiplying a matrix by a single number, known as a scalar, is straightforward. You simply multiply each element within the matrix by that scalar.

For example, if we have a matrix:

[ 2  0 ]
[ 1 -9 ]

And we want to multiply it by the scalar 2, we perform the following operation:

This results in:

[ 2×2  2×0 ]   =   [ 4  0 ]
[ 2×1  2×-9]       [ 2 -18]

Scalar multiplication is a simple operation where every element in the matrix is scaled by the same factor. This is a foundational concept before we move on to matrix-matrix multiplication.

Matrix by Matrix Multiplication: The Dot Product

Multiplying a matrix by another matrix is a bit more involved than scalar multiplication. It requires understanding the concept of the “dot product”. Instead of simply multiplying corresponding elements, we use a row-column combination with the dot product at its core.

To multiply two matrices, we take the dot product of the rows of the first matrix and the columns of the second matrix. Let’s illustrate this with an example.

Suppose we want to multiply matrix A by matrix B to get matrix C.

Matrix A:

[ 1  2  3 ]
[ 4  5  6 ]

Matrix B:

[ 7  8 ]
[ 9  10]
[ 11 12]

To find the element in the 1st row and 1st column of the resulting matrix C, we take the dot product of the 1st row of A and the 1st column of B:

Dot Product Calculation (1st row of A and 1st column of B):

(1, 2, 3) • (7, 9, 11) = (1×7) + (2×9) + (3×11) = 7 + 18 + 33 = 58

Explanation of calculating the first element in matrix multiplication using the dot product of the first row of the first matrix and the first column of the second matrix.

So, the element in the 1st row and 1st column of C is 58.

Now, let’s find the element in the 1st row and 2nd column of C. We take the dot product of the 1st row of A and the 2nd column of B:

Dot Product Calculation (1st row of A and 2nd column of B):

(1, 2, 3) • (8, 10, 12) = (1×8) + (2×10) + (3×12) = 8 + 20 + 36 = 64

Similarly, for the 2nd row and 1st column of C:

Dot Product Calculation (2nd row of A and 1st column of B):

(4, 5, 6) • (7, 9, 11) = (4×7) + (5×9) + (6×11) = 28 + 45 + 66 = 139

And for the 2nd row and 2nd column of C:

Dot Product Calculation (2nd row of A and 2nd column of B):

(4, 5, 6) • (8, 10, 12) = (4×8) + (5×10) + (6×12) = 32 + 50 + 72 = 154

Putting it all together, the resulting matrix C is:

[ 58  64 ]
[ 139 154]

This step-by-step approach highlights how each element in the product matrix is calculated using the dot product of corresponding rows and columns from the original matrices.

Why This Method? A Real-World Example

Matrix multiplication might seem like an abstract mathematical operation, but it’s designed to solve real-world problems effectively. Let’s consider a practical example to understand why matrix multiplication works the way it does.

Imagine a local bakery that sells three types of pies: apple, cherry, and blueberry.

  • Apple pies cost $3 each.
  • Cherry pies cost $4 each.
  • Blueberry pies cost $2 each.

Let’s say we want to calculate the total sales value for each day of the week based on the number of pies sold each day. Here’s a table showing the number of pies sold over four days:

Sales data for apple, cherry, and blueberry pies over four days, illustrating a real-world application of matrix multiplication.

To find the total sales value for Monday, we need to calculate:

(Value of Apple pie sales) + (Value of Cherry pie sales) + (Value of Blueberry pie sales)

= ($3 × 13) + ($4 × 8) + ($2 × 6) = $39 + $32 + $12 = $83

This calculation is, in fact, the dot product of the price vector and the sales quantities for Monday:

(Price per pie) • (Pies sold on Monday) = ($3, $4, $2) • (13, 8, 6) = $83

We match each price to the quantity sold, multiply them, and then sum the results. Doing this for each day:

  • Monday: ($3 × 13) + ($4 × 8) + ($2 × 6) = $83
  • Tuesday: ($3 × 9) + ($4 × 7) + ($2 × 4) = $63
  • Wednesday: ($3 × 7) + ($4 × 4) + ($2 × 0) = $37
  • Thursday: ($3 × 15) + ($4 × 6) + ($2 × 3) = $75

We can represent the prices as a 1×3 matrix and the quantities sold each day as a 3×4 matrix. Multiplying these matrices will give us a 1×4 matrix representing the total sales for each day.

The resulting matrix of total sales is:

[ $83  $63  $37  $75 ]

This example demonstrates why the dot product is used in matrix multiplication – it allows us to perform these types of aggregate calculations efficiently, which are common in various applications from economics to computer graphics.

Matrix Dimensions: Rows and Columns are Key

When multiplying matrices, the dimensions are crucial. We describe a matrix by the number of rows and columns it has, written as rows × columns.

For example, a matrix with 2 rows and 3 columns is a 2×3 matrix:

Example of a 2×3 matrix, illustrating the concept of rows and columns in matrix dimensions.

For matrix multiplication to be possible, a specific condition regarding dimensions must be met:

  • The number of columns in the first matrix must be equal to the number of rows in the second matrix.

If matrix A is an m×n matrix and matrix B is an n×p matrix, then their product A×B is possible, and the resulting matrix will be of dimension m×p. The inner dimensions (n and n) must match, and the outer dimensions (m and p) determine the size of the product.

Visual representation of matrix dimension compatibility for multiplication, showing how inner dimensions must match and outer dimensions determine the product matrix size.

Example:

Multiplying a 1×3 matrix by a 3×4 matrix is possible (the inner dimension ‘3’ matches), and the result will be a 1×4 matrix.

However, multiplying a 3×4 matrix by a 1×3 matrix is not possible because the number of columns in the first matrix (4) does not equal the number of rows in the second matrix (1).

Let’s consider the difference between multiplying a 1×3 by a 3×1 and a 3×1 by a 1×3.

1×3 multiplied by 3×1:

[ 1  2  3 ]  x  [ 4 ]  =  [ (1×4) + (2×5) + (3×6) ] = [ 32 ]
                     [ 5 ]
                     [ 6 ]

Result is a 1×1 matrix (a scalar).

3×1 multiplied by 1×3:

[ 4 ]  x  [ 1  2  3 ]  =  [ 4×1  4×2  4×3 ]  =  [ 4  8  12 ]
[ 5 ]                   [ 5×1  5×2  5×3 ]      [ 5  10 15 ]
[ 6 ]                   [ 6×1  6×2  6×3 ]      [ 6  12 18 ]

Result is a 3×3 matrix.

This clearly shows how the order and dimensions affect the outcome of matrix multiplication.

The Identity Matrix: The “1” of Matrices

The Identity Matrix is a special square matrix that acts like the number “1” in matrix multiplication. Denoted by I, it’s a square matrix (same number of rows and columns) with 1s on the main diagonal (from top-left to bottom-right) and 0s everywhere else.

A 3×3 Identity Matrix looks like this:

[ 1  0  0 ]
[ 0  1  0 ]
[ 0  0  1 ]

The key property of the Identity Matrix is that when you multiply any matrix A by the Identity Matrix I (in either order, as long as dimensions allow), the original matrix A remains unchanged:

A × I = A

I × A = A

The Identity Matrix is essential in linear algebra, especially when dealing with inverses of matrices and solving systems of linear equations.

Order of Multiplication Matters: Non-Commutative Property

In regular arithmetic, multiplication is commutative, meaning the order doesn’t change the result (e.g., 3 × 5 = 5 × 3). However, matrix multiplication is generally not commutative.

In most cases:

A × B ≠ B × A

Changing the order of multiplication usually leads to a different result, or might even make the multiplication undefined due to dimension mismatches.

Example:

Let’s see how changing the order affects the product of two matrices:

Matrix X:

[ 1  2 ]
[ 3  4 ]

Matrix Y:

[ 2  0 ]
[ 1  2 ]

X × Y:

[ 1  2 ]   x   [ 2  0 ]   =   [ (1×2)+(2×1)   (1×0)+(2×2) ]   =   [ 4  4 ]
[ 3  4 ]       [ 1  2 ]       [ (3×2)+(4×1)   (3×0)+(4×2) ]       [ 10 8 ]

Y × X:

[ 2  0 ]   x   [ 1  2 ]   =   [ (2×1)+(0×3)   (2×2)+(0×4) ]   =   [ 2  4 ]
[ 1  2 ]       [ 3  4 ]       [ (1×1)+(2×3)   (1×2)+(2×4) ]       [ 7  10]

As you can see, X × Y is not equal to Y × X. This non-commutative property is a fundamental aspect of matrix multiplication and must always be considered.

While there are special cases where A × B = B × A (like when one of the matrices is the Identity Matrix), in general, the order of matrix multiplication is critical and affects the outcome.

Understanding How To Multiply Matrices is a building block for more advanced topics in linear algebra and its applications. By mastering scalar multiplication, matrix-matrix multiplication using the dot product, and being mindful of matrix dimensions and the non-commutative property, you’ll be well-equipped to use matrices effectively in various mathematical and computational contexts.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *