## Subtitles section Play video

• [inaudible] -- topic. I've been talking --

• I've been multiplying matrices already, but certainly time for me

• to discuss the rules for matrix multiplication.

• And the interesting part is the many ways you can do it,

• and they all give the same answer. So it's -- and they're

• all important. So matrix multiplication,

• and then, come inverses. So we're --

• we -- mentioned the inverse of a matrix, but there's --

• that's a big deal. Lots to do about inverses

• and how to find them. Okay, so I'll begin with how to

• multiply two matrices. First way,

• okay, so suppose I have a matrix A multiplying a matrix B and --

• giving me a result -- well, I could call it C.

• A times B. Okay. So, l- let me just review the

• rule for w- for this entry. That's the entry in

• row I and column J. So that's the I J entry.

• Right there is C I J. We always write the row number and

• then the column number. So I might --

• I might -- maybe I take it C three four, just to make it specific.

• So instead of I J, let me use numbers. C three four.

• So where does that come from, the three four entry?

• It comes from row three, here, row three and column four,

• as you know. Column four.

• And can I just write down, or can we write down the formula for

• it? C three four is --

• if we look at the whole row and the whole

• column, the quick way for me to say it is row three of A --

• I could use a dot for dot product. I won't often use that,

• actually. S- dot column four of B.

• And -- but this gives us a chance to just, like, use a little

• matrix notation. What are the entries?

• What's this first entry in row three?

• The first -- the first -- that number that's

• sitting right there is A,

• so it's got two indices and what are they? [Class response,

• inaudible] Three one. So there's an A three one there.

• Now what's the first guy at the top of column four? [Class

• response, inaudible] So what's sitting up there?

• [Class response, inaudible] B one four, right.

• So that this dot product starts with A three one times B one four.

• And then what's the next -- so this is like I-

• I'm accumulating this sum, then comes the next guy, A three two,

• second column, times B two four, second row.

• So it's B A three two, B two four and so on.

• Just practice with indices. Oh, let -- let me even practice with

• a summation formula. So this is --

• I -- I -- most of the course, I use whole vectors.

• I very seldom, get down to the details of these

• particular entries, but here we'd better do it.

• So I'm -- it's some kind of a sright?

• Of things in row three, column K shall I say?

• Times things in row K, column four. Do you see that that's what's --

• that's what we're seeing here? This is K is one,

• here K is two, on along -- so up --

• so the sum goes all the way along the row and down the column,

• say, one to N. So that's what the A --

• the C three four entry looks like. A sum of A three K B K four.

• Just takes a little practice to do that.

• Okay. And, uh -- oh, well,

• maybe I should say -- when are we allowed to multiply

• these matrices? What are the shapes of these things?

• The shapes are, uh -- if we allow them to be not

• necessarily square matrices. If they're square,

• they've got to be the same size. If they're rectangular, they're

• not the same size. If they're rectangular,

• this might be -- well, I always think of A as M by N.

• M rows, N columns. So that sum goes to N.

• Now what's the point -- how many rows does B have to have?

• [Class response, inaudible] N. N.

• The number of rows in B, the number of guys that we meet

• coming down has to match the number of ones across.

• So B will have to be N by something. Whatever. P.

• So then -- the number of columns here has to match the number of rows

• there, and then what's the result? What's the shape of the result?

• What's the shape of C, the output? Well, it's got these same M rows,

• or -- it's got M rows. And how many columns?

• [Class response, inaudible] P. M by P. Okay.

• So there are M times P little numbers in there,

• entries, and each one, looks like that.

• Okay. So that's the standard rule. That's the way people think of

• multiplying matrices. I do it too.

• But that's -- that's -- I want to talk about other

• ways to look at that same calculation,

• looking at whole columns and whole rows.

• Okay. So can I do A B C again? A B equaling C again?

• But now, tell me s- tell me about, yeah.

• Let me -- I'll put it up here. So here goes A, again,

• times B producing C. And again,

• this is M by N. This is N by P and this is M by P.

• Okay. Now I want to look

• at whole columns. I want to look at the columns of --

• here -- in fact - here's the second way to multiply matrices.

• Because I'm going to build on what I know already.

• How do I multiply a matrix by a column?

• How do I -- I know how to multiply this matrix

• by that column. Th- th- shall I call

• that column one? That tells me column

• one of the answer. The matrix times the first column is

• that first column. Because none of this stuff entered

• that part of the answer. The matrix times the second column

• is the second column of the answer. Do you see what I'm saying?

• That I could think of multiplying a matrix by a vector,

• which I already knew how to do, and I can think of

• the vec- I can think of just P columns sitting side by side,

• just like resting next to each other.

• And I multiply A times each one of those.

• And I get the P columns of the answer.

• Do you see this as -- this is quite nice, to be able to

• think, okay, matrix multiplication works so

• that I can just think of having several columns,

• multiplying by A and getting the columns of the answer.

• So, like, here's column one -- a -- shall I call that --

• here's a -- shall I call that column one?

• And what's going in there is A times column one.

• Okay. So that's the picture a column at a time.

• So what does that tell me? What does that tell me

• about these columns? These columns of C are combinations,

• because we've seen that before, of columns of A.

• Every one of these comes from A times this,

• and A times a vector is a combination of the columns of A.

• And -- right -- and it makes sense,

• because the columns of A have length M and the columns of

• C have length M. And every column of C is a --

• is some combination of the columns of A.

• And it's these numbers in here that tell me what combination it is.

• Do you see that? That out --

• that in that answer, C, I'm seeing stuff that's col-

• that's combinations of these columns.

• Now, suppose I look at it -- that's two ways now.

• The third way is look at it by rows. So now let me change to rows. Okay.

• So now I can think of a row of A -- a row of A multiplying all these

• rows here and producing a row of the product.

• So this row takes a combination of these rows and that's the answer.

• So these rows of C are combinations of what?

• Of -- tell me how to finish that. The rows of C,

• when I have a matrix B, it's got it's rows and I multiply by

• A, and what does that do? It mixes the rows up.

• It makes -- it creates combinations of the rows

• of -- [student response, inaudible] -- B, thanks.

• Rows of B. That's what I wanted to see,

• that this -- that this answer -- I can see where the pieces are

• coming from. The rows in the answer are coming as

• combinations of these rows. The columns in the answer are com-

• coming as combinations of those columns.

• And now that's -- so that's three ways.

• Now you can say, okay, what's the fourth way?

• The fourth way -- so that's -- now we've got,

• like, the regular way, the column way, the row way and -- what's left?

• The -- the one that I can -- I -- I want to tell you about --

• well, one way is columns times rows. What happens if I multiply --

• so th- this was row times column, it gave a number.

• Okay. Now I want to ask you about column times row.

• What does -- if I multiply a column of A times a

• row of B, what shape am I ending up with?

• So if I take a column times a row, that's definitely different from

• taking a row times a column. So a column of A was --

• what -- what's the shape of a column of A?

• N by one. A column of A is a column.

• It's got M entries and one column. And what's a row of B?

• It's got one row and P columns. So what's the shape --

• what do I get if I multiply a column by a row?

• I get a big matrix. I get a full-sized matrix.

• If I multiply a column by a row, I get -- should we just do one?

• Let me take the column two three four times the row one six.

• That is a -- that product there -- I mean, when I'm just following the

• rules of matrix multiplication,

• those rules are just looking like -- kind of

• petite, kind of small, because the -- the rows here are so

• short and the columns there are so short, but they're the same

• length, one entry. So what's the answer?

• What's the answer if I do two three four times one six,

• just for practice? Well, what's the first row of the

• answer? Two twelve. And the second row of the answer is

• three eighteen. And the third row of the answer is

• four twenty four. Actually, what am I --

• I mean, that's a very special matrix, there.

• Very special matrix. What can you tell me about its

• columns, the columns of that matrix?

• They're multiples of this guy, right?

• They're multiples of that one. Which follows our rule.

• We said that the columns of the answer were combinations,

• but there's only -- to take a combination of one guy,

• it's just a multiple. The rows of the answer,

• what can you tell me about those three rows?

• They're all multiples of this row. They're all multiples of

• one six, as we expected. But I'm getting a full-sized

• matrix. And now, just to complete this

• thought, if I have,-- now, l- let me right

• down the fourth way. A B is a sum of columns

• of A times rows of B. So that, for example, if my --

• if my matrix was two three four and then had another column,

• say, seven eight nine, and my matrix here has --

• say, started with one six and then had another column like zero zero,

• then -- h- here's the fourth way, okay?

• I've got two columns there, I've got two rows there.

• So the beautiful rule is -- see, the whole thing by columns

• and rows is that I can take the first column times the first

• row and add the second column times the second row.

• So that's the fourth way, that -- that I can take columns times rows,

• first column times first row, second column times second row and add.

• Actually, what will I get? What will the answer be for that

• matrix multiplication? Well, this one it's just going to

• give us zero, so in fact I'm back to this --

• that's the answer, for that matrix multiplication. [sneeze]

• Uh -- I'm -- I'm sort of,

• like, happy to put up here these facts about matrix multiplication,

• because it gives me a chance to write down special

• matrices like this. This is a special matrix.

• All those rows lie on the same line.

• All those rows lie on the line through one six.

• If I draw a picture of all these row vectors, they're all

• the same direction. If I draw a picture of these two

• column vectors, they're in the same direction.

• Later, I would use this language. Not too much later, either.

• I would say the row space, which is like all the combinations

• of the rows, is just a line for this matrix.

• The row space is the line through the vector one six.

• All the rows lie on that line. And the column space is also a line.

• All the columns lie on the line through the vector two three four.

• So this is like a really minimal matrix.

• And it's because of these ones. Okay. So that's a third way.

• Now, even -- yeI -- can I --

• will you -- would you take -- this is -- I- I want to say one more

• thing about matrix multiplication while we're on the subject.

• And it's this. You could also multiply --

• you could also cut the matrix into blocks and do the multiplication

• by blocks. Yethat's actually so,

• useful that I want to mention it. Block multiplication.

• So I could take my matrix A and I could

• chop it up, like, maybe just for simplicity,

• let me chop it into two -- into four square blocks.

• Suppose it's square. Let's just take a nice case.

• And B, suppose it's square also, same size.

• So these sizes don't have to be the same.

• What they have to do is match properly.

• Here they certainly will match. So here's the rule for

• block multiplication, that if this has blocks like,

• A -- so maybe A one, A two, A three, A four

• are the blocks here, and these blocks are B one,

• B two, B three and B four? Then the answer I can find block --

• I can find that block. And if you tell me what's in that

• block, then I'm going to be quiet about matrix multiplication for the

• rest of the day. What goes into that block?

• You see, these might be -- this matrix might be --

• these matrices might be, like, twenty by twenty with blocks that

• are ten by ten, to take the easy case where all the

• blocks are the same shape. And the point is that I could

• multiply those by blocks. And what goes in here? What's that?

• What's that -- what's that block in the answer?

• A one B one, that's a matrix times a matrix,