Lesson Explainer: Matrix Multiplication Mathematics

In this explainer, we will learn how to identify the conditions for matrix multiplication and evaluate the product of two matrices if possible.

Let us begin by recalling scalar multiplication, which is much simpler than matrix multiplication. Scalar multiplication involves multiplying a matrix by a scalar (or a number). For example, consider the matrix ๐ด=๏€ผ2132๏ˆ

If we wanted to multiply this matrix by a scalar 2, we would multiply each of the components of the matrix by 2: 2ร—๐ด=๏€ผ2ร—22ร—12ร—32ร—2๏ˆ=๏€ผ4264๏ˆ.

We can see that multiplying a matrix by a scalar is simple. However, it is much more complicated to multiply a matrix by another matrix. Before we can discuss how to multiply a matrix by another matrix, we need to understand when it is possible to multiply a pair of matrices.

Recall that the order of a matrix is given by ()ร—().numberofrowsnumberofcolumns

For instance, a matrix with ๐‘š rows and ๐‘› columns is said to be an ๐‘šร—๐‘› matrix. In order to multiply a pair of matrices, their orders must be compatible.

Rule: Criterion for Matrix Multiplication

Let ๐ด and ๐ต be matrices. To compute matrix multiplication ๐ดร—๐ต, the number of columns in ๐ด must equal the number of rows in ๐ต. If ๐ด is an ๐‘šร—๐‘› matrix for some positive integers ๐‘š and ๐‘›, ๐ต must be an ๐‘›ร—๐‘ matrix for some positive integer ๐‘. In this case, ๐ดร—๐ต is an ๐‘šร—๐‘ matrix.

From this criterion for matrix multiplication, we can see that ๐ดร—๐ต is not the same as ๐ตร—๐ด for matrices ๐ด and ๐ต. In fact, it is possible for one of these to be defined while the other is not. For instance, say that matrices ๐ด and ๐ต are of order 1ร—2 and 2ร—3 respectively. Then, the number of columns of ๐ด is equal to the number of rows of ๐ต, which means that the matrix multiplication ๐ดร—๐ต is defined. On the other hand, the number of columns of ๐ต is not equal to the number of rows of ๐ด. This means that the matrix multiplication ๐ตร—๐ด is not defined. This tells us that matrix multiplication is not commutative, which means that the order of matrices in matrix multiplication cannot be changed.

In the first example, we will find the order of a matrix resulting from matrix multiplication.

Example 1: Order of Matrices in Matrix Multiplication

If ๐ด is a matrix of order 2ร—3 and ๐ต๏Œณ is a matrix of order 1ร—3, then matrix ๐ด๐ต is of order .

  1. 3ร—1
  2. 2ร—1
  3. 1ร—2
  4. 3ร—2

Answer

Recall that the number of columns in matrix ๐ด must be equal to the number of rows in matrix ๐ต to compute matrix multiplication ๐ดร—๐ต. We also recall that the order of a matrix is given by ()ร—().numberofrowsnumberofcolumns

Since the order of matrix ๐ด is 2ร—3, this tells us that the number of columns in matrix ๐ด is 3. The order of ๐ต๏Œณ is 1ร—3, which means that matrix ๐ต๏Œณ has 1 row and 3 columns. ๐ต๏Œณ is the transpose of ๐ต, and we know that the transpose of a matrix changes the rows of the matrix to columns of its transpose. Since the transpose of ๐ต has 1 row and 3 columns, matrix ๐ต must have 3 rows and 1 column. This tells us that the number of columns in matrix ๐ด and the number of rows in matrix ๐ต are both equal to 3, which means that matrix multiplication is valid.

Recall that the multiplication of a matrix of order ๐‘šร—๐‘› by a matrix of order ๐‘›ร—๐‘ results in a matrix of order ๐‘šร—๐‘. In this example, we are multiplying a 2ร—3 matrix by a 3ร—1 matrix. This means ๐‘šร—๐‘›=2ร—3,๐‘›ร—๐‘=3ร—1.

Hence, ๐‘š=2, ๐‘›=3, and ๐‘=1. The order of matrix ๐ด๐ต is ๐‘šร—๐‘=2ร—1. This is option B.

In the next example, we will find the order of a matrix being multiplied, based on the order of the product matrix as well as the order of the other matrix.

Example 2: Order of Matrices in Matrix Multiplication

If matrix ๐ด is of order 3ร—1 and matrix ๐ด๐ต is of order 3ร—2, then matrix ๐ต is of order .

  1. 2ร—3
  2. 3ร—2
  3. 2ร—1
  4. 1ร—2

Answer

Recall that the number of columns in matrix ๐ด must be equal to the number of rows in matrix ๐ต to compute matrix multiplication ๐ดร—๐ต. We also recall that the order of a matrix is given by ()ร—().numberofrowsnumberofcolumns

Since the order of matrix ๐ด is 3ร—1, this tells us that the number of columns in matrix ๐ด is 1. This number must equal the number of rows in matrix ๐ต. Hence, the number of rows in matrix ๐ต must be equal to 1.

We also recall that the number of rows in matrix ๐ด๐ต is equal to the number of rows in matrix ๐ด, and likewise the number of columns in ๐ด๐ต is equal to the number of columns in matrix ๐ต. We are given that matrix ๐ด is of order 3ร—1 and matrix ๐ด๐ต is of order 3ร—2, and we can see that the numbers of rows in matrices ๐ด and ๐ด๐ต are the same. Since matrix ๐ด๐ต has 2 columns, this tells us that the number of columns in ๐ต must be equal to 2.

Hence, matrix ๐ต is of order 1ร—2. This is option D.

In the next example, we will check the criterion for matrix multiplication to determine whether the given matrix multiplication is well defined.

Example 3: Finding the Product of Two Given Matrices

Given that ๐ด=๏€ผ512โˆ’3โˆ’4โˆ’3๏ˆ,๐ต=๏€ผ1โˆ’25โˆ’4๏ˆ, determine ๐ด๐ต if possible.

Answer

Recall that the number of columns in matrix ๐ด must equal the number of rows in matrix ๐ต to compute matrix multiplication ๐ดร—๐ต. We also recall that the order of a matrix is given by ()ร—().numberofrowsnumberofcolumns

We can see that matrix ๐ด has 2 rows and 3 columns and matrix ๐ต has 2 rows and 2 columns. Since the number of columns in ๐ด is not equal to the number of rows in matrix ๐ต, the matrix multiplication ๐ด๐ต is undefined.

In the previous examples, we considered the property of the order of matrices in matrix multiplication. Now that we know when a pair of matrices can be multiplied, let us consider how to multiply matrices. The simplest matrix multiplication is the multiplication of a row matrix by a column matrix.

How To: Multiplying Row Matrices by Column Matrices

Let ๐ด and ๐ต be row and column matrices respectively. Then, matrix ๐ด๐ต is well defined and is of order 1ร—1. The entry of this matrix is obtained by multiplying each entry in the row matrix by the corresponding entry in the column matrix and then summing all the products.

We will demonstrate this process in the next example.

Example 4: Finding the Product of Two Given Matrices

Consider the matrices ๐ด=(12โˆ’7),๐ต=๏€โˆ’46โˆ’2๏Œ.

Find ๐ด๐ต, if possible.

Answer

We know that matrix multiplication is only possible if the number of columns of the first matrix matches the number of rows of the second matrix. We note that the number of columns of the first matrix ๐ด and the number of rows of the second matrix ๐ต are both equal to 3, so it is possible to compute matrix multiplication ๐ด๐ต.

We also know that the multiplication of an ๐‘šร—๐‘› matrix by an ๐‘›ร—๐‘ matrix results in an ๐‘šร—๐‘ matrix. We can see that the orders of matrices ๐ด and ๐ต are 1ร—3 and 3ร—1 respectively. Hence, ๐‘š=1, ๐‘›=3, and ๐‘=1. This tells us that matrix ๐ด๐ต is of order ๐‘šร—๐‘=1ร—1.

Since matrix ๐ด has only one row, it is a row matrix. Likewise, matrix ๐ต is a column matrix. Recall that we can multiply a row matrix by a column matrix by multiplying each entry in matrix ๐ด by the corresponding entry in the column of ๐ต and summing all the products. In the following computation, we have highlighted the corresponding entries in each matrix with the same color: ๐ด๐ต=(12โˆ’7)๏€โˆ’46โˆ’2๏Œ=(1ร—(โˆ’4)+2ร—6+(โˆ’7)ร—(โˆ’2))=(โˆ’4+12+14)=[22].

We can see that the order of ๐ด๐ต is 1ร—1, as expected.

Hence, ๐ด๐ต=[22].

In the previous example, we multiplied a row matrix by a column matrix, which resulted in a matrix with a single entry, by multiplying the ๐‘—th entry of the row matrix by the ๐‘—th entry of the column matrix and summing all the products. The resulting matrix had only one entry because the first matrix in matrix multiplication had one row and the second matrix had one column.

This process can be generalized to multiply any pair of matrices with compatible orders, where the resulting matrix may have multiple entries. To multiply a matrix with multiple rows by a matrix with multiple columns, we need to pick one row from the first matrix and one column from the second matrix. Treating the selected row and column as row and column matrices, respectively, we can multiply the row matrix and the column matrix using the method introduced earlier. We continue this process until each of the rows of the first matrix is multiplied by each of the columns of the second matrix.

How To: Multiplying Matrices

Let ๐ด and ๐ต be matrices of orders ๐‘šร—๐‘› and ๐‘›ร—๐‘ respectively. For each ๐‘–=1,2,โ€ฆ,๐‘š and ๐‘—=1,2,โ€ฆ,๐‘, we can compute the entry in the ๐‘–th row and ๐‘—th column of matrix ๐ด๐ต by multiplying the ๐‘–th row of ๐ด by the ๐‘—th column of ๐ต.

We know that if we multiply a matrix of order ๐‘šร—๐‘› by a matrix of order ๐‘›ร—๐‘, we obtain a matrix of order ๐‘šร—๐‘. This means that we need to compute this ๐‘šร—๐‘ times to complete the matrix multiplication.

Let us demonstrate this process graphically by multiplying a 3ร—2 matrix by a 2ร—3 matrix. We know that the resulting matrix will be of order 3ร—3, which means that we need to multiply a row by a column 9 times. Consider the following matrices: ๐ด=๏€2โˆ’42โˆ’144๏Œ,๐ต=๏€ผ5โˆ’1โˆ’2316๏ˆ.

We can see that matrix ๐ด has 2 columns and matrix ๐ต has 2 rows. Hence, we can compute the product ๐ด๐ต. We also know that the product will be of order 3ร—3. First, we can multiply the first row by the first column to find the entry in the first row and first column of matrix ๐ด๐ต:

Next, we multiply the first row of ๐ด by the second column of ๐ต to obtain

This process continues until we have completed the matrix multiplication:

Example 5: Finding the Product of Two Given Matrices

Given that ๐ด=๏€ผโˆ’3โˆ’7โˆ’1341๏ˆ,๐ต=๏€6โˆ’43๏Œ, find ๐ด๐ต if possible.

Answer

We know that matrix multiplication is only possible if the number of columns of the first matrix matches the number of rows of the second matrix. We note that the number of columns of the first matrix ๐ด and the number of rows of the second matrix ๐ต are both equal to 3, so it is possible to compute matrix multiplication ๐ด๐ต.

We also know that the multiplication of an ๐‘šร—๐‘› matrix by an ๐‘›ร—๐‘ matrix results in an ๐‘šร—๐‘ matrix. We can see that the orders of matrices ๐ด and ๐ต are 2ร—3 and 3ร—1 respectively. Hence, ๐‘š=2, ๐‘›=3, and ๐‘=1. This tells us that matrix ๐ด๐ต is of order ๐‘šร—๐‘=2ร—1. We need to compute the entries of this matrix.

Recall that the entry in the ๐‘–th row and ๐‘—th column of matrix ๐ด๐ต is obtained by multiplying the ๐‘–th row of ๐ด by the ๐‘—th column of ๐ต. We begin by taking the first row of ๐ด, which can be written as a column matrix (โˆ’3โˆ’7โˆ’1). We also take the first (and only) column of ๐ต, which can be written as the column matrix ๏€6โˆ’43๏Œ. Multiplying each entry in the row matrix by the corresponding entry in the column matrix and then summing all the products, (โˆ’3โˆ’7โˆ’1)๏€6โˆ’43๏Œ=[โˆ’3ร—6+(โˆ’7)ร—(โˆ’4)+(โˆ’1)ร—3]=[7].

Since this is the product of the first row of ๐ด and the first column of ๐ต, this tells us that 7 is the entry in the first row and first column of matrix ๐ด๐ต.

Next, we multiply the second row of ๐ด, (341), by the first column of ๐ต, ๏€6โˆ’43๏Œ, which leads to (341)๏€6โˆ’43๏Œ=[3ร—6+4ร—(โˆ’4)+1ร—3]=[5].

Hence, 5 is the entry in the second row and first column of matrix ๐ด๐ต. This leads to ๐ด๐ต=๏€ผ75๏ˆ.

In the previous example, we multiplied a pair of matrices that had compatible orders. We did this by taking the row submatrices of the first matrix and the column submatrices of the second matrix and then multiplying them together. While this is the correct process for multiplying two matrices, it is not efficient to write out the row and column matrices each time. Instead, we can abbreviate these computations by writing the product of the corresponding row and column matrices within each entry of the resulting matrix, as seen in the following formula.

Definition: Matrix Multiplication

Let ๐ด and ๐ต be matrices of orders ๐‘šร—๐‘› and ๐‘›ร—๐‘, respectively, given by ๐ด=โŽ›โŽœโŽœโŽ๐‘Ž๐‘Žโ‹ฏ๐‘Ž๐‘Ž๐‘Žโ‹ฏ๐‘Žโ‹ฎโ‹ฎโ‹ฑโ‹ฎ๐‘Ž๐‘Žโ‹ฏ๐‘ŽโŽžโŽŸโŽŸโŽ ,๐ต=โŽ›โŽœโŽœโŽœโŽ๐‘๐‘โ‹ฏ๐‘๐‘๐‘โ‹ฏ๐‘โ‹ฎโ‹ฎโ‹ฑโ‹ฎ๐‘๐‘โ€ฆ๐‘โŽžโŽŸโŽŸโŽŸโŽ .๏Šง๏Šง๏Šง๏Šจ๏Šง๏Š๏Šจ๏Šง๏Šจ๏Šจ๏Šจ๏Š๏‰๏Šง๏‰๏Šจ๏‰๏Š๏Šง๏Šง๏Šง๏Šจ๏Šง๏Œ๏Šจ๏Šง๏Šจ๏Šจ๏Šจ๏Œ๏Š๏Šง๏Š๏Šจ๏Š๏Œ

Then, the product matrix ๐ด๐ต has order ๐‘šร—๐‘ and is given by ๐ด๐ต=โŽ›โŽœโŽœโŽ๐‘๐‘โ‹ฏ๐‘๐‘๐‘โ‹ฏ๐‘โ‹ฎโ‹ฎโ‹ฑโ‹ฎ๐‘๐‘โ‹ฏ๐‘โŽžโŽŸโŽŸโŽ ,๏Šง๏Šง๏Šง๏Šจ๏Šง๏Œ๏Šจ๏Šง๏Šจ๏Šจ๏Šจ๏Œ๏‰๏Šง๏‰๏Šจ๏‰๏Œ where ๐‘=๏„š๐‘Ž๐‘=๐‘Ž๐‘+โ‹ฏ+๐‘Ž๐‘.๏ƒ๏…๏Š๏‡๏Šฒ๏Šง๏ƒ๏‡๏‡๏…๏ƒ๏Šง๏Šง๏…๏ƒ๏Š๏Š๏…

In the next example, we will multiply a pair of matrices using this formula.

Example 6: Finding the Product of Two Given Matrices

Consider the matrices ๐ด=๏€11โˆ’2โˆ’4477๏Œ,๐ต=๏€ผโˆ’8โˆ’96โˆ’489๏ˆ.

Find ๐ด๐ต, if possible.

Answer

We know that matrix multiplication is only possible if the number of columns of the first matrix matches the number of rows of the second matrix. We note that the number of columns of the first matrix ๐ด and the number of rows of the second matrix ๐ต are both equal to 2, so it is possible to compute matrix multiplication ๐ด๐ต.

We also know that the multiplication of an ๐‘šร—๐‘› matrix by an ๐‘›ร—๐‘ matrix results in an ๐‘šร—๐‘ matrix. We can see that the orders of matrices ๐ด and ๐ต are 3ร—2 and 2ร—3 respectively. Hence, ๐‘š=3, ๐‘›=2, and ๐‘=3. This tells us that matrix ๐ด๐ต is of order ๐‘šร—๐‘=3ร—3. We need to compute 9 entries of this matrix.

Recall that the entry in the ๐‘–th row and ๐‘—th column of matrix ๐ด๐ต is obtained by multiplying each entry of the ๐‘–th row of ๐ด by the corresponding entry of the ๐‘—th column of ๐ต and then summing all the products.

For instance, to obtain the entry in the first row and first column of matrix ๐ด๐ต, we need to multiply the first row matrix of ๐ด, (11โˆ’2), by the first column matrix of ๐ต, ๏€ผโˆ’8โˆ’4๏ˆ. This means that we multiply each entry in the row matrix by the corresponding entry in the column matrix and then sum all the products. This gives 11ร—(โˆ’8)+(โˆ’2)ร—(โˆ’4)=โˆ’80.

Hence, the entry in the first row and first column of matrix ๐ด๐ต is โˆ’80. We can continue in the same manner until we complete the 3ร—3 matrix: ๏€11โˆ’2โˆ’4477๏Œ๏€ผโˆ’8โˆ’96โˆ’489๏ˆ=๏ƒ11ร—(โˆ’8)+(โˆ’2)ร—(โˆ’4)11ร—(โˆ’9)+(โˆ’2)ร—811ร—6+(โˆ’2)ร—9(โˆ’4)ร—(โˆ’8)+4ร—(โˆ’4)(โˆ’4)ร—(โˆ’9)+4ร—8(โˆ’4)ร—6+4ร—97ร—(โˆ’8)+7ร—(โˆ’4)7ร—(โˆ’9)+7ร—87ร—6+7ร—9๏=๏€โˆ’80โˆ’11548166812โˆ’84โˆ’7105๏Œ.

In this explainer, we discussed how to multiply two matrices of compatible orders. We note that matrix multiplication is quite different from the multiplication of two real numbers as it has a more complex structure. While it is hard to see why we need to define matrix multiplication in this manner, there is a good reason for doing this. This reason will become clearer as we learn about more advanced topics on matrices. However, we can see a glimpse of this reason when we consider a real-world example that can be solved using matrix multiplication.

In our final example, we will consider a real-world application of matrix multiplication.

Example 7: SolvingWord Problems by Applying Operations on Matrices

The table below shows the number of different types of rooms in three hotels owned by a company. If a single room costs 160 LE per night, a double room costs 430 LE per night, and a suite costs 740 LE per night, determine the companyโ€™s daily income when all the rooms are occupied.

HotelSingle RoomDouble RoomSuite
First Hotel457415
Second Hotel487419
Third Hotel499410

Answer

In this example, we need to determine the companyโ€™s daily income when all the rooms are occupied. This company owns three hotels, and the number of rooms of each type is listed in the given table. If we take only the numbers in the table, we can form a 3ร—3 matrix, which we can write as ๏€457415487419499410๏Œ.

The first column of this matrix represents the number of single rooms in each hotel. To compute the companyโ€™s income from these rooms, we need to multiply these numbers by 160 LE, which is the cost of a single room. Similarly, we need to multiply the second column by 430 LE, which is the cost of a double room. In the same manner, the entries in the third column should be multiplied by 740 LE, which is the cost of a suite. In the end, we can obtain the total daily income by summing all the entries of the resulting matrix: ๏45ร—16074ร—43015ร—74048ร—16074ร—43019ร—74049ร—16094ร—43010ร—740๏.

If we sum the entries in each row, we obtain

๏45ร—160+74ร—430+15ร—74048ร—160+74ร—430+19ร—74049ร—160+94ร—430+10ร—740๏.(1)

The entry in each row of the matrix above tells us the daily income from each hotel. We can finish the computation by finding each entry above and adding up the entries. But let us pause here for a second to note that the matrix above can also be obtained when we multiply our original 3ร—3 matrix by the column matrix containing the cost of each room type: ๏€457415487419499410๏Œ๏€160430740๏Œ.

Let us consider this multiplication. We know that matrix multiplication is only possible if the number of columns of the first matrix matches the number of rows of the second matrix. We note that the number of columns of the first matrix and the number of rows of the second matrix are both equal to 3, so it is possible to compute this matrix multiplication.

We also know that we can multiply a pair of matrices by multiplying each row of the first matrix by each column of the second matrix. Let us multiply the first row of the 3ร—3 matrix, (457415), by the column of the second matrix, ๏€160430740๏Œ. This means that we multiply each entry in the row matrix by the corresponding entry in the column matrix and then sum all the products. This gives 45ร—160+74ร—430+15ร—740, which is the same as the first row of the matrix given in (1). Similarly, we can see that multiplying the second and third rows of the 3ร—3 matrix by the column matrix leads to the entries in the second and third rows of the matrix in (1). Computing each entry in (1) gives us ๏€457415487419499410๏Œ๏€160430740๏Œ=๏€501205356055660๏Œ.

Adding up all the entries, we have 50120+53560+55660=159340.

Hence, when all the rooms are occupied, the companyโ€™s daily income is 159โ€Žโ€‰โ€Ž340 LE.

Let us finish by recapping a few important concepts from this explainer.

Key Points

  • Let ๐ด and ๐ต be matrices. To compute matrix multiplication ๐ดร—๐ต, the number of columns in ๐ด must be equal to the number of rows in ๐ต. If ๐ด is an ๐‘šร—๐‘› matrix for some positive integers ๐‘š and ๐‘›, ๐ต must be an ๐‘›ร—๐‘ matrix for some positive integer ๐‘. In this case, ๐ดร—๐ต is an ๐‘šร—๐‘ matrix:
  • Let ๐ด and ๐ต be row and column matrices respectively. Then, matrix ๐ด๐ต is well defined and is of order 1ร—1. The entry of this matrix is obtained by multiplying each entry in the row matrix by the corresponding entry in the column matrix and then summing all the products.
  • Let ๐ด and ๐ต be matrices of orders ๐‘šร—๐‘› and ๐‘›ร—๐‘, respectively, given by ๐ด=โŽ›โŽœโŽœโŽ๐‘Ž๐‘Žโ‹ฏ๐‘Ž๐‘Ž๐‘Žโ‹ฏ๐‘Žโ‹ฎโ‹ฎโ‹ฑโ‹ฎ๐‘Ž๐‘Žโ‹ฏ๐‘ŽโŽžโŽŸโŽŸโŽ ,๐ต=โŽ›โŽœโŽœโŽœโŽ๐‘๐‘โ‹ฏ๐‘๐‘๐‘โ‹ฏ๐‘โ‹ฎโ‹ฎโ‹ฑโ‹ฎ๐‘๐‘โ€ฆ๐‘โŽžโŽŸโŽŸโŽŸโŽ .๏Šง๏Šง๏Šง๏Šจ๏Šง๏Š๏Šจ๏Šง๏Šจ๏Šจ๏Šจ๏Š๏‰๏Šง๏‰๏Šจ๏‰๏Š๏Šง๏Šง๏Šง๏Šจ๏Šง๏Œ๏Šจ๏Šง๏Šจ๏Šจ๏Šจ๏Œ๏Š๏Šง๏Š๏Šจ๏Š๏Œ Then, the product matrix ๐ด๐ต has order ๐‘šร—๐‘ and is given by ๐ด๐ต=โŽ›โŽœโŽœโŽ๐‘๐‘โ‹ฏ๐‘๐‘๐‘โ‹ฏ๐‘โ‹ฎโ‹ฎโ‹ฑโ‹ฎ๐‘๐‘โ‹ฏ๐‘โŽžโŽŸโŽŸโŽ ,๏Šง๏Šง๏Šง๏Šจ๏Šง๏Œ๏Šจ๏Šง๏Šจ๏Šจ๏Šจ๏Œ๏‰๏Šง๏‰๏Šจ๏‰๏Œ where ๐‘=๏„š๐‘Ž๐‘=๐‘Ž๐‘+โ‹ฏ+๐‘Ž๐‘.๏ƒ๏…๏Š๏‡๏Šฒ๏Šง๏ƒ๏‡๏‡๏…๏ƒ๏Šง๏Šง๏…๏ƒ๏Š๏Š๏…

Nagwa uses cookies to ensure you get the best experience on our website. Learn more about our Privacy Policy.