0:00:00.000,0:00:00.670 0:00:00.670,0:00:02.380 Well, after the last video,[br]hopefully, we're a little 0:00:02.380,0:00:04.330 familiar with how you[br]add matrices. 0:00:04.330,0:00:07.150 So now let's learn how[br]to multiply matrices. 0:00:07.150,0:00:11.450 And keep in mind, these are[br]human-created definitions for 0:00:11.450,0:00:12.840 matrix multiplication. 0:00:12.840,0:00:15.000 We could have come up with[br]completely different ways to 0:00:15.000,0:00:15.450 multiply it. 0:00:15.450,0:00:18.510 But I encourage you to learn[br]this way because it'll help 0:00:18.510,0:00:19.810 you in math class. 0:00:19.810,0:00:22.100 And we will see later that[br]there's actually a lot of 0:00:22.100,0:00:24.730 applications that come out[br]of this type of matrix 0:00:24.730,0:00:25.290 multiplication. 0:00:25.290,0:00:26.340 So let me think of[br]two matrices. 0:00:26.340,0:00:30.320 I will do two 2 by 2 matrices,[br]and let's multiply them. 0:00:30.320,0:00:34.500 Let's say-- let me pick some[br]random numbers: 2, 0:00:34.500,0:00:40.530 minus 3, 7, and 5. 0:00:40.530,0:00:42.980 And I'm going to multiply that[br]matrix, or that table of 0:00:42.980,0:00:56.440 numbers, times 10, minus 8--[br]let me pick a good number 0:00:56.440,0:01:03.980 here-- 12, and then minus 2. 0:01:03.980,0:01:07.400 So now there might be a strong[br]temptation-- and you know in 0:01:07.400,0:01:11.330 some ways it's not even an[br]illegitimate temptation-- to 0:01:11.330,0:01:13.880 do the same thing with[br]multiplication that we did 0:01:13.880,0:01:17.520 with addition, to just multiply[br]the corresponding 0:01:17.520,0:01:20.580 terms. So you might be tempted[br]to say, well, the first term 0:01:20.580,0:01:23.160 right here, the 1, 1 term, or[br]in the first row and first 0:01:23.160,0:01:25.070 column, is going to[br]be 2 times 10. 0:01:25.070,0:01:26.970 And this term is going[br]to be minus 3 times 0:01:26.970,0:01:28.230 minus 8 and so forth. 0:01:28.230,0:01:30.330 And that's how we added matrices[br]so maybe it's a 0:01:30.330,0:01:33.510 natural extension to multiply[br]matrices the same way. 0:01:33.510,0:01:36.180 And that is legitimate. 0:01:36.180,0:01:38.530 One could define it that way,[br]but that's not the way it is 0:01:38.530,0:01:39.410 in the real world. 0:01:39.410,0:01:40.380 And the way in the real world, 0:01:40.380,0:01:42.470 unfortunately, is more complex. 0:01:42.470,0:01:44.980 But if you look at a[br]bunch of examples I 0:01:44.980,0:01:45.670 think you'll get it. 0:01:45.670,0:01:47.460 And you'll learn that[br]it's actually fairly 0:01:47.460,0:01:47.980 straightforward. 0:01:47.980,0:01:48.985 So how do we do it? 0:01:48.985,0:01:53.290 So this first term that's in[br]the first row and its first 0:01:53.290,0:01:58.050 column, is equal to essentially[br]this first row's 0:01:58.050,0:02:01.380 vector-- no, this first[br]row vector-- 0:02:01.380,0:02:04.790 times this column vector. 0:02:04.790,0:02:08.229 Now what do I mean[br]by that, right? 0:02:08.229,0:02:11.320 So it's getting it's row[br]information from the first 0:02:11.320,0:02:14.170 matrix's row, and it's getting[br]it's column information from 0:02:14.170,0:02:16.320 the second matrix's column. 0:02:16.320,0:02:17.190 So how do I do that? 0:02:17.190,0:02:18.860 If you're familiar with dot[br]product, it's essentially the 0:02:18.860,0:02:20.930 dot product of these[br]two matrices. 0:02:20.930,0:02:24.820 Or without saying it that fancy,[br]it's just this: it's 2 0:02:24.820,0:02:31.890 times 10, so 2-- I'm going to[br]write small-- times 10, plus 0:02:31.890,0:02:39.640 minus 3 times 12. 0:02:39.640,0:02:42.630 I'm going to run out of space. 0:02:42.630,0:02:45.600 And so what's this second[br]term over here? 0:02:45.600,0:02:49.170 Well, we're still on the first[br]row of the product vector but 0:02:49.170,0:02:50.350 now we're on the[br]second column. 0:02:50.350,0:02:51.910 We get our column information[br]from here. 0:02:51.910,0:02:58.800 So let's pick a good color--[br]this is a slightly different 0:02:58.800,0:03:00.530 shade of purple. 0:03:00.530,0:03:04.110 So now this is going to be--[br]I'll do that in another 0:03:04.110,0:03:10.580 color-- 2 times minus 8-- let me[br]just write out the number-- 0:03:10.580,0:03:18.810 2 times minus 8 is minus 16,[br]plus minus 3 times minus 2-- 0:03:18.810,0:03:21.160 what's minus 3 times minus 2? 0:03:21.160,0:03:26.400 That is plus 6, right? 0:03:26.400,0:03:28.870 So that's in row 1 column 2. 0:03:28.870,0:03:30.590 It's minus 16 plus 6. 0:03:30.590,0:03:31.830 And then let's come down here. 0:03:31.830,0:03:33.920 So now we're in the[br]second row. 0:03:33.920,0:03:35.550 So now we're going to use--[br]we're getting our row 0:03:35.550,0:03:37.930 information from the first[br]matrix-- I know this is 0:03:37.930,0:03:41.380 confusing and I feel bad for you[br]right now, but we're going 0:03:41.380,0:03:45.230 to a bunch of examples and[br]I think it'll make sense. 0:03:45.230,0:03:49.060 So this term-- the bottom left[br]term-- is going to be this row 0:03:49.060,0:03:50.310 times this column. 0:03:50.310,0:03:58.010 So it's going to be 7 times[br]10, so 70, plus 7 times 10 0:03:58.010,0:04:05.650 plus 5 times 12, plus 60. 0:04:05.650,0:04:09.290 And then the bottom right term[br]is going to be 7 times minus 0:04:09.290,0:04:19.540 8, which is minus 56 plus[br]5 times minus 2. 0:04:19.540,0:04:22.900 So that's minus 10. 0:04:22.900,0:04:31.290 So the final product is going to[br]be 2 times 10 is 20, minus 0:04:31.290,0:04:41.040 36, so that's minus 16[br]plus 6, that's 10. 0:04:41.040,0:04:42.220 90-- was that what I said? 0:04:42.220,0:04:46.390 No, it was-- 70, plus[br]60, that's 130. 0:04:46.390,0:04:55.580 And then minus 56 minus[br]10, so minus 66. 0:04:55.580,0:04:56.400 So there you have it. 0:04:56.400,0:04:59.020 We just multiplied this matrix[br]times this matrix. 0:04:59.020,0:05:00.360 Let me do another example. 0:05:00.360,0:05:03.490 And I think I'll actually[br]squeeze it on this side so 0:05:03.490,0:05:06.106 that we can write this side out[br]a little bit more neatly. 0:05:06.106,0:05:18.630 So let's take the matrix and[br]now 1, 2, 3, 4, times the 0:05:18.630,0:05:27.710 matrix 5, 6, 7, 8. 0:05:27.710,0:05:30.200 Now we have much more space to[br]work with so this should come 0:05:30.200,0:05:32.760 out neater. 0:05:32.760,0:05:37.460 OK, but I'm going to do the[br]same thing, so to get this 0:05:37.460,0:05:40.350 term right here-- the top left[br]term-- we're going to take-- 0:05:40.350,0:05:43.070 or the one that has row 1 column[br]1-- we're going to take 0:05:43.070,0:05:52.050 the row 1 information from[br]here, and the column 1 0:05:52.050,0:05:54.440 information from here. 0:05:54.440,0:05:56.070 So you can view it as[br]this row vector 0:05:56.070,0:05:57.120 times this column vector. 0:05:57.120,0:06:01.680 So it results, 1 times[br]5 plus 2 times 7. 0:06:01.680,0:06:07.730 0:06:07.730,0:06:08.380 Right? 0:06:08.380,0:06:09.610 There you go. 0:06:09.610,0:06:12.520 And so this term, it'll be this[br]row vector times this 0:06:12.520,0:06:15.740 column vector-- let me do that[br]in a different color-- will be 0:06:15.740,0:06:20.550 1 times 6 plus 2 times 8. 0:06:20.550,0:06:21.370 Let me write that down. 0:06:21.370,0:06:28.590 So it's 1 times 6[br]plus 2 times 8. 0:06:28.590,0:06:33.270 0:06:33.270,0:06:34.720 Now we go down to[br]the second row. 0:06:34.720,0:06:38.130 And we get our row information[br]from the first vector-- let me 0:06:38.130,0:06:44.150 circle it with this color--[br]and it is 3 times 5 0:06:44.150,0:06:45.520 plus 4 times 7. 0:06:45.520,0:06:52.800 0:06:52.800,0:06:54.760 And then we are in the bottom[br]right, so we're in the bottom 0:06:54.760,0:06:57.070 row and second column. 0:06:57.070,0:06:59.350 So we get our row information[br]from here and our column 0:06:59.350,0:07:00.930 information from here. 0:07:00.930,0:07:03.860 So it's 3 times 6[br]plus 4 times 8. 0:07:03.860,0:07:10.300 0:07:10.300,0:07:13.680 And if we simplify,[br]this is 5 plus-- 0:07:13.680,0:07:15.950 Well actually, let me just[br]remind you where all the 0:07:15.950,0:07:16.630 numbers came from. 0:07:16.630,0:07:18.200 So we have that green[br]color, right? 0:07:18.200,0:07:25.890 This 1 and this 2, that's[br]this 1 and this 2, 0:07:25.890,0:07:28.620 this 1 and this 2. 0:07:28.620,0:07:28.755 Right? 0:07:28.755,0:07:30.330 And notice, these were in the[br]first row and they're in the 0:07:30.330,0:07:31.660 first row here. 0:07:31.660,0:07:33.640 And this 5 and this 7? 0:07:33.640,0:07:39.920 Well, that's this 5 and this[br]7, and this 5 and this 7. 0:07:39.920,0:07:42.800 So, interesting. 0:07:42.800,0:07:45.410 This was in column 1 of the[br]second matrix and this is in 0:07:45.410,0:07:47.780 column 1 in the product[br]matrix. 0:07:47.780,0:07:51.030 And similarly, the[br]6 and the 8. 0:07:51.030,0:07:55.610 That's this 6, this 8, and then[br]it's used here, this 6 0:07:55.610,0:07:57.540 and this 8. 0:07:57.540,0:08:00.250 And then finally this 3 and the[br]4 in the brown, so that's 0:08:00.250,0:08:03.980 this 3, this 4, and[br]this 3 and this 4. 0:08:03.980,0:08:05.290 And we could of course[br]simplify all of it. 0:08:05.290,0:08:10.180 This was 1 times 5 plus 2 times[br]7, so that's 5 plus 14, 0:08:10.180,0:08:15.410 so this is 19. 0:08:15.410,0:08:19.200 This is 1 times 6 plus 2[br]times 8, so it's 6 plus 0:08:19.200,0:08:22.330 16, so that's 22. 0:08:22.330,0:08:26.380 This is 3 times 5[br]plus 4 times 7. 0:08:26.380,0:08:32.909 So 15 plus 28, 38, 43-- if my[br]math is correct-- and then we 0:08:32.909,0:08:36.250 have 3 times 6 plus 4 times 8. 0:08:36.250,0:08:44.220 So that's 18 plus[br]32, that's 50. 0:08:44.220,0:08:45.980 So now let me ask you-- just so[br]you know that the product 0:08:45.980,0:08:47.690 matrix-- just write[br]it neatly-- is 0:08:47.690,0:08:53.610 19, 22, 43, and 50. 0:08:53.610,0:08:55.100 So now let me ask[br]you a question. 0:08:55.100,0:08:58.810 When we did matrix addition we[br]learned that if I had two 0:08:58.810,0:09:03.210 matrices-- it didn't matter what[br]order we added them in. 0:09:03.210,0:09:06.970 So if we said, A plus B-- and[br]these are matrices; that's why 0:09:06.970,0:09:09.340 I'm making them all bold-- we[br]said this is the same thing as 0:09:09.340,0:09:12.330 B plus A, based on how[br]we define matrix 0:09:12.330,0:09:15.520 addition, B plus A. 0:09:15.520,0:09:17.060 So now let me ask[br]you a question. 0:09:17.060,0:09:22.970 Is multiplying two matrices,[br]is AB-- that's just means 0:09:22.970,0:09:26.460 we're multiplying A and B-- is[br]that the same thing as BA? 0:09:26.460,0:09:30.090 0:09:30.090,0:09:30.820 Does it matter? 0:09:30.820,0:09:33.800 Does the order of the matrix[br]multiplication matter? 0:09:33.800,0:09:36.310 And so, I'll tell you right[br]now, it actually matters a 0:09:36.310,0:09:37.090 tremendous amount. 0:09:37.090,0:09:39.550 And actually there are certain[br]matrices that you can add in 0:09:39.550,0:09:42.040 one direction that you can't[br]add in the other-- oh, that 0:09:42.040,0:09:47.300 you can multiply in one way but[br]you can't multiply in the 0:09:47.300,0:09:48.200 other order. 0:09:48.200,0:09:50.755 And well, I'll show you that[br]in an example-- but just to 0:09:50.755,0:09:52.800 show that this isn't even equal[br]for most matrices, I 0:09:52.800,0:09:56.640 encourage you to multiply these[br]two matrices in the 0:09:56.640,0:09:57.110 other order. 0:09:57.110,0:09:58.950 Actually let me do that. 0:09:58.950,0:10:00.630 Let me do that really[br]fast just to prove 0:10:00.630,0:10:01.440 the point to you. 0:10:01.440,0:10:02.830 So let me delete all[br]this top part. 0:10:02.830,0:10:06.040 0:10:06.040,0:10:13.830 Let me delete all of it, and[br]actually I can delete to this. 0:10:13.830,0:10:15.960 So hopefully, you know that when[br]I multiply this matrix 0:10:15.960,0:10:17.850 times this matrix, I got this. 0:10:17.850,0:10:20.250 So let me switch the order--[br]and I'll do it fairly fast 0:10:20.250,0:10:23.140 just so as to not bore you-- so[br]let me switch the order of 0:10:23.140,0:10:24.150 the matrix multiplication. 0:10:24.150,0:10:26.755 This is good as this is another[br]example-- so I'm going 0:10:26.755,0:10:36.740 to multiply this matrix: 5, 6,[br]7, 8, times this matrix-- and 0:10:36.740,0:10:40.400 I just switched the order; and[br]we're testing to see whether 0:10:40.400,0:10:46.700 order matters-- 1, 2, 3, 4. 0:10:46.700,0:10:49.010 Let's do it-- and I won't do all[br]the colors and everything, 0:10:49.010,0:10:49.690 I'll just do it systematically. 0:10:49.690,0:10:54.330 I think you just have to see a[br]lot of examples here-- So this 0:10:54.330,0:10:56.410 first term gets its row[br]information from the first 0:10:56.410,0:10:58.810 matrix, column information[br]from the second matrix. 0:10:58.810,0:11:06.340 So it's 5 times 1 plus 6 times[br]3, so it's 5 times 1-- 0:11:06.340,0:11:09.130 Let me just write,[br]actually edit. 0:11:09.130,0:11:17.650 I'm going to skip a step here--[br]OK so it's 5 times 1 0:11:17.650,0:11:23.480 plus 6 times 3, plus 18. 0:11:23.480,0:11:25.110 What's the second term here? 0:11:25.110,0:11:29.650 It's going to be 5 times[br]2 plus 6 times 4. 0:11:29.650,0:11:40.190 So 5 times 2 is 10, plus[br]6 times 4 is 24. 0:11:40.190,0:11:42.390 Right, now we just took[br]this row times this 0:11:42.390,0:11:44.680 column right here. 0:11:44.680,0:11:48.030 OK now we're down here for the[br]set-- so then we're doing this 0:11:48.030,0:11:51.095 row, this element right here at[br]the bottom left is going to 0:11:51.095,0:11:52.960 use this row, and this column. 0:11:52.960,0:12:00.410 So it's 7 times 1[br]plus 8 times 3. 0:12:00.410,0:12:02.980 8 times 3 is 24. 0:12:02.980,0:12:05.430 And then finally, to get this[br]element we're essentially 0:12:05.430,0:12:11.820 multiplying this row times this[br]column, so it's 7 times 2 0:12:11.820,0:12:21.810 is 14, plus 8 times[br]4, plus 32. 0:12:21.810,0:12:30.020 So this is equal to 5[br]plus 18 is 23, 34. 0:12:30.020,0:12:31.100 What's 7 plus 24? 0:12:31.100,0:12:35.530 That's 31, 46. 0:12:35.530,0:12:44.140 So notice, if we called[br]this matrix A and this 0:12:44.140,0:12:47.080 is matrix B, right? 0:12:47.080,0:12:57.560 In the last example, we showed[br]that A times B is equal to 19, 0:12:57.560,0:13:02.640 22, 43, 50. 0:13:02.640,0:13:06.550 And we just showed that, well,[br]if you reverse the order, B 0:13:06.550,0:13:10.225 times A is actually this[br]completely different matrix. 0:13:10.225,0:13:12.230 So the order in which[br]you multiply 0:13:12.230,0:13:15.140 matrices completely matters. 0:13:15.140,0:13:16.330 So I'm actually running[br]out of time. 0:13:16.330,0:13:19.210 In the next video I going talk[br]a little bit more about the 0:13:19.210,0:13:22.260 types of matrix-- well, one, we[br]know that order matters-- 0:13:22.260,0:13:25.110 and in the next video I'll[br]show that what type of 0:13:25.110,0:13:27.460 matrices can be multiplied[br]by each other. 0:13:27.460,0:13:29.820 When we added or subtracted[br]matrices, we just said, well 0:13:29.820,0:13:31.850 they have to have the same[br]dimensions because you're 0:13:31.850,0:13:33.855 adding or subtracting[br]corresponding terms. But 0:13:33.855,0:13:37.040 you'll see with multiplication[br]it's a little bit different. 0:13:37.040,0:13:38.253 And we'll do that in[br]the next video. 0:13:38.253,0:13:39.790 See you soon. 0:13:39.790,0:13:39.900