Explainer: Matrix Multiplication

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

The multiplication of matrices can be divided into two categories: scalar multiplication and matrix multiplication. Scalar multiplication involves multiplying a matrix by a scalar (or a number). For example, given the matrix 𝐴=2132, if we wanted to find 2𝐴, this would be considered a scalar multiplication. To find 2𝐴, we would multiply each of the components of the matrix by 2: 2𝐴=2×22×12×32×2=4264.

Matrix multiplication is somewhat more difficult, and there are particular criteria that need to be adhered to. Firstly, the dimensions of matrices need to be considered.

A matrix is often referred to in terms of its number of rows and columns. For example, a matrix with 𝑚 rows and 𝑛 columns is said to be an 𝑚×𝑛 matrix. Two matrices can only be multiplied if the number of columns in the first matrix is equal to the number of rows in the second matrix.

More generally, if a matrix multiplication exists between two matrices 𝐴 and 𝐵 and the dimensions of 𝐴 are 𝑚×𝑛, then the dimensions of 𝐵 must be 𝑛×𝑝. A useful note is that the dimensions of the resultant multiplication of these two matrices would be 𝑚×𝑝. This is demonstrated in the picture below.

As we now know how to establish if a matrix multiplication exists, let us look at how to calculate this multiplication. We will demonstrate how to do this using an example. Consider a 1×2 matrix 𝐴=[31] and a 2×1 matrix 𝐵=41; then, the product 𝐴𝐵 must exist and will have dimensions 1×1. How to complete this multiplication is demonstrated as follows:

If you are familiar with how to calculate the dot product, you may notice that this multiplication is very similar to finding the dot product of the vectors a=3,1 and b=4,1. In fact, the dot product can be defined as a matrix multiplication for these two vectors if we consider the transpose of b, notated bT. The product 𝑎𝑏T would then be the same as the product 𝐴𝐵 shown above.

Let us now look at how we would multiply a 3×2 matrix by a 2×3 matrix. We know that the multiplication exists as the number of columns of the first matrix matches the number of rows of the second matrix. We also know that the resulting matrix will be a 3×3 matrix. As before, we need to multiply the rows and columns, but we now need to consider the position of each of the entries in the resulting matrix. For example, if we multiply the top row of the first matrix by the left-hand column of the second matrix, the result will be the top-left entry. The bottom row multiplied by the middle column would result in the bottom-middle entry. These steps are outlined by multiplying the following matrices: 𝐴=242144,𝐵=512316.

First, we consider the top row and the left column:

Then, we consider the top row and the middle column:

This process continues until we have completed the matrix multiplication:

Let us look at another example.

Example 1: Multiplying Matrices

Consider the shown matrices 𝐴 and 𝐵: 𝐴=1124477,𝐵=896489.

Find 𝐴𝐵, if possible.

Answer

We know that the multiplication exists as the number of columns of the first matrix matches the number of rows of the second matrix. We also know that the resulting matrix will be a 3×3 matrix. First, we consider the top row of 𝐴 and the first column of 𝐵 in order to calculate the top-left entry of the result. Then, we consider the top row of 𝐴 and the middle column of 𝐵 to find the top-middle entry, and we continue this process until we have populated the whole matrix: 1124477896489=11×8+2×411×9+2×811×6+2×94×8+4×44×9+4×84×6+4×97×8+7×47×9+7×87×6+7×9=8011548166812847105.

It is worth noting at this point that matrix multiplication is not commutative. That means, in general, given two matrices 𝐴 and 𝐵, 𝐴𝐵𝐵𝐴. This can easily be seen in example 3. The product 𝐴𝐵 would be a 3×3 matrix, but the product 𝐵𝐴 would be a 2×2 matrix. We can also find powers of matrices providing the product exists. Let us demonstrate this with another example.

Example 2: Finding the Square of a Matrix

Given that 𝐴=6155, find 𝐴2.

Answer

Remember that 𝐴2 means 𝐴𝐴. We multiply matrices by considering each of the rows and columns: 61556155=6×6+1×56×1+1×55×6+5×55×1+5×5=311520.

If we wanted to find 𝐴3, we would then multiply this result by 𝐴 on the right-hand side.

Before finishing, let us look at one final example.

Example 3: Multiplying Matrices

Given that 𝐴=371341and𝐵=643, find 𝐴𝐵 if possible.

Answer

First, let us establish if the multiplication is possible. The first matrix has dimensions 2×3 and the second matrix has dimensions 3×1. Therefore, as the number of columns of the first matrix is the same as the number of rows of the second matrix, the product exists and the resulting matrix will have dimensions 2×1. It is always worth doing this check to avoid making mistakes. We then need to multiply the matrices: 371341643=3×6+7×4+1×33×6+4×4+1×3=75.

In the last couple of examples, we will use matrix multiplication to find unknown entries in matrices which are part of a product.

Example 4: Finding Unknowns in Matrix Equations

Find the values of 𝑥 and 𝑦 given the following: 132120𝑥𝑦=8923.

Answer

First, we inspect the entry in the first row and first column of the rightmost matrix: 132120𝑥𝑦=8923.

This gives the equation 1×2+3×𝑥=8, which yields 𝑥=2. Now that we know the value of 𝑥, we substitute it into the original equation: 1321202𝑦=8923.

We will now be able to find 𝑦 by examining the entry in the first row and second column of the rightmost matrix: 1321202𝑦=8923.

We must then solve 1×0+3×𝑦=9, which gives 𝑦=3. The final matrix equation is, therefore, 13212023=8923.

We could also check that the values of 𝑥 and 𝑦 are correct by calculating the two remaining entries in the second row of the rightmost matrix. Doing this will confirm that our values of 𝑥 and 𝑦 are correct.

Example 5: Solving Matrix Equations with Unknowns on Both Sides

Find the values of 𝑥 and 𝑦 that solve 20𝑥3103121140𝑥1=6111104𝑦.

Answer

We begin by taking the rightmost matrix and looking at the entry in the first row and the first column. We also appropriately highlight the relevant entries from the two matrices on the left-hand side of the equation: 20𝑥3103121140𝑥1=6111104𝑦.

The rules of matrix multiplication imply that 2×3+0×(1)+𝑥×0=6. Essentially, all this equation confirms is that 6=6, which is encouraging, even if slightly unhelpful.

Continuing, we now consider the entry in the first row and second column of the rightmost matrix: 20𝑥3103121140𝑥1=6111104𝑦.

This gives 2×1+0×(1)+𝑥×𝑥=11, which implies that 𝑥2+2=11 or alternatively that 𝑥=±3. This means that 𝑥 has two possible values.

Next, we look at the entry in the first row and third column of the rightmost matrix: 20𝑥3103121140𝑥1=6111104𝑦.

This gives 2×2+0×(4)+𝑥×1=1, which implies that 4+𝑥=1 and hence 𝑥=3. The subsequent matrix equation is 203310312114031=6111104𝑦.

Now that we have found 𝑥, we only need to find 𝑦. This variable appears only once, in the second row and third column of the rightmost matrix: 203310312114031=6111104𝑦.

This gives (3)×2+1×(4)+0×1=𝑦, which gives 𝑦=10.

Key Points

  1. Suppose that 𝐴 is a matrix with order 𝑚×𝑛 and that 𝐵 is a matrix with order 𝑛×𝑝 such that 𝐴=𝑎11𝑎12𝑎1𝑛𝑎21𝑎22𝑎2𝑛𝑎𝑚1𝑎𝑚2𝑎𝑚𝑛,𝐵=𝑏11𝑏12𝑏1𝑝𝑏21𝑏22𝑏2𝑝𝑏𝑛1𝑏𝑛2𝑏𝑛𝑝. Then, the matrix multiplication 𝐶=𝐴𝐵 is a matrix with order 𝑚×𝑝, hence having the following form: 𝐶=𝐴𝐵=𝑐11𝑐12𝑐1𝑝𝑐21𝑐22𝑐2𝑝𝑐𝑚1𝑐𝑚2𝑐𝑚𝑝. The entries 𝑐𝑖𝑗 are calculated by the pairwise summation of entries from 𝐴 and 𝐵 as shown: 𝑐𝑖𝑗=𝑛𝑘=1𝑎𝑖𝑘𝑏𝑘𝑗=𝑎𝑖1𝑏1𝑗++𝑎𝑖𝑛𝑏𝑛𝑗.
  2. In general, matrix multiplication is not commutative; that is, in general, for two matrices 𝐴 and 𝐵, 𝐴𝐵𝐵𝐴.

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