Main content

## Algebra (all content)

### Course: Algebra (all content) > Unit 20

Lesson 8: Multiplying matrices by matrices# 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?

- How do you multiply two matrix with different dimensions?(33 votes)
- If you want to visualize it, check out this site: http://matrixmultiplication.xyz/(26 votes)

- At1:30he says we might have thought that we could do it just as addition but we multiply matrices in a different way.Why?Why can't we just multiply each like addition?(9 votes)
- 5 years late :) But just in case someone looks at this question. What Suraj P is suggesting is called the Hadamard product (https://en.wikipedia.org/wiki/Hadamard_product_(matrices). The reason why normal matrix product is defined as it is follows by thinking about matrice as a transformation. I.e. multiplying x by matrix A transforms it to Ax.(9 votes)

- Where can I find a video on powers of a matrix, like how to solve [A]^8?

Is there a video on the Cayley-Hamilton method?(11 votes) - What is the intuition behind defining matrix multiplication this way?(6 votes)
- Matrix multiplication is defined in such a way that it will be practically useful. This method is the most useful, hence it was adopted. You will see its applications in finding solutions of equations, among many others. That is the main concept for which matrix multiplication was developed.(9 votes)

- What is the real world meaning of multiplying matrices?(9 votes)
- Electronics networks, airplane and spacecraft, and in chemical engineering all require perfectly calibrated computations which are obtained from matrix transformations and multiplication(1 vote)

- My question is quite a bit more complex than what we are discussing right here...
`How to you graph a matrix? And is it possible to find a matrix from a graph?`

(3 votes)- A graph represents a single function, from x onto y. A matrix holds a lot more information than that. Matrices perform transformations on the entire space they act upon, so I'm not particularly sure what you mean by graphing a matrix.(9 votes)

- Whats the use of this in real life?, and for what purpose is the learning of this?

(No offense)(2 votes) - So when multiplying matrices the product matrix size will come out as the smallest row size by the smallest column size?(3 votes)
- Not necessarily. To multiply matrices they need to be in a certain order. If you had matrix 1 with dimensions axb and matrix 2 with cxd then it depends on what order you multiply them. Kind of like subtraction where 2-3 = -1 but 3-2=1, it changes the answer.

So if you did matrix 1 times matrix 2 then b must equal c in dimensions.

so if one matrix had dimensions 2x3 and the second had 3x5 you could multiply matrix 1 by matrix 2, but not atri 2 by matrix 1

if matrix 1 had dmensions 1x6 and matrix 2 had 2x1 you could only multiply matrix 2 by matrix 1.

The only matrices you can swap the order of is square matrices

Then, when you multiply matrices the dimensions of the matrix product is the left over dimensions.

so if you did matrix 1 times matrix 2, and matrix 1 was an axb matrix and matrix 2 was a bxc matrix, the new matrix would have dimensions axc

Let me know if that did not help though.

a 2x3 multiplied by a 3x5 matrix would have a product with 2x5(4 votes)

- Is this multiplication convention somehow connected to that matrices seem, in a way, 2 dimensional, when compared to the regular (1 dimensional, linear) equations? Is this resembling a calculation of [Length]*[Width]? Got that idea when Sal mentioned matrices are used extensively in the graphics territory.(3 votes)
- I'm not sure I follow the line of thought with matrices being 2 dimensional. Matrix arithmetic is actually based in vector arithmetic, though vectors are kinda matrices with just one column. I'm not sure how familiar you are with vectors, but you can think of them as a line segment in space, then multiplying by certain matrices actually transforms it just like adusting a function would. so f(x)+1 moves a function up one, there is a matrix you would multiply a vector by t do the same thing.

Now, if you did multiple transformations you would multiply each matrix together, and in the end multiply this new matrix made by multiplying all the others by the vector and it would have all the transformations happen to that vector.

Let me know if that doesn't make sense and I can try explaining another way.(3 votes)

- How would you multiply 3x3 matrices?(3 votes)
- Multiply the first row's entries of the first matrix by the first column's entries, add it together, and repeat for all 9 places(2 votes)

## 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.