Mastering Matrix Multiplication: From Basics to Advanced Techniques
Dive into the world of matrix multiplication! Learn essential rules, master dot product techniques, and explore real-world applications. Perfect for students seeking to excel in linear algebra and beyond.

  1. Intros0/1 watched
  2. Examples0/11 watched
  3. Practice0/16 practiced
  1. 0/1
  2. 0/11
  3. 0/16
Now Playing:Multiplying a matrix by another matrix– Example 0
Intros
0/1 watched
  1. Multiplying a matrix by a matrix overview:
    Dot product
Examples
0/11 watched
  1. Dot product
    Find the dot product of the following ordered nn-tuples:
    1. a=(2,4,6) \vec{a}=(2,4,6) and b=(1,3,5)\vec{b}=(1,3,5)

    2. a=(1,7,5,3) \vec{a}=(1,7,5,3) and b=(2,3,6,1)\vec{b}=(-2,3,6,1)

    3. a=(1,2) \vec{a}=(1,2) and b=(3,5)\vec{b}=(3,5)

    4. a=(7,2,1,4) \vec{a}=(7,-2,-1,4) and b=(1,1,2,2)\vec{b}=(1,1,2,2)

Practice
0/16
Multiplying A Matrix By Another Matrix 1a
Adding and subtracting matrices
Notes
In this lesson, we will learn how to multiply a matrix with another matrix. But we will learn about n-tuples first. An n-tuple is an ordered list of n numbers. Multiplying an n-tuple by another n-tuple is called the dot product. The dot product is the summation of all product of each corresponding entries. To multiply a matrix with another matrix, we have to think of each row and column as a n-tuple. Each entry will be the dot product of the corresponding row of the first matrix and corresponding column of the second matrix. For example, if your entry is at the 3rd row and 4th column, then you have to take the dot product of the 3rd row of the first matrix and 4th column of the second matrix. Note that not all matrices can be multiplied.

Matrix Multiplication

There are exactly two ways of multiplying matrices. The first way is to multiply a matrix with a scalar. This is known as scalar multiplication. The second way is to multiply a matrix with another matrix. That is known as matrix multiplication.

Scalar Multiplication

scalar multiplication is actually a very simple matrix operation. To multiply a scalar with a matrix, we simply take the scalar and multiply it to each entry in the matrix. Let's do an example.

Question 1: Calculate 2A2A if

Equation 1: Scalar Multiplication Example 1 pt.1
Equation 1: Scalar Multiplication Example 1 pt.1

The question is asking us to find out what 2A2A is. In other words, we are finding

Equation 1: Scalar Multiplication Example pt.2
Equation 1: Scalar Multiplication Example 1 pt.2

Notice that if we are to multiply 2 to each entry in the matrix, we get that:

Equation 1: Scalar Multiplication Example 1 pt.3
Equation 1: Scalar Multiplication Example 1 pt.3

Very simple! Let's do another one.

Question 2: Calculate 0A0A if

Equation 2: Scalar Multiplication Example 2 pt.1
Equation 2: Scalar Multiplication Example 2 pt.1

Again, we are trying to find 0A0A. This means that we will be looking for the answer to

Equation 2: Scalar Multiplication Example 2 pt.2
Equation 2: Scalar Multiplication Example 2 pt.2

The matrix will be oddly shaped, but the concept remains the same. We will still multiple the scalar 0 to each entry in the matrix. Doing so gives us:

Equation 2: Scalar Multiplication Example 2 pt.3
Equation 2: Scalar Multiplication Example 2 pt.3

Notice that all the entries in the matrix are 0. This is known as a zero matrix that is 3 x 2.

Now that we are very familiar with scalar multiplication, why don't we move on to matrix multiplication?

How to Multiply Matrices

To multiply a matrix by another matrix, we first need to learn about what dot product is.

What is dot product?

Dot product (also known as vector multiplication) is a way to calculate the product of two vectors. For example, let the two vectors be:

Equation 3: Dot Product Example pt.1
Equation 3: Dot Product Example pt.1

How would I multiply these two vectors? Simply just multiply the corresponding entries, and add the products together. In other words,

Equation 3: Dot Product Example pt.2
Equation 3: Dot Product Example pt.2

So we get a single value from multiplying vectors. However, notice how that the two vectors have the same number of entries.What if one of the vectors has a different number of entries than the other? For example, let

Equation 4: Dot Product Failure Example pt.1
Equation 4: Dot Product Failure Example pt.1

If I were to multiply the corresponding entries and add them up all together, then I get:

Equation 4: Dot Product Failure Example pt.2
Equation 4: Dot Product Failure Example pt.2

There is a problem here. The first three entries have corresponding entries to multiply with, but the last entry doesn't. So what do we do here? The answer is we cannot do anything here. This just means we cannot calculate the dot product of these two vectors.

So in conclusion, we cannot find the dot product of two vectors that have different numbers of entries. They must have the same number of entries.

2 x 2 Matrix Multiplication

So what was the point of learning the dot product? Well, we will be using the dot product when we multiply two matrices together. When multiplying a matrix with another matrix, we want to treat rows and columns as a vector. More specifically, we want to treat each row in the first matrix as vectors, and each column in the second matrix as vectors. Let's do an example.

Question 3: Find ABA \bullet B if

Equation 5: 2 x 2 Matrix Multiplication Example pt.1
Equation 5: 2 x 2 Matrix Multiplication Example pt.1

Multiplying the two matrices will give us:

Equation 5: 2 x 2 Matrix Multiplication Example pt.2
Equation 5: 2 x 2 Matrix Multiplication Example pt.2

Now the rows and the columns we are focusing are

Equation 5: 2 x 2 Matrix Multiplication Example pt.3
Equation 5: 2 x 2 Matrix Multiplication Example pt.3

where r1r_{1} is the first row, r2r_{2} is the second row, and, c1,c2c_{1}, c_{2} are first and second columns. Now we are going to treat each row and column we see here as a vector.

Notice here that multiplying a 2 x 2 matrix with another 2 x 2 matrix gives a 2 x 2 matrix. In other words, the matrix we get should have 4 entries.

Equation 5: 2 x 2 Matrix Multiplication Example pt.4
Equation 5: 2 x 2 Matrix Multiplication Example pt.4

How do we exactly get the first entry? Well, notice that the first entry is located on the first row and first column. So we simply take the dot product of r1r_{1} and c1c_{1}. Thus, the first entry will be

Equation 5: 2 x 2 Matrix Multiplication Example pt.5
Equation 5: 2 x 2 Matrix Multiplication Example pt.5

How do we get the second entry this time? Well, notice that the location of the second entry is in the first row and second column. So we simply take the dot product of r1r_{1} and c2c_{2}. Thus, the second entry will be

Equation 5: 2 x 2 Matrix Multiplication Example pt.6
Equation 5: 2 x 2 Matrix Multiplication Example pt.6/figcaption>

Now we are going to use the same strategy to look for the last two entries. Notice the second last entry is located in the 2nd2^{nd} row and 1st1^{st} column, and the last entry is located in the 2nd2^{nd} row and 2nd2^{nd} column. So we take the dot product of r2r_{2} and c1c_{1}, and the dot product of r2r_{2} and c2c_{2}. This gives us:

Equation 5: 2 x 2 Matrix Multiplication Example pt.7
Equation 5: 2 x 2 Matrix Multiplication Example pt.7

Now we are done! This is what we get when we are multiplying 2 x 2 matrices. In general, the matrix multiplication formula for 2 x 2 matrices is

Formula 1: 2 x 2 Matrix Multiplication Formula
Formula 1: 2 x 2 Matrix Multiplication Formula

3x3 Matrix Multiplication

Now the process of a 3 x 3 matrix multiplication is very similar to the process of a 2 x 2 matrix multiplication. Again, why don't we do a matrix multiplication example?

Question 4:Find ABA \bullet B if

Equation 6: 3 x 3 Matrix Multiplication Example pt.1
Equation 6: 3 x 3 Matrix Multiplication Example pt.1

First, notice that multiplying them should give us another 3 x 3 matrix. In other words,

Equation 6: 3 x 3 Matrix Multiplication Example pt.2
Equation 6: 3 x 3 Matrix Multiplication Example pt.2

Now let's label all our rows in the first matrix and columns in the second matrix.

Equation 6: 3 x 3 Matrix Multiplication Example pt.3
Equation 6: 3 x 3 Matrix Multiplication Example pt.3

Notice that the first entry of the matrix is located in the 1st1^{st} row and 1st1^{st} column, so we take the dot product of r1r_{1} and c1c_{1}. This gives us:

Equation 6: 3 x 3 Matrix Multiplication Example pt.4
Equation 6: 3 x 3 Matrix Multiplication Example pt.4

Now notice that the second entry of the matrix is located in the 1st1^{st} row and 2nd2^{nd} column. Thus, we take the dot product of r1r_{1} and c2c_{2}. This gives us:

Equation 6: 3 x 3 Matrix Multiplication Example pt.5
Equation 6: 3 x 3 Matrix Multiplication Example pt.5

If we are to keep locating all the entries and doing the dot product corresponding to the rows and columns, then we get the final result.

Equation 6: 3 x 3 Matrix Multiplication Example pt.6
Equation 6: 3 x 3 Matrix Multiplication Example pt.6

We are done! Notice that the bigger the matrices are, the more tedious matrix multiplication becomes. This is because we have to deal with more and more numbers! In general, the matrix multiplication formula for 3 x 3 matrices is

Formula 2: 3 x 3 Matrix Multiplication Formula
Formula 2: 3 x 3 Matrix Multiplication Formula

How to Multiply Matrices with Different Dimensions?

So far we have multiplied matrices with the same dimensions. In addition, we know that multiplying two matrices with the same dimension gives a matrix of the same dimensions. But what happens if we multiply a matrix with different dimensions? How would we know the dimensions of the computed matrix? First, we need to see multiplying the matrices gives you a defined matrix.

Is the Matrix Defined?

There are cases where it is not possible to multiply two matrices together. For those cases, we call the matrix to be undefined. How can we tell if they are undefined?

The product of two matrices is only defined if the number of columns in the first matrix is equal to the number of rows of the second matrix.

Let's try to use this definition in this example.

Question 5: Let

Equation 7: Defined Matrix example pt.1
Equation 7: Defined Matrix example pt.1

Is ABA \bullet B defined?

First, notice that the first matrix has 3 columns. Also, the second matrix has 3 rows. Since they are both equal to 3, then I know that ABA \bullet B is defined.

Now that we know it is defined, how would we know the dimensions of ABA \bullet B?

The Dimension Property

To find the dimensions of ABA \bullet B, we need to first look at the dimensions of and separately.

Equation 7: Defined Matrix example pt.2
Equation 7: Defined Matrix example pt.2

Now we are going to put the dimensions of the matrices side by side like this:

Equation 7: Defined Matrix example pt.3
Equation 7: Defined Matrix example pt.3

What we are going to do now is take the first number and the last number and combine it to get the dimensions of ABA \bullet B. See that the first number is 2 and the last number is 4. So the dimensions of ABA \bullet B will be:

Equation 7: Defined Matrix example pt.4
Equation 7: Defined Matrix example pt.4

Now that we know the dimensions of the matrix, we can just compute each entry by using the dot products. This will give us:

Equation 7: Defined Matrix example pt.5
Equation 7: Defined Matrix example pt.5

Now that we know how to multiply matrices very well, why don't take a look at some matrix multiplication rules?

Matrix Multiplication Properties

So what type of properties does matrix multiplication actually have? First, let's formally define everything.

Let X,Y,ZX, Y, Z be matrices, InI_{n} be an identity matrix, and OnO_{n} be a zero matrix. If all five of these matrices have equal dimensions, then we will have the following matrix to matrix multiplication properties:

Formula 3: Matrix Multiplication Properties
Formula 3: Matrix Multiplication Properties

The associative property states that the order in which you multiply does not matter. In other words, computing XYX \bullet Y and then multiply with ZZ would give you the same result as computing YZY \bullet Z and then multiplying with XX. Let's do an example.

Question 6: Show that the associative property works with these matrices:

Equation 8: Associative Property example pt.1
Equation 8: Associative Property example pt.1

Looking at the left side of the equation in the associative property, we see that (XY)Z(XY)Z gives:

Equation 8: Associative Property example pt.2
Equation 8: Associative Property example pt.2

Now looking at the right side of the equation in the associative property, we see that X(YZ)X(YZ) gives:

Equation 8: Associative Property example pt.3
Equation 8: Associative Property example pt.3

See how the left side and right side of the equation are both equal. Hence, we know that the associative property actually works! Again, this means that matrix multiplication order does not matter!

Now the next property is the distributive property. The distributive property states that:

Formula 4: Distributive Property
Formula 4: Distributive Property

We see that we are allowed to use the foil technique for matrices as well. Just to show that this property works, let's do an example.

Question 7: Show that the distributive property works for the following matrices:

Equation 9: Distributive Property example pt.1
Equation 9: Distributive Property example pt.1

See that the left hand side of the equation is X(Y+Z)X(Y + Z). Hence computing that gives us:

Equation 9: Distributive Property example pt.2
Equation 9: Distributive Property example pt.2

Now let's check if the right hand side of the equation gives us the exact same thing. Notice that the right hand side of the equation is XY+XZXY + XZ. Computing this gives us:

Equation 9: Distributive Property example pt.3
Equation 9: Distributive Property example pt.3

Notice that the left hand side of the equation is exactly the same as the right hand side of the equation. Hence, we can confirm that the distributive property actually works.

Is Matrix Multiplication Commutative?

We know that matrix multiplication satisfies both associative and distributive properties, however we did not talk about the commutative property at all. Does that mean matrix multiplication does not satisfy it? It actually does not, and we can check it with an example.

Question 8: If matrix multiplication is commutative, then the following must be true:

Equation 10: Failure of Commutative Property pt.1
Equation 10: Failure of Commutative Property pt.1

Show that XYeqYXXY eq YX if

Equation 10: Failure of Commutative Property pt.2
Equation 10: Failure of Commutative Property pt.2

First we compute the left hand side of the equation. Calculating XYXY gives us:

Equation 10: Failure of Commutative Property pt.3
Equation 10: Failure of Commutative Property pt.3

Now computing the right hand side of the equation, we have:

Equation 10: Failure of Commutative Property pt.4
Equation 10: Failure of Commutative Property pt.4

As you can see,

Equation 10: Failure of Commutative Property pt.5
Equation 10: Failure of Commutative Property pt.5

Because we have

Equation 10: Failure of Commutative Property pt.6
Equation 10: Failure of Commutative Property pt.6

These two matrices are completely different.

Now there are still a few more properties of the multiplication of matrices. However, these properties deal with the zero and identity matrices.

Matrix Multiplication for the Zero Matrix

The matrix multiplication property for the zero matrix states the following:

Formula 5: Matrix Multiplication for Zero Matrix
Formula 5: Matrix Multiplication for Zero Matrix

where OO is a zero matrix.

This is means that if you were to multiply a zero matrix with another non-zero matrix, then you will get a zero matrix. Let's test if this is true with an example.

Question 9: Show that the equation OX=OOX = O and XO=OXO = O holds if:

Equation 11: Matrix Multiplication for Zero Matrix example pt.1
Equation 11: Matrix Multiplication for Zero Matrix example pt.1

Let's first look at the equation

Equation 11: Matrix Multiplication for Zero Matrix example pt.2
Equation 11: Matrix Multiplication for Zero Matrix example pt.2

Notice that calculating OXOX gives us:

Equation 11: Matrix Multiplication for Zero Matrix example pt.3
Equation 11: Matrix Multiplication for Zero Matrix example pt.3

We do see that OX=OOX = O, so the equation holds. Similarly, if we calculate XOXO, we get:

Equation 11: Matrix Multiplication for Zero Matrix example pt.4
Equation 11: Matrix Multiplication for Zero Matrix example pt.4

We do see that the equation XO=OXO = O holds, so we are done.

Matrix Multiplication for the Identity Matrix

Now what about the matrix multiplication property for identity matrices? Well, the property states the following:

Formula 6: Matrix Multiplication for Identity Matrix
Formula 6: Matrix Multiplication for Identity Matrix

where InI_{n} is an n×nn \times n identity matrix. Again, we can see that the following equations do hold with an example.

Question 10: Show that the equations XI2=XX I_{2} = X and I2X=XI_{2} X = X holds with the following matrices

Equation 12: Matrix Multiplication for identity matrix example pt.1
Equation 12: Matrix Multiplication for identity matrix example pt.1

So for the equation XI2=XX I_{2} = X, we have:

Equation 12: Matrix Multiplication for identity matrix example pt.2
Equation 12: Matrix Multiplication for identity matrix example pt.2

So the equation does hold. Similar to the equation I2X=XI_{2}X = X, we have:

Equation 12: Matrix Multiplication for identity matrix example pt.3
Equation 12: Matrix Multiplication for identity matrix example pt.3

Again, the equation holds. So we are done with the question, and both equations hold. This concludes all the properties of matrix multiplication. Now if you want to look at a real life application of matrix multiplication, then I recommend you look at this article.

https://www.mathsisfun.com/algebra/matrix-multiplying.html

In this section we will learn how to multiply two matrices like A \cdot B together.

A nn-tuple is an ordered list of nn numbers. For example,
(1,2,3,4) is an ordered quadruple with 4 numbers, and (1,2,3) is an ordered triple with 3 numbers. We usually specify each ordered nn-tuple as a variable with an arrow on top. For example,

x=(1,2,3,4)\vec{x}=(1,2,3,4)

If we have 2 ordered nn-tuples, then we can find the dot product. The dot product is summation of all the product of each corresponding entries. For example, let

a=(1,2,3)\vec{a}=(1,2,3) and b=(2,2,2)\vec{b}=(2,2,2).

If we do the dot product of a\vec{a} and b\vec{b} and ,then we will get the following:

ab=(1,2,3)(2,2,2)\vec{a}\cdot\vec{b}=(1,2,3)\cdot(2,2,2)
=12+22+32=1\cdot2+2\cdot2+3\cdot2
=2+4+6=2+4+6
=12=12

When we want to multiply a matrix by a matrix, we want to think of each row and column as a nn-tuple. To be exact, we want to focus on the rows of the first matrix and focus on columns of the second matrix. For example,

Matrix multiplication explained

For example, r1\vec{r_1}is the first row of the matrix with an ordered triple (1,2,3). Now to multiply these two matrices, we need to use the dot product of r1\vec{r_1} to each column, dot product of r2\vec{r_2} to each column, and r3\vec{r_3} to each column. In other words

Matrix multiplication explained