1 00:00:05,140 --> 00:00:08,210 In this second of the videos on matrix multiplication, we're 2 00:00:08,210 --> 00:00:11,280 going to delve a little bit more deeply into matrix 3 00:00:11,280 --> 00:00:14,350 multiplication and look at some of the properties and the 4 00:00:14,350 --> 00:00:17,113 conditions under which different sorts of multiplication can be 5 00:00:17,113 --> 00:00:20,490 carried out. Let's start by looking at looking at a specific 6 00:00:20,490 --> 00:00:23,560 example in this example. Here I've written down to matrices 7 00:00:23,560 --> 00:00:28,791 M&N. And let's look at the sizes of these matrices. The first 8 00:00:28,791 --> 00:00:33,392 matrix M. Is a three row three column matrix, so 9 00:00:33,392 --> 00:00:34,848 it's three by three. 10 00:00:37,710 --> 00:00:42,070 And the second matrix N is 3 rows, two columns. 11 00:00:42,900 --> 00:00:44,250 So it's a 3 by 2. 12 00:00:46,920 --> 00:00:49,152 And we notice that these numbers are the same. 13 00:00:50,920 --> 00:00:54,261 The number of columns in the first is the same as the number 14 00:00:54,261 --> 00:00:57,088 of rows in the second, so we can perform this matrix 15 00:00:57,088 --> 00:01:00,172 multiplication and the size of the answer will be a three by 16 00:01:00,172 --> 00:01:03,513 two matrix. So right at the start we know the size of the 17 00:01:03,513 --> 00:01:06,597 answer. It's going to have three rows and two columns just like 18 00:01:06,597 --> 00:01:09,788 this one had. So the shape of the answer is. 19 00:01:10,910 --> 00:01:13,396 Like we have here and we're looking for these 6 numbers. 20 00:01:13,980 --> 00:01:14,760 In the product. 21 00:01:16,510 --> 00:01:17,818 Let's try and work it out. 22 00:01:18,780 --> 00:01:23,239 To find the number that's in the first row, first column. We work 23 00:01:23,239 --> 00:01:27,698 with the first row of the first matrix and the first column of 24 00:01:27,698 --> 00:01:28,727 the Second Matrix. 25 00:01:29,510 --> 00:01:33,570 What we want is 3 * 1 which is 3. 26 00:01:34,580 --> 00:01:41,116 2 * -- 2 which is minus 4 and 1 * 3, which is 3. So we've got 3 27 00:01:41,116 --> 00:01:42,148 ones or three. 28 00:01:43,730 --> 00:01:50,322 2 * -- 2 is minus 4 and 1 * 3 is 3. We multiply the 29 00:01:50,322 --> 00:01:53,206 paired elements together and add the result. 30 00:01:56,590 --> 00:02:00,776 When we come to the first row, second column, we work with the 31 00:02:00,776 --> 00:02:02,708 first row here and the second 32 00:02:02,708 --> 00:02:08,880 column here. And again, pairing off 3 * -- 2 is minus 6. 33 00:02:10,400 --> 00:02:12,188 2 * 3. 34 00:02:13,030 --> 00:02:13,960 Is 6. 35 00:02:15,470 --> 00:02:18,270 1 * -- 4 is minus 4. 36 00:02:19,030 --> 00:02:21,613 So in each case, we're multiplying the paired elements 37 00:02:21,613 --> 00:02:23,048 together and adding the results. 38 00:02:24,750 --> 00:02:28,936 When we want the element that's going in here, which is in the 39 00:02:28,936 --> 00:02:32,800 2nd row first column of the answer, we work with the 2nd 40 00:02:32,800 --> 00:02:36,664 row, first column of the given matrices 4 * 1 is 4. 41 00:02:38,220 --> 00:02:41,706 Minus 3 * -- 2 is +6. 42 00:02:43,760 --> 00:02:45,510 2 * 3 is 6. 43 00:02:47,600 --> 00:02:52,033 And continuing in the same way, the answer that goes in the 2nd 44 00:02:52,033 --> 00:02:55,443 row, second column comes from taking the 2nd row, second 45 00:02:55,443 --> 00:02:58,846 column. 4 * -- 2 is minus 8. 46 00:03:00,090 --> 00:03:03,498 Minus 3 * + 3 is minus 9. 47 00:03:04,810 --> 00:03:07,400 2 * -- 4 is minus 8. 48 00:03:09,530 --> 00:03:13,886 And finally on the last row to find the element in the 49 00:03:13,886 --> 00:03:17,879 first row. Sorry the 3rd row first column will work with 50 00:03:17,879 --> 00:03:21,146 the 3rd row, First Column, 5 ones of five. 51 00:03:23,170 --> 00:03:25,375 4 * -- 2 is minus 8. 52 00:03:26,410 --> 00:03:28,120 3 * 3 is 9. 53 00:03:29,810 --> 00:03:33,562 And similarly to find the last element, it will be 5 * -- 2, 54 00:03:33,562 --> 00:03:34,634 which is minus 10. 55 00:03:35,260 --> 00:03:40,746 4 * 3 is 12 and 3 * -- 4 is minus 12. 56 00:03:42,360 --> 00:03:46,404 And if we just tidy up what we've got, we'll have 336 57 00:03:46,404 --> 00:03:48,089 subtract 4, which is 2. 58 00:03:50,120 --> 00:03:53,216 Minus 6 + 6 zero subtract 4 is 59 00:03:53,216 --> 00:03:57,269 minus 4. Four and six is 10 and 616. 60 00:03:58,610 --> 00:04:02,912 Minus 8 -- 9 -- 8 is minus 25. 61 00:04:05,450 --> 00:04:07,810 5 subtract 8 + 9. 62 00:04:08,460 --> 00:04:09,530 6th 63 00:04:10,680 --> 00:04:13,452 and minus 10 + 12 -- 12 is minus 64 00:04:13,452 --> 00:04:17,439 10. And this is the result of multiplying these two 65 00:04:17,439 --> 00:04:18,041 matrices together. 66 00:04:20,560 --> 00:04:23,368 What about if we try and multiply the two 67 00:04:23,368 --> 00:04:25,240 matrices together the opposite way round? 68 00:04:25,240 --> 00:04:27,736 Suppose we try and workout N * M. 69 00:04:45,730 --> 00:04:50,644 Now, in this case the size of the first matrix here is 3 rows 70 00:04:50,644 --> 00:04:55,558 and two columns, so that's a three by two and the size of the 71 00:04:55,558 --> 00:04:59,068 second matrix is 3 by 3, three rows, three columns. 72 00:04:59,890 --> 00:05:03,102 And what we observe now is that these two numbers here 73 00:05:03,102 --> 00:05:06,606 are not the same, they are not equal. That means that we 74 00:05:06,606 --> 00:05:08,942 cannot do the matrix multiplication in the order 75 00:05:08,942 --> 00:05:11,570 that I've written it down here. That matrix product 76 00:05:11,570 --> 00:05:15,074 doesn't exist. So this is the first point. I'd like to make 77 00:05:15,074 --> 00:05:18,286 that even when you can find a matrix product by multiplying 78 00:05:18,286 --> 00:05:20,914 two matrices together, it matters very much. The order 79 00:05:20,914 --> 00:05:24,418 in which you write them down. It may be possible to workout 80 00:05:24,418 --> 00:05:27,630 a product one way, but not another way. Let's look at 81 00:05:27,630 --> 00:05:28,506 some more examples. 82 00:05:29,570 --> 00:05:33,123 Suppose we've got two matrices C&D as I've written them down 83 00:05:33,123 --> 00:05:37,322 here, I'm going to try to work out the product C * D. 84 00:05:38,120 --> 00:05:41,396 And I'll also try and workout the product D times. See if 85 00:05:41,396 --> 00:05:42,488 either of these exist. 86 00:05:43,970 --> 00:05:48,390 But in the first case, we've got a two row three column matrix. 87 00:05:49,280 --> 00:05:52,210 And in the second example here, within the Second matrix 88 00:05:52,210 --> 00:05:56,019 here we've got three rows into two columns, so we can in fact 89 00:05:56,019 --> 00:05:59,242 work this product out because these numbers are the same and 90 00:05:59,242 --> 00:06:03,051 the result will be a two by two matrix. So the shape of 91 00:06:03,051 --> 00:06:05,688 the answer will be 2 rows and two columns. 92 00:06:08,020 --> 00:06:12,610 If we try and do this the other way round, D * C, The first 93 00:06:12,610 --> 00:06:16,588 matrix Now has got three rows and two columns. It's a three by 94 00:06:16,588 --> 00:06:20,260 two matrix and the second one's got two rows and three columns. 95 00:06:20,260 --> 00:06:22,096 It's a two by three matrix. 96 00:06:22,690 --> 00:06:26,092 So you can. You can see that we can still work it out because 97 00:06:26,092 --> 00:06:29,251 these two numbers are still the same 2 into the same, but this 98 00:06:29,251 --> 00:06:32,653 time the result is going to be a three by three matrix, so it's 99 00:06:32,653 --> 00:06:35,569 going to be a bigger matrix with three rows and three columns. 100 00:06:38,990 --> 00:06:43,322 We can use the process that we evaluate that we worked on 101 00:06:43,322 --> 00:06:47,293 before to evaluate the elements in the these matrices. So for 102 00:06:47,293 --> 00:06:53,069 example, the element that goes in here is 1 * 3 + 2 * 5 added 103 00:06:53,069 --> 00:06:55,957 to 3 * -- 1, which is 10. 104 00:06:57,730 --> 00:07:02,295 And you can check for yourself that the remaining elements are 105 00:07:02,295 --> 00:07:03,955 131 and minus 11. 106 00:07:04,780 --> 00:07:08,108 So it's possible to workout C * D and the answer is a 107 00:07:08,108 --> 00:07:09,132 two by two matrix. 108 00:07:10,430 --> 00:07:14,846 When we do it the other way round, let's take an element 109 00:07:14,846 --> 00:07:19,262 here. Let's take the elements in the first row, first column and 110 00:07:19,262 --> 00:07:23,310 we obtain the answer by working with the first row, first 111 00:07:23,310 --> 00:07:27,726 column. Here, that's three times, one is 3 added to minus 7 112 00:07:27,726 --> 00:07:32,142 * 4. That's three added to minus 28, which is minus 25. 113 00:07:34,760 --> 00:07:39,713 And you can proceed in the same way to fill out this resulting 114 00:07:39,713 --> 00:07:44,666 matrix and the numbers. You'll get a -- 25 -- 29 -- 33. 115 00:07:46,540 --> 00:07:52,620 9. 1521 789 116 00:07:53,990 --> 00:07:58,540 The important point that I want to make here is that when you 117 00:07:58,540 --> 00:08:00,290 multiply C * D together. 118 00:08:00,950 --> 00:08:06,350 It may be possible to also find D * C, But the answers that you 119 00:08:06,350 --> 00:08:09,230 get may have completely different sizes. It's certainly 120 00:08:09,230 --> 00:08:14,270 not true that CD is the same as DC, so one of the observations 121 00:08:14,270 --> 00:08:18,950 we take away straight away is that in general CD is not equal 122 00:08:18,950 --> 00:08:23,270 to DC. Even in situations where both of these products do exist, 123 00:08:23,270 --> 00:08:25,790 we say that matrix multiplication is not 124 00:08:25,790 --> 00:08:29,030 commutative. In general, it really doesn't matter the order 125 00:08:29,030 --> 00:08:31,190 in which you carry out the 126 00:08:31,190 --> 00:08:34,950 multiplication. Now that we know how to multiply 2 matrices 127 00:08:34,950 --> 00:08:38,050 together, I'm going to show you an important property of 128 00:08:38,050 --> 00:08:43,818 identity matrices. Suppose we have a two by two identity 129 00:08:43,818 --> 00:08:45,456 matrix, that's 1001. 130 00:08:46,920 --> 00:08:52,250 And suppose we have a second matrix, two 3 -- 4 and seven. 131 00:08:52,250 --> 00:08:55,940 And suppose I want to multiply these two together. 132 00:08:58,950 --> 00:09:02,030 The identity matrix is certainly a two by two matrix, 133 00:09:02,030 --> 00:09:05,726 and this matrix is also a two by two matrix. So because 134 00:09:05,726 --> 00:09:08,806 these numbers are the same, we can actually workout the 135 00:09:08,806 --> 00:09:12,810 product and the answer is also a two by two matrix. So the 136 00:09:12,810 --> 00:09:16,198 answer has this sort of shape with four elements in there. 137 00:09:18,340 --> 00:09:22,904 To get the first element in the answer, we want to pair 10 with 138 00:09:22,904 --> 00:09:26,816 2 -- 4, multiply the paired elements together and add so we 139 00:09:26,816 --> 00:09:30,402 get 1 * 2 is 2 added to 0 * -- 140 00:09:30,402 --> 00:09:33,184 4. Which is just 1 * 2 is 2. 141 00:09:35,720 --> 00:09:41,080 To get this element here, we want 1 * 3 which is 3 added to 0 142 00:09:41,080 --> 00:09:43,090 * 7, which is just three. 143 00:09:45,430 --> 00:09:49,630 To get the element in here, we want to pair 01 with two and 144 00:09:49,630 --> 00:09:54,730 minus four, so it's 0 * 2, which is nothing 1 * -- 4 is minus 4, 145 00:09:54,730 --> 00:09:56,530 so we just get minus 4. 146 00:09:57,630 --> 00:09:59,436 And finally, the last element is 147 00:09:59,436 --> 00:10:03,854 0 times. Three, which is nothing 1 * 7 is 7, so that's our 148 00:10:03,854 --> 00:10:07,910 answer. And if you look at the answer you'll see the answer is 149 00:10:07,910 --> 00:10:11,030 identical to the matrix we started with here. In other 150 00:10:11,030 --> 00:10:14,150 words, multiplying a matrix by an identity matrix when this 151 00:10:14,150 --> 00:10:16,646 multiplication is possible leaves an answer which is 152 00:10:16,646 --> 00:10:20,078 identical to the matrix you started with, and that's a very 153 00:10:20,078 --> 00:10:21,326 important property of identity 154 00:10:21,326 --> 00:10:25,940 matrices. The same result occurs if we do the multiplication the 155 00:10:25,940 --> 00:10:30,860 other way round. If we take two 3 -- 4 seven and we multiply it 156 00:10:30,860 --> 00:10:34,140 by the identity matrix, one nought nought one will find. 157 00:10:34,140 --> 00:10:38,404 It's also possible, and if you go through the operation 2 * 1 158 00:10:38,404 --> 00:10:42,340 is 2 three times. Nothing is nothing. The result there is 2. 159 00:10:43,150 --> 00:10:46,000 Two times nothing is nothing 313. 160 00:10:47,440 --> 00:10:51,604 Minus 4 * 1 added to 7 times nought is minus 4. 161 00:10:52,270 --> 00:10:56,131 And minus four times North, which is nothing added to 717 162 00:10:56,131 --> 00:11:00,694 and you'll see again this answer here is the same as this matrix 163 00:11:00,694 --> 00:11:04,204 here. So that's very important property to remember when you 164 00:11:04,204 --> 00:11:08,065 multiply a matrix by an identity matrix, it leaves the original 165 00:11:08,065 --> 00:11:10,873 matrix unaltered, identical to what it was before. 166 00:11:11,480 --> 00:11:14,135 The same works even if we haven't got square 167 00:11:14,135 --> 00:11:16,200 matrices. Suppose we have this identity matrix. 168 00:11:19,650 --> 00:11:23,178 And we multiply, for example by the Matrix 78. 169 00:11:24,810 --> 00:11:28,702 Well, this has got one row and two columns. It's a one by two 170 00:11:28,702 --> 00:11:32,038 matrix. This is got two rows, two columns, so we can perform 171 00:11:32,038 --> 00:11:35,096 the matrix multiplication and the result is going to be a 172 00:11:35,096 --> 00:11:38,432 one by two matrix that's the same shape as the one we 173 00:11:38,432 --> 00:11:38,988 started with. 174 00:11:40,360 --> 00:11:43,708 And if we carry out the operations, it's 7 * 1, which 175 00:11:43,708 --> 00:11:46,777 is 7 added to 8 times nothing, which is nothing. So 176 00:11:46,777 --> 00:11:48,172 the result is just 7th. 177 00:11:49,200 --> 00:11:54,015 7 times and nothing is nothing and 8 * 1 is 8, so it's just 178 00:11:54,015 --> 00:11:58,188 eight. And again, this answer 7 eight is the same as the matrix 179 00:11:58,188 --> 00:12:01,719 we started with over here. So that's just to reinforce the 180 00:12:01,719 --> 00:12:04,608 message that multiplying by an identity matrix leaves the 181 00:12:04,608 --> 00:12:05,571 original matrix unaltered.