0:00:05.130,0:00:08.300 One of the most important[br]operations we can do with 0:00:08.300,0:00:11.470 matrices is to learn how to[br]multiply them together. That's 0:00:11.470,0:00:14.957 what we're going to do now. And[br]when we multiply matrices 0:00:14.957,0:00:18.444 together, we find that we[br]combine the elements in the two 0:00:18.444,0:00:21.931 matrices in rather a strange[br]way, and the easiest way to 0:00:21.931,0:00:25.101 explain that is by example, so[br]let's have a look. 0:00:26.040,0:00:29.793 Suppose we've got a[br]row of a matrix 37. 0:00:31.650,0:00:36.057 And we want to combine it or[br]multiply it with a column of 0:00:36.057,0:00:37.074 another matrix 29. 0:00:38.790,0:00:42.222 And what we do is we combine[br]these numbers in a rather 0:00:42.222,0:00:46.226 strange way. What we do is we[br]pair off the elements in the row 0:00:46.226,0:00:49.658 of the first matrix with the[br]column with the column in the 0:00:49.658,0:00:52.804 Second matrix, and we pair them[br]off and we multiply the 0:00:52.804,0:00:55.664 corresponding elements together.[br]So we pair off the three with 0:00:55.664,0:00:58.460 the two. The seven with the 9. 0:00:59.250,0:01:02.310 And we multiply the paired[br]elements together so we 0:01:02.310,0:01:03.670 have 3 * 2. 0:01:06.290,0:01:08.546 I mean multiply the[br]seven with the 9. 0:01:10.750,0:01:12.388 And we add the results together. 0:01:13.390,0:01:18.542 So we have 3 * 2 which is[br]6 and 7 * 9, which is 63 0:01:18.542,0:01:22.084 and we add them together[br]and we get the answer 69. 0:01:25.560,0:01:29.004 So we have this rather strange[br]way in which we have combined 0:01:29.004,0:01:32.448 the elements in the row of the[br]first matrix with the column 0:01:32.448,0:01:33.596 in the Second matrix. 0:01:34.620,0:01:38.652 Let's have a look at another[br]example. Suppose we have a row 0:01:38.652,0:01:39.660 which is 425. 0:01:41.020,0:01:45.947 And we're going to learn how to[br]multiply it with a column 368. 0:01:48.670,0:01:53.416 And again, what we do is we pair[br]the elements off elements in the 0:01:53.416,0:01:57.823 row of the first matrix with the[br]column of the Second matrix. We 0:01:57.823,0:01:59.179 have 4 * 3. 0:02:03.200,0:02:05.060 2 * 6. 0:02:07.370,0:02:09.230 5 * 8. 0:02:12.050,0:02:17.003 And we add these products[br]together, so with 4 * 3 which is 0:02:17.003,0:02:23.861 12 two times 6 which is 12 and 5[br]* 8 which is 40. And if we add 0:02:23.861,0:02:26.909 these up will get 12 and 12 is 0:02:26.909,0:02:29.970 24. And 40 which is 64. 0:02:34.190,0:02:37.742 So this is a rather strange way[br]in which we've combined the 0:02:37.742,0:02:40.998 elements in the first matrix[br]with the elements in the second 0:02:40.998,0:02:43.958 matrix, but it's the basis of[br]matrix multiplication, as we'll 0:02:43.958,0:02:47.214 see shortly Now, suppose we have[br]to general matrices A&B, say. 0:02:48.900,0:02:52.050 And we want to find the[br]product of these two 0:02:52.050,0:02:54.885 matrices. In other words, we[br]want to multiply A&B 0:02:54.885,0:02:55.200 together. 0:02:56.470,0:03:00.694 Now suppose that this matrix[br]A. The first matrix has P, 0:03:00.694,0:03:04.534 rossion, Q columns, so it's[br]a P by Q matrix. 0:03:06.270,0:03:09.663 And the second matrix be.[br]Let's suppose that Scott 0:03:09.663,0:03:13.810 are rows and S columns,[br]so it's an arby S matrix. 0:03:15.820,0:03:19.746 Now it turns out that we can[br]only form this product. We can 0:03:19.746,0:03:21.256 only multiply the two matrices 0:03:21.256,0:03:24.692 together. If the number of[br]columns in the first matrix, 0:03:24.692,0:03:28.304 which is Q is the same as the[br]number of rows in the second 0:03:28.304,0:03:31.658 matrix, these two numbers have[br]got to be the same. Q Must equal 0:03:31.658,0:03:35.012 R and the reason for that will[br]become apparent when we start to 0:03:35.012,0:03:38.366 do the calculation. But you've[br]got to be able to pair up the 0:03:38.366,0:03:41.204 elements in the first matrix[br]with the elements in the Second 0:03:41.204,0:03:44.816 matrix and will only be able to[br]do that if the number of columns 0:03:44.816,0:03:48.428 in the first is the same as the[br]number of rows in the second. 0:03:49.960,0:03:54.100 When that's the case, we can[br]actually find the product AB and 0:03:54.100,0:03:57.895 the answer is another matrix.[br]And let's suppose this answer is 0:03:57.895,0:04:02.380 matrix C and the size of matrix.[br]See, we can determine in advance 0:04:02.380,0:04:07.210 from the sizes of matrix A&B,[br]the size of matrix C will be P 0:04:07.210,0:04:11.967 by S. So it's got the same[br]number of rows as the first 0:04:11.967,0:04:16.088 matrix and columns as the second[br]matrix, so this will be an R. 0:04:16.088,0:04:18.624 This will be a P by S matrix. 0:04:20.690,0:04:25.622 Let's have a look at a specific[br]example. Suppose we want to 0:04:25.622,0:04:27.266 multiply the matrix 37. 0:04:27.990,0:04:29.670 45 0:04:32.040,0:04:34.508 by the Matrix 29. 0:04:35.920,0:04:39.077 And the first question we should[br]ask ourselves is, do these 0:04:39.077,0:04:42.234 matrices have the right size so[br]that we can actually multiply 0:04:42.234,0:04:47.470 them together? Well, this matrix[br]is a two row two column matrix. 0:04:50.350,0:04:53.374 And the second matrix[br]is 2 rows one column. 0:04:55.960,0:04:59.951 And we note that the number of[br]columns here in the first matrix 0:04:59.951,0:05:03.942 is the same as the number of[br]rows in the second matrix. So 0:05:03.942,0:05:07.626 these two numbers are the same,[br]so we can do this multiplication 0:05:07.626,0:05:11.924 and the size of the answer. The[br]size of the result that will get 0:05:11.924,0:05:15.915 is obtained by the number of[br]rows in the 1st and columns in 0:05:15.915,0:05:19.906 the second. So the size of the[br]answer that we're looking for is 0:05:19.906,0:05:24.204 a 2 by 1 matrix. So you see[br]right at the beginning we can 0:05:24.204,0:05:27.046 tell how many. Elements are[br]going to be in our answer. 0:05:27.046,0:05:29.770 There's going to be a number[br]there, and a number there so 0:05:29.770,0:05:31.586 that we have a 2 by 1 matrix. 0:05:32.920,0:05:36.169 Now to determine these[br]numbers, we use the same 0:05:36.169,0:05:39.779 operations as we've just[br]seen. We take the first row 0:05:39.779,0:05:43.750 here and we pair the elements[br]with those in the first 0:05:43.750,0:05:44.111 column. 0:05:45.380,0:05:50.308 We multiply the paired elements[br]together and add the result. So 0:05:50.308,0:05:53.892 we want 3 * 2, which is 6. 0:05:55.540,0:06:02.125 We want 7 * 9 which is 63 and[br]we add the results together. 6 0:06:02.125,0:06:07.832 and 63 is 69, so the element[br]that goes in the first position 0:06:07.832,0:06:13.539 in our answer is 69. That's 3 *[br]2 at 7 * 9. 0:06:15.380,0:06:19.043 The element that's going in this[br]position here is obtained by 0:06:19.043,0:06:22.373 working with the 2nd row and[br]this first column here. 0:06:23.120,0:06:25.871 Again, we pair the elements up 4 0:06:25.871,0:06:28.670 * 2. Which is 8th. 0:06:29.950,0:06:36.541 5 * 9 which is 45, and[br]we add the results together. 45 0:06:36.541,0:06:38.062 + 8 is. 0:06:39.600,0:06:40.610 53 0:06:43.270,0:06:46.810 So the result is 6953, so the[br]result of multiplying these two 0:06:46.810,0:06:50.350 matrices together is another[br]matrix which is a 2 by 1 matrix 0:06:50.350,0:06:53.890 and the elements are obtained in[br]the way I've just shown you. 0:06:54.490,0:06:56.116 Let's have a look at another 0:06:56.116,0:07:01.054 example. This time I'm going to[br]try to multiply together the two 0:07:01.054,0:07:06.010 matrices A&B where a is this two[br]by two Matrix 2453 and B. Is 0:07:06.010,0:07:09.550 this two by two Matrix three 6[br]-- 1 nine? 0:07:10.380,0:07:13.339 And again, the first question we[br]should ask ourselves is, do 0:07:13.339,0:07:16.298 these matrices have the right[br]size so that we can actually 0:07:16.298,0:07:21.893 multiply them together? Well,[br]matrix a this matrix A is a two 0:07:21.893,0:07:25.916 row two column matrix. So that's[br]two by two. 0:07:27.550,0:07:30.960 Matrix B is 2 rows and two[br]columns, so that's also 0:07:30.960,0:07:31.890 two by two. 0:07:33.290,0:07:36.631 And you can see that these two[br]numbers are the same. That is, 0:07:36.631,0:07:39.715 the number of columns in the[br]first is the same as the 0:07:39.715,0:07:42.799 number of rows in the second.[br]So we can perform the matrix 0:07:42.799,0:07:43.056 multiplication. 0:07:44.280,0:07:47.604 The size of the answer we can[br]determine right at the start. 0:07:47.604,0:07:51.205 The size of the matrix that we[br]get is determined by the number 0:07:51.205,0:07:54.806 here and the number there two by[br]two. So what we can decide 0:07:54.806,0:07:58.130 before we do any calculation at[br]all is that this answer matrix 0:07:58.130,0:07:59.792 is a two by two matrix. 0:08:00.470,0:08:03.198 Be 2 rows and two columns,[br]so we're looking for four 0:08:03.198,0:08:04.438 numbers to pop in there. 0:08:05.970,0:08:09.389 Let's try and figure out how we[br]work out, what the answer is. 0:08:10.940,0:08:15.269 When we want to find the element[br]that goes in here, observe that 0:08:15.269,0:08:18.599 this is the first row first[br]column of the answer. 0:08:20.140,0:08:23.781 And the number in the first[br]row first column comes from 0:08:23.781,0:08:26.760 looking at the first row and[br]1st Column here. 0:08:28.370,0:08:32.491 If we pair off the elements in[br]the first row and 1st Column 0:08:32.491,0:08:35.027 will have 2 * 3 which is 6. 0:08:36.410,0:08:40.960 4 * -- 1, which is minus four,[br]and we add them together. 0:08:44.870,0:08:49.430 When we come to this element[br]here, this element is in the 0:08:49.430,0:08:50.950 first row, second column. 0:08:51.610,0:08:55.558 So we use the first row, second[br]column in the original matrices. 0:08:56.270,0:09:03.155 2 * 6 which is 12 and 4[br]* 9 Four nines of 36. And 0:09:03.155,0:09:05.909 we add those paired[br]products together. 0:09:08.610,0:09:13.303 When we want the element that's[br]in the 2nd row first column, we 0:09:13.303,0:09:17.996 use the 2nd row in the first[br]matrix and 1st column in the 0:09:17.996,0:09:22.328 Second Matrix. Again, pairing[br]the elements off 5 * 3 is 15. 0:09:23.790,0:09:28.122 3 * -- 1 is minus three.[br]When we add the paired 0:09:28.122,0:09:28.844 elements together. 0:09:30.730,0:09:35.570 Finally. The element that's in[br]the 2nd row, second column of 0:09:35.570,0:09:39.860 the answer is obtained by using[br]the elements in the 2nd row of 0:09:39.860,0:09:42.830 the first matrix, second column[br]of the Second matrix. 0:09:43.810,0:09:50.984 5 * 6 which is 30 and 3 *[br]9, which is 27, and we add the 0:09:50.984,0:09:52.250 paired elements together. 0:09:53.480,0:09:57.596 So finally, just to tidy it[br]up, we've got 6 subtract 4 0:09:57.596,0:09:58.625 which is 2. 0:10:00.540,0:10:03.606 12 + 36, which is 48. 0:10:05.750,0:10:12.533 15 subtract 3 which is 12 and 30[br]+ 27 which is 57, so we can find 0:10:12.533,0:10:18.119 the matrix product AB in this[br]case and the result is a two by 0:10:18.119,0:10:21.874 two matrix. Let's have a look[br]at another example. Suppose 0:10:21.874,0:10:24.654 we're asked to find the[br]product of these two matrices. 0:10:25.990,0:10:29.270 And again, we should ask all[br]these matrices of the 0:10:29.270,0:10:32.550 appropriate size. The first[br]matrix here has two rows, one 0:10:32.550,0:10:34.846 column, it's a 2 by 1 matrix. 0:10:35.760,0:10:40.154 And the second matrix has two[br]rows and two columns, so it's a 0:10:40.154,0:10:44.210 two by two matrix. Now in this[br]case, you'll see that the 0:10:44.210,0:10:48.604 number of columns in the first[br]matrix is not the same as the 0:10:48.604,0:10:52.322 number of rows in the second[br]matrix. Those two numbers are 0:10:52.322,0:10:55.026 not equal, so we cannot[br]multiply these matrices 0:10:55.026,0:10:58.406 together. We say the product of[br]these matrices doesn't exist, 0:10:58.406,0:11:01.110 so we stop there. We can't[br]calculate that. 0:11:02.540,0:11:07.950 Let's have another example.[br]Suppose we want to try to 0:11:07.950,0:11:11.737 find the product of the[br]matrices 3214. 0:11:14.180,0:11:17.700 With the matrix XY. Now this[br]is the first example we've 0:11:17.700,0:11:20.900 looked at where we've had[br]symbols rather than numbers in 0:11:20.900,0:11:23.780 our matrix, but the operation[br]the process is, the 0:11:23.780,0:11:25.380 calculations are just the[br]same. 0:11:26.430,0:11:29.466 First of all, we should ask can[br]we multiply these together? Are 0:11:29.466,0:11:30.731 they of the right size? 0:11:31.660,0:11:34.188 This is a two row two[br]column matrix. 0:11:35.970,0:11:38.562 And this is a two row one[br]column matrix. 0:11:40.030,0:11:43.969 And these numbers are the same[br]in here the number of columns in 0:11:43.969,0:11:48.211 the first is the same as the[br]number of rows in the second. So 0:11:48.211,0:11:50.938 we can actually perform the[br]matrix multiplication and the 0:11:50.938,0:11:55.786 answer we get will be a 2 by 1[br]matrix, so we know the shape of 0:11:55.786,0:11:59.725 the answer. It's a two row one[br]column matrix, so it looks the 0:11:59.725,0:12:01.846 same shape as this one. This one 0:12:01.846,0:12:04.348 here. Two rows, one column. 0:12:06.340,0:12:09.750 Let's actually work out what the[br]elements in the answers are. 0:12:10.600,0:12:15.176 As before, we take the first row[br]and pair the elements with the 0:12:15.176,0:12:21.620 first column. So it's 3[br]multiplied by X 2 * y and we add 0:12:21.620,0:12:26.130 the resulting products, so we[br]get three X + 2 Y. 0:12:33.190,0:12:37.138 The element that's down here,[br]which is in the 2nd row, first 0:12:37.138,0:12:41.086 column of our answer, is[br]obtained by using the 2nd row in 0:12:41.086,0:12:43.060 the first matrix and the first 0:12:43.060,0:12:47.612 column here. Multiply the pad[br]elements together and add so 0:12:47.612,0:12:54.344 it's 1 * X which is X 4 * y,[br]which is 4 Y and we add the 0:12:54.344,0:13:00.328 products together and we get X +[br]4 Y. So the result we found is a 0:13:00.328,0:13:02.198 two row one column matrix. 0:13:03.770,0:13:06.914 In this case, the answers got[br]symbols in as well, but that's 0:13:06.914,0:13:09.534 the result of finding the[br]product of these two matrices. 0:13:09.534,0:13:12.940 Now we can go on and look at[br]more examples and trying to 0:13:12.940,0:13:15.298 find products of matrices of[br]different sizes and shapes, 0:13:15.298,0:13:18.180 and we'll do some more of that[br]in the next video.