1 00:00:00,060 --> 00:00:01,920 Matrix multiplication is really 2 00:00:01,920 --> 00:00:03,302 useful since you can pack 3 00:00:03,302 --> 00:00:05,494 a lot of computation into just 4 00:00:05,494 --> 00:00:08,092 one matrix multiplication operation. 5 00:00:08,110 --> 00:00:10,829 But you should be careful of how you use them. 6 00:00:10,829 --> 00:00:12,103 In this video I want to 7 00:00:12,103 --> 00:00:16,974 tell you about a few properties of matrix multiplication. 8 00:00:18,328 --> 00:00:19,678 When working with just raw 9 00:00:19,680 --> 00:00:21,653 numbers or when working with 10 00:00:21,653 --> 00:00:25,797 scalars, multiplication is commutative. 11 00:00:25,797 --> 00:00:27,459 And what I mean by that is 12 00:00:27,459 --> 00:00:29,272 if you take three times 13 00:00:29,272 --> 00:00:30,873 five, that is equal 14 00:00:30,873 --> 00:00:32,368 to five times three and 15 00:00:32,380 --> 00:00:35,371 the ordering of this multiplication doesn't matter. 16 00:00:35,371 --> 00:00:38,271 And this is called the commutative 17 00:00:38,271 --> 00:00:41,952 property of multiplication of real numbers. 18 00:00:41,952 --> 00:00:43,765 It turns out this property that 19 00:00:43,770 --> 00:00:45,299 you can, you know, reverse 20 00:00:45,310 --> 00:00:46,317 the order in which you 21 00:00:46,317 --> 00:00:50,217 multiply things, this is not true for matrix multiplication.So 22 00:00:50,260 --> 00:00:52,294 concretely, if A and 23 00:00:52,294 --> 00:00:53,423 B are matrices, then in 24 00:00:53,423 --> 00:00:55,120 general, A times B is 25 00:00:55,120 --> 00:00:56,653 not equal to B times 26 00:00:56,653 --> 00:00:58,220 A. So just be careful of that. 27 00:00:58,220 --> 00:01:00,530 It's not okay to arbitrarily reverse 28 00:01:00,550 --> 00:01:02,545 the order in which you are multiplying matrices. 29 00:01:02,545 --> 00:01:04,892 So, we say that matrix multiplication 30 00:01:04,892 --> 00:01:06,420 is not commutative, it's a fancy 31 00:01:06,420 --> 00:01:08,480 way of saying it. 32 00:01:08,560 --> 00:01:11,028 As a concrete example, here 33 00:01:11,028 --> 00:01:13,156 are two matrices, matrix 1100 34 00:01:13,156 --> 00:01:14,302 times 0020, and if you multiply 35 00:01:14,302 --> 00:01:17,018 these two matrices, you get this result on the right. 36 00:01:17,020 --> 00:01:20,428 Now, let's swap around the order of these two matrices. 37 00:01:20,460 --> 00:01:21,857 So, I'm going to take these 38 00:01:21,857 --> 00:01:24,244 two matrices and just reverse them. 39 00:01:24,250 --> 00:01:25,511 It turns out if you multiply 40 00:01:25,511 --> 00:01:27,629 these two matrices, you get 41 00:01:27,630 --> 00:01:29,525 the second answer on the 42 00:01:29,525 --> 00:01:31,423 right and, you know, real 43 00:01:31,423 --> 00:01:33,652 clearly, these two matrices are 44 00:01:33,652 --> 00:01:36,099 not equal to each other. 45 00:01:36,730 --> 00:01:38,159 So, in fact, in 46 00:01:38,159 --> 00:01:39,120 general, if you have 47 00:01:39,120 --> 00:01:41,585 a matrix operation like 48 00:01:41,585 --> 00:01:44,793 A times B. If A 49 00:01:44,793 --> 00:01:47,301 is an m by n matrix 50 00:01:47,301 --> 00:01:49,188 and B is an by 51 00:01:49,210 --> 00:01:52,415 M matrix, just as an example. 52 00:01:52,430 --> 00:01:53,974 Then, it turns out 53 00:01:53,980 --> 00:01:56,735 that the matrix A times 54 00:01:56,735 --> 00:01:59,042 B right, is going 55 00:01:59,042 --> 00:02:01,258 to be an m by 56 00:02:01,280 --> 00:02:03,792 m matrix, where as 57 00:02:03,792 --> 00:02:06,410 the matrix b x a 58 00:02:06,460 --> 00:02:08,390 is going to be an n 59 00:02:08,450 --> 00:02:09,928 by n matrix so the 60 00:02:09,928 --> 00:02:11,406 dimensions don't even match, right, 61 00:02:11,410 --> 00:02:13,283 so A times B and 62 00:02:13,290 --> 00:02:16,647 B times A may not even be the same dimension. 63 00:02:16,647 --> 00:02:17,762 In the example on the left, 64 00:02:17,762 --> 00:02:19,265 I have all two by two matrices, 65 00:02:19,265 --> 00:02:20,342 so the dimensions were the same, 66 00:02:20,342 --> 00:02:22,688 but in general reversing the 67 00:02:22,688 --> 00:02:25,285 order of the matrices 68 00:02:25,320 --> 00:02:27,301 can even change the dimension 69 00:02:27,301 --> 00:02:30,030 of the outcome so 70 00:02:30,030 --> 00:02:33,291 matrix multiplication is not commutative. 71 00:02:34,310 --> 00:02:36,302 Here's the next I want to talk about. 72 00:02:36,302 --> 00:02:37,663 So, when talking about real 73 00:02:37,680 --> 00:02:39,731 numbers, or scalars, let's 74 00:02:39,731 --> 00:02:42,859 see, I have 3 times 5 times 2. 75 00:02:42,860 --> 00:02:45,848 I can either multiply 5 76 00:02:45,848 --> 00:02:47,625 times 2 first, and 77 00:02:47,625 --> 00:02:50,394 I can compute this as 3 times 10. 78 00:02:50,430 --> 00:02:52,936 Or, I can multiply 79 00:02:52,936 --> 00:02:54,635 three times five for us and 80 00:02:54,635 --> 00:02:55,804 I can compute this as, you 81 00:02:55,804 --> 00:02:58,029 know fifteen times two and 82 00:02:58,029 --> 00:02:59,885 both of these give you the same answer, right? 83 00:02:59,885 --> 00:03:01,007 Each, both of these is equal 84 00:03:01,060 --> 00:03:03,895 to thirty so Whether I 85 00:03:03,910 --> 00:03:06,433 multiply five times 86 00:03:06,433 --> 00:03:08,185 two first or whether I 87 00:03:08,185 --> 00:03:09,746 multiply three times five 88 00:03:09,746 --> 00:03:12,663 first because well, three 89 00:03:12,663 --> 00:03:14,670 times five times two 90 00:03:14,670 --> 00:03:16,389 is equal to three times 91 00:03:16,389 --> 00:03:18,894 five times two. 92 00:03:18,894 --> 00:03:20,445 And this is called the 93 00:03:20,445 --> 00:03:27,022 associative property of role number multiplication. 94 00:03:27,022 --> 00:03:30,695 It turns out that matrix multiplication is associative. 95 00:03:30,695 --> 00:03:32,335 So concretely, let's say 96 00:03:32,335 --> 00:03:33,452 I have a product of three 97 00:03:33,452 --> 00:03:34,762 matrices, A times B times 98 00:03:34,762 --> 00:03:36,189 C. Then I can 99 00:03:36,189 --> 00:03:37,818 compute this either as A 100 00:03:37,840 --> 00:03:41,412 times, B times C 101 00:03:41,460 --> 00:03:42,838 or I can compute this as 102 00:03:42,838 --> 00:03:45,310 A times B, times C 103 00:03:45,710 --> 00:03:48,125 and these will actually give me the same answer. 104 00:03:48,125 --> 00:03:49,310 I'm not going to prove this, but 105 00:03:49,310 --> 00:03:51,556 you can just take my word for it, I guess. 106 00:03:51,556 --> 00:03:52,692 So just be clear what I mean by 107 00:03:52,692 --> 00:03:54,340 these two cases, let's look 108 00:03:54,340 --> 00:03:56,263 at first one first case. 109 00:03:56,270 --> 00:03:57,345 What I mean by that is 110 00:03:57,345 --> 00:03:58,405 if you actually want to compute 111 00:03:58,405 --> 00:03:59,925 A times B times C, what 112 00:03:59,925 --> 00:04:01,410 you can do is you can 113 00:04:01,410 --> 00:04:03,078 first compute B times C. 114 00:04:03,100 --> 00:04:04,423 So that D equals B time 115 00:04:04,423 --> 00:04:05,848 C, then compute A times 116 00:04:05,848 --> 00:04:07,178 D. And so this is really 117 00:04:07,200 --> 00:04:09,605 computing a times B 118 00:04:09,605 --> 00:04:12,406 times C. Or, for 119 00:04:12,440 --> 00:04:14,895 this second case, You can 120 00:04:14,895 --> 00:04:16,065 compute this as, you can 121 00:04:16,112 --> 00:04:17,673 set E equals A 122 00:04:17,680 --> 00:04:19,142 times B. Then compute E 123 00:04:19,142 --> 00:04:20,750 times C. And this 124 00:04:20,750 --> 00:04:22,912 is then the same as a 125 00:04:22,920 --> 00:04:25,526 times B times C 126 00:04:25,530 --> 00:04:27,322 and it turns out that both 127 00:04:27,322 --> 00:04:30,115 of these options will give 128 00:04:30,115 --> 00:04:33,702 you, is guaranteed to give you the same answer. 129 00:04:33,702 --> 00:04:35,115 And so we say that matrix 130 00:04:35,115 --> 00:04:39,692 multiplication does enjoy the associative property. 131 00:04:39,722 --> 00:04:40,592 Okay? 132 00:04:40,592 --> 00:04:42,752 And don't worry about the terminology 133 00:04:42,752 --> 00:04:44,609 associative and commutative that's 134 00:04:44,625 --> 00:04:46,083 why there's not really going to use 135 00:04:46,083 --> 00:04:47,586 this terminology later in these 136 00:04:47,586 --> 00:04:50,608 class, so don't worry about memorizing those terms. 137 00:04:50,608 --> 00:04:52,841 Finally, I want to 138 00:04:52,841 --> 00:04:54,552 tell you about the identity 139 00:04:54,552 --> 00:04:56,676 matrix, which is special matrix. 140 00:04:56,676 --> 00:04:58,202 So let's again make the 141 00:04:58,210 --> 00:04:59,296 analogy to what we know 142 00:04:59,296 --> 00:05:01,342 of raw numbers, so when dealing 143 00:05:01,342 --> 00:05:02,842 with raw numbers or scalar 144 00:05:02,842 --> 00:05:04,562 numbers, the number one, 145 00:05:04,562 --> 00:05:06,131 is you can think 146 00:05:06,131 --> 00:05:09,756 of it as the identity of multiplication, 147 00:05:09,810 --> 00:05:10,853 and what I mean by that 148 00:05:10,853 --> 00:05:12,885 is for any number 149 00:05:12,885 --> 00:05:14,942 Z, the number 1 150 00:05:14,950 --> 00:05:16,803 times z is equal 151 00:05:16,810 --> 00:05:19,754 to z times one, and 152 00:05:19,754 --> 00:05:21,550 that's just equal to 153 00:05:21,550 --> 00:05:24,548 the number z, right, for any raw number. 154 00:05:24,548 --> 00:05:26,128 Z. So 1 is 155 00:05:26,128 --> 00:05:29,891 the identity operation and so it satisfies this equation. 156 00:05:29,900 --> 00:05:31,755 So it turns out that 157 00:05:31,755 --> 00:05:33,297 in the space of matrices as 158 00:05:33,297 --> 00:05:35,453 an identity matrix as well. 159 00:05:35,453 --> 00:05:38,375 And it's unusually denoted i, 160 00:05:38,380 --> 00:05:39,573 or sometimes we write it 161 00:05:39,573 --> 00:05:40,945 as i of n by 162 00:05:40,970 --> 00:05:43,079 n we want to make explicit the dimensions. 163 00:05:43,079 --> 00:05:44,355 So I subscript n by n 164 00:05:44,355 --> 00:05:47,391 is the n by n identity matrix. 165 00:05:47,391 --> 00:05:49,339 And so there's a different identity 166 00:05:49,339 --> 00:05:53,375 matrix for each dimension n and are a few examples. 167 00:05:53,410 --> 00:05:54,912 Here's the two by two identity 168 00:05:54,912 --> 00:05:56,447 matrix, here's the three 169 00:05:56,447 --> 00:05:59,882 by three identity matrix, here's the four by four identity matrix. 170 00:05:59,882 --> 00:06:01,858 So the identity matrix, has the 171 00:06:01,858 --> 00:06:03,602 property that it has 172 00:06:03,602 --> 00:06:06,348 ones along the diagonals, 173 00:06:07,620 --> 00:06:10,325 right, and so on and 174 00:06:10,325 --> 00:06:12,915 is zero everywhere else, and 175 00:06:12,915 --> 00:06:14,012 so, by the way the 176 00:06:14,012 --> 00:06:17,425 one by one identity matrix is just a number one. 177 00:06:17,425 --> 00:06:18,740 This is one by one matrix 178 00:06:18,740 --> 00:06:20,090 just and it's not a very 179 00:06:20,090 --> 00:06:23,242 interesting identity matrix and informally 180 00:06:23,285 --> 00:06:24,593 when I or others are being 181 00:06:24,610 --> 00:06:26,438 sloppy, very often, we will 182 00:06:26,438 --> 00:06:28,878 write the identity matrix using fine notation. 183 00:06:28,880 --> 00:06:30,574 I draw, you know, let's 184 00:06:30,574 --> 00:06:31,675 go back to it and just write 1111, 185 00:06:31,675 --> 00:06:33,565 dot, dot, dot, 1 186 00:06:33,565 --> 00:06:34,928 and then we'll, maybe, somewhat 187 00:06:34,940 --> 00:06:37,650 sloppily write a bunch of zeros there. 188 00:06:37,660 --> 00:06:40,750 And these zeros, this 189 00:06:40,750 --> 00:06:42,474 big zero, this big zero 190 00:06:42,474 --> 00:06:44,262 that's meant to denote that this 191 00:06:44,262 --> 00:06:46,174 matrix is zero everywhere except for 192 00:06:46,174 --> 00:06:47,367 the diagonals, so this is just 193 00:06:47,367 --> 00:06:49,680 how I might sloppily write 194 00:06:49,680 --> 00:06:52,251 this identity matrix 195 00:06:52,251 --> 00:06:55,138 She says property that for 196 00:06:55,138 --> 00:06:57,493 any matrix A, A times 197 00:06:57,493 --> 00:06:59,635 identity i times A 198 00:06:59,660 --> 00:07:00,892 A. So that's a lot 199 00:07:00,892 --> 00:07:04,782 like this equation that we have up here. 200 00:07:04,782 --> 00:07:06,502 One times z equals z times 201 00:07:06,502 --> 00:07:08,427 one, equals z itself so 202 00:07:08,430 --> 00:07:09,972 I times A equals A 203 00:07:09,972 --> 00:07:12,566 times I equals A. Just 204 00:07:12,570 --> 00:07:14,095 make sure we have the dimensions right, so 205 00:07:14,095 --> 00:07:15,721 if A is a n 206 00:07:15,721 --> 00:07:18,065 by n matrix, then this 207 00:07:18,080 --> 00:07:19,952 identity matrix that's an 208 00:07:19,952 --> 00:07:22,797 m by n identity matrix. 209 00:07:23,260 --> 00:07:24,573 And if A is m by 210 00:07:24,573 --> 00:07:26,595 n then this identity 211 00:07:26,595 --> 00:07:28,766 matrix, right, for matrix 212 00:07:28,766 --> 00:07:30,270 multiplication make sense that has a 213 00:07:30,290 --> 00:07:33,008 m by n matrix because 214 00:07:33,008 --> 00:07:34,305 this m has a match 215 00:07:34,305 --> 00:07:36,948 up that m And 216 00:07:36,948 --> 00:07:38,619 in either case the outcome 217 00:07:38,619 --> 00:07:40,042 of this process is you 218 00:07:40,042 --> 00:07:42,025 get back to Matrix A, which 219 00:07:42,030 --> 00:07:44,501 is m by n. 220 00:07:44,530 --> 00:07:46,068 So whenever we write 221 00:07:46,068 --> 00:07:47,728 the identity matrix I, you 222 00:07:47,728 --> 00:07:50,798 know, very often the dimension rightwill 223 00:07:50,810 --> 00:07:52,473 be implicit from the context. 224 00:07:52,473 --> 00:07:53,665 So these two I's they' re 225 00:07:53,665 --> 00:07:55,645 actually different dimension matrices, one 226 00:07:55,645 --> 00:07:56,789 may be N by N, the other 227 00:07:56,789 --> 00:07:58,985 is M by M But when 228 00:07:58,985 --> 00:08:00,505 we want to make the dimension 229 00:08:00,510 --> 00:08:02,831 of the matrix explicit, then sometimes 230 00:08:02,840 --> 00:08:04,468 we'll write to this I subscript 231 00:08:04,480 --> 00:08:06,470 N by N, kind of like we have up here. 232 00:08:06,470 --> 00:08:09,854 But very often the dimension will be implicit. 233 00:08:10,040 --> 00:08:11,513 Finally, just want to point 234 00:08:11,513 --> 00:08:14,606 out that earlier I 235 00:08:14,606 --> 00:08:16,458 said that A times B 236 00:08:16,458 --> 00:08:19,069 is not in general equal 237 00:08:19,069 --> 00:08:22,595 to B times A, right? 238 00:08:22,595 --> 00:08:25,687 That for most matrices A and B, this is not true. 239 00:08:25,690 --> 00:08:29,558 But when B is the identity matrix, this does hold true. 240 00:08:29,580 --> 00:08:30,840 That A times the identity 241 00:08:30,870 --> 00:08:33,390 matrix does indeed equal to 242 00:08:33,390 --> 00:08:34,523 identity times A, it's 243 00:08:34,523 --> 00:08:35,858 just that this is not true 244 00:08:35,858 --> 00:08:39,124 for other matrices, B in general. 245 00:08:39,900 --> 00:08:41,645 So that's it for the 246 00:08:41,645 --> 00:08:43,994 properties of matrix multiplication. 247 00:08:43,994 --> 00:08:45,416 And the special matrices, like the 248 00:08:45,416 --> 00:08:46,618 identity matrix I want to 249 00:08:46,618 --> 00:08:48,505 tell you about, in the next 250 00:08:48,505 --> 00:08:51,690 and final video now linear algebra review. 251 00:08:51,690 --> 00:08:53,337 I am going to quickly tell you 252 00:08:53,350 --> 00:08:55,895 about a couple of special 253 00:08:55,895 --> 00:08:58,190 matrix operations, and after 254 00:08:58,190 --> 00:08:59,328 that you know everything you need 255 00:08:59,328 --> 00:09:01,830 to know about linear algebra for this course