If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Intro to matrix multiplication

Sal explains what it means to multiply two matrices, and gives an example. Created by Sal Khan.

Want to join the conversation?

Video transcript

Voiceover:Let's say that we have got 2 matrices, and I'll just, for simplicity, I'll start with two 2 by 2 matrices. Let's say that this first one right over here is 2, negative 2, 5, and let's say 5 and 3, and then I have this matrix right over here that it's also going to be 2 by 2. Let's say it's negative 1, 4, and let's say 7 and negative 6. What I want to go through in this video, what I want to introduce you to is the convention, the mathematical convention for multiplying two matrices like these. I want to stress that because mathematicians could have come up with a bunch of different ways to define matrix multiplication. But the convention that I'm going to show you is the way that it is done, and it's done this way especially as you go into deeper linear algebra classes or you start doing computer graphics or even modeling different types of phenomena, you'll see why this type of matrix multiplication, which I'm about to show you, why it has the most applications. But I really want to stress this is a human construct. Humans have found defining matrix multiplication the way I'm about to show you to be useful. Let's just think about how this could be. Once again, I want to stress it's a human construct. There's several ways that you could have thought about multiplying two 2 by 2 matrices. You could have done it the same way that you add matrices. When you add matrices, both matrices have to have the same dimensions, and you just add the corresponding entries in the matrices. One convention could have been why don't we just, for our product right over here, why don't we just multiply corresponding entries? 2 times negative 1 would put a negative 2 here. Negative 2 times 4, put a negative 8 here. That's how we did addition. We added corresponding entries, but that is not the convention for multiplying matrices. That is not the standard convention. The standard convention for multiplying matrices is we're essentially going to take ... To get this top left entry right over here, we're going to take the product of this row, of that row with this column right over here. Now what does it mean to take the product of a row and a column? If you are familiar with vector dot products, this might ring a bell, where you take the product of the corresponding terms, the product of the first terms, products of the second terms, and then add those together. That's essentially what we're going to be doing. We're going to be taking the dot product of this first row and this first column to get this top left entry right over here. If the word "dot product" makes no sense to you, I will show you what that actually means. Actually, let's get some more real estate here just so I think it will be useful, especially this very first time that we attempt to multiply matrices. This top left entry, it's going to be 2 times negative 1, so 2 times negative 1, plus negative 2, plus negative 2 times 7, plus negative 2 times 7. Notice, I took the product, first entry in the row, first entry in the column, those two products, then the product of second entry in the row, second entry in the column that's right over there, and then I added them together. That's essentially taking the dot product of this row vector and this column vector. If that doesn't make sense to you, if you're not familiar with vectors and dot products, don't worry about it. We just took the first end product of the first entry, product of the second entry, added them together to get ... This is going to give us some number, and we'll calculate that in a few seconds. But let's think about the other ones. To get this, to get this entry right over here, we're going to take the first row from this matrix and the second column from this matrix. That makes sense because we're still in the first row but we're in the second column of the first row right here. First row, second column. It's going to be 2 times 4, 2 times 4 plus negative 2, plus negative 2 times negative 6. At this point, I encourage you to pause the video. Seeing what you just saw, see if you could complete this. See if you can figure out the bottom left entry and the bottom right entry. I'll give you a clue. It has something to do with this second row here. I'm assuming you've given a go at it. Now let's just power through it together. Sometimes matrix multiplication can get a little bit intense. We're now in the second row, so we're going to use the second row of this first matrix, and for this entry, second row, first column, second row, first column. 5 times negative 1, 5 times negative 1 plus 3 times 7, plus 3 times 7. Then finally, we're in the home stretch now, to get this bottom row second column, or second row, second column, we multiply this row essentially by this column right over here. It is going to be 5 times 4, 5 times 4 plus 3 times negative 6, plus 3 times negative 6. Now what does all of this simplify to? This is going to be equal to, let's see, so negative 2 plus negative 14, that's going to be negative 16. That, right over there, is negative 16. Then we have 8 plus 12, so that's going to be 20. Then we have negative 5 plus 21, which is going to be 16, positive 16. Did I do that right? Yup, positive 16. Then finally, you're going to have 20 minus 18, so that's just going to be 2. The product of these 2 matrices, we deserve a little bit of a drum roll at this point, when we multiply this 2 by 2 matrix times this 2 by 2 matrix, we are going to get negative 16, 20, 20, 16, and 16 and 2, and we are done.