1
00:00:00,900 --> 00:00:04,190
Topic five is Matrix Multiplication.

2
00:00:04,190 --> 00:00:08,920
So, I think we're developing some idea of
what it means to multiply a vector by a

3
00:00:08,920 --> 00:00:10,860
matrix, and now we'll just look at how we

4
00:00:10,860 --> 00:00:14,710
can extend that idea to multiplying two
matrices together.

5
00:00:21,040 --> 00:00:24,550
So we have a linear system Ax equals b.

6
00:00:24,550 --> 00:00:28,910
And now we know how to make these
elimination matrixes, matrices E.

7
00:00:28,910 --> 00:00:32,050
So, I can make and eliminate, an
elimination matrix E.

8
00:00:33,840 --> 00:00:35,410
And I know what that's supposed to do.

9
00:00:35,410 --> 00:00:39,140
So, I want to define matrix
multiplication,

10
00:00:41,560 --> 00:00:46,160
so that the product of E and my
coefficient matrix.

11
00:00:46,160 --> 00:00:50,500
Gives me the same coefficient matrix I
would get if I did one elimination step.

12
00:00:56,440 --> 00:00:57,790
So we know how to do the vector.

13
00:00:57,790 --> 00:01:00,570
So I know how to do elimination on the
right hand side now.

14
00:01:03,820 --> 00:01:06,720
And I know what effect elimination is
going to

15
00:01:06,720 --> 00:01:08,820
have on the coefficient matrix so I
want to make

16
00:01:08,820 --> 00:01:10,720
sure that whatever definition I come up
with

17
00:01:10,720 --> 00:01:13,430
for matrix multiplication it, it needs to
do that.

18
00:01:18,810 --> 00:01:20,680
So for our.
Column view.

19
00:01:20,680 --> 00:01:24,230
I, I think of the matrix as composed of n
columns.

20
00:01:24,230 --> 00:01:28,910
So here, a1, a2 up to an, these are the
columns of the matrix A.

21
00:01:33,900 --> 00:01:39,220
And I know how to do vector times alright
sorry, matrix times vector multiplication.

22
00:01:39,220 --> 00:01:39,720
So

23
00:01:41,820 --> 00:01:45,680
I could think of one way I might want to
represent matrix multiplication is just,

24
00:01:45,680 --> 00:01:53,350
I'll say the answer needs to be E times
the first column of A, E

25
00:01:53,350 --> 00:01:56,280
times the second column of A, and then
each one of those is going to

26
00:01:56,280 --> 00:02:00,400
be a vector, and I'm going to put all
those vectors back together in a matrix.

27
00:02:00,400 --> 00:02:03,900
And so this would then be the answer

28
00:02:03,900 --> 00:02:07,200
to my matrix multiplication product, so my
matrix

29
00:02:07,200 --> 00:02:08,620
product, E times A.

30
00:02:11,450 --> 00:02:11,950
Okay.

31
00:02:13,550 --> 00:02:16,250
So we have to, to make this a little bit
more rigorous,

32
00:02:16,250 --> 00:02:20,590
we have to start thinking of exactly what
rules we have to follow.

33
00:02:20,590 --> 00:02:24,020
So a matrix is just a rectangular array of
numbers.

34
00:02:25,570 --> 00:02:30,570
If we say an m by n matrix, we mean that
it has m rows and n columns.

35
00:02:33,018 --> 00:02:40,510
And I'm going to denote the entries in the
matrix by little aij.

36
00:02:40,510 --> 00:02:44,950
So if it has, I'm sort of using the
notation here if it's got one subscript.

37
00:02:46,090 --> 00:02:49,260
So if I say just A sub j that's a whole
column.

38
00:02:49,260 --> 00:02:51,890
If it's A sub i that's a row.

39
00:02:51,890 --> 00:02:53,670
Or if it's aij if it has two

40
00:02:53,670 --> 00:02:58,794
subscripts then that's a particular entry
in a matrix.

41
00:02:59,820 --> 00:03:02,600
And so that means I can write my matrix A
like this.

42
00:03:02,600 --> 00:03:09,180
So I have a11 is always the top left entry
and then there's a21 below that, a31 below

43
00:03:09,180 --> 00:03:17,200
that all the way down to am1 and then for
columns I have a11.

44
00:03:17,200 --> 00:03:23,935
Just one step to the right of that is a12,
a13, and so on up to a1n.

45
00:03:25,130 --> 00:03:27,814
And then the bottom right corner will just
be amn.

46
00:03:29,820 --> 00:03:33,660
So this works well for small, smaller
matrices.

47
00:03:33,660 --> 00:03:36,792
I suppose if you wanted to actually start
talking about you know, the.

48
00:03:36,792 --> 00:03:42,476
13, 17 position, you might want to put a
comma in between here,

49
00:03:42,476 --> 00:03:42,478
[COUGH]

50
00:03:42,478 --> 00:03:47,416
and so for addition, we're

51
00:03:47,416 --> 00:03:52,500
going to do addition for matrices

52
00:03:52,500 --> 00:03:57,380
just like we did with vectors, and so it's
going to be For

53
00:03:57,380 --> 00:04:02,370
vectors I call the elements components and
for a matrix I'll call the

54
00:04:02,370 --> 00:04:07,920
elements entries, like that.
So if matrices,

55
00:04:07,920 --> 00:04:10,920
two matrices are the same dimension, so
they have the same number

56
00:04:10,920 --> 00:04:13,710
of rows and the same number of columns,
then I can add them.

57
00:04:13,710 --> 00:04:17,999
And I'm going to say that the sum is just
The element-wise sum.

58
00:04:17,999 --> 00:04:23,110
And then I can also multiply a matrix by a
scalar value, C.

59
00:04:23,110 --> 00:04:25,360
And that's going to be the same as the
vector.

60
00:04:25,360 --> 00:04:29,900
It's just going to be each entry in the
matrix multiplied by that value, C.

61
00:04:32,370 --> 00:04:36,780
So, for instance, if I wanted to add these
two matrices together, I have in the top

62
00:04:36,780 --> 00:04:42,036
left, so the 1 1 sum is just going to be 1
plus 2, so I get 3.

63
00:04:42,036 --> 00:04:48,200
The top right entry is going to be 2 plus
2, 4.

64
00:04:48,200 --> 00:04:49,890
And, you know, every other one.

65
00:04:49,890 --> 00:04:53,350
So this would be 0 plus 9 is equal to 9.

66
00:04:53,350 --> 00:04:57,890
And then if I want to multiply by a scalar
value C.

67
00:04:57,890 --> 00:05:02,228
So here I decided to choose 2 as my scalar
value.

68
00:05:02,228 --> 00:05:03,680
Then that's going to have the affect of
just

69
00:05:03,680 --> 00:05:07,280
doubling every element or every entry in
the matrix.

70
00:05:07,280 --> 00:05:09,914
So 1,2 becomes 2,4.

71
00:05:09,914 --> 00:05:15,270
3,4 becomes 6,8 and then 0,0 stays 0,0.

72
00:05:15,270 --> 00:05:21,770
So addition is pretty straightforward,
scaling by a

73
00:05:24,840 --> 00:05:24,840
[NOISE]

74
00:05:24,840 --> 00:05:27,690
A real valued scalier is pretty straight
forward.

75
00:05:27,690 --> 00:05:30,870
Matrix multiplication we're going to find
is a little bit more difficult.

76
00:05:33,940 --> 00:05:38,610
So in order to plot, in order to multiply
a matrix A by a matrix

77
00:05:38,610 --> 00:05:44,269
B the number of columns of A has to be
equal to the number of rows of B.

78
00:05:49,800 --> 00:05:54,610
So in particular if A is an m by n matrix,
and B is an n by p

79
00:05:54,610 --> 00:06:01,430
matrix, then I'm going to have m rows and
n columns for A.

80
00:06:01,430 --> 00:06:04,680
And then the number of columns of A has to
be equal to the number

81
00:06:04,680 --> 00:06:08,420
of rows, so I have to have n columns in A
and n rows in B.

82
00:06:08,420 --> 00:06:11,730
If that's true, then I can make a matrix
product.

83
00:06:11,730 --> 00:06:14,800
And the output is going to be the
dimension of

84
00:06:14,800 --> 00:06:17,650
the output, so the dimension of the
product is going

85
00:06:17,650 --> 00:06:20,919
to ha have a number of rows determined by
the first.

86
00:06:22,180 --> 00:06:25,880
Element in the product, and a number of
columns determined by the second.

87
00:06:28,330 --> 00:06:31,920
So the product AB is going to have m rows
because A had

88
00:06:31,920 --> 00:06:35,700
m rows and it's going to have p columns
because B had p columns.

89
00:06:39,820 --> 00:06:42,320
And so one thing you can think of is the
matrix

90
00:06:42,320 --> 00:06:46,290
form of the dot product is just the most
extreme case.

91
00:06:46,290 --> 00:06:48,410
So, if I have two vectors, in this case,

92
00:06:48,410 --> 00:06:50,970
of length two, and I take their dot
product.

93
00:06:52,390 --> 00:06:56,160
I could also write that as u transpose, so
that means,

94
00:06:56,160 --> 00:06:59,000
transpose of a vector just means turn it
on it's side.

95
00:07:01,050 --> 00:07:05,090
So, here u is a column vector.
When I transpose it.

96
00:07:05,090 --> 00:07:07,120
It becomes a row.

97
00:07:07,120 --> 00:07:09,430
So I now have a matrix that has one row
and

98
00:07:09,430 --> 00:07:13,960
two columns, times a matrix with two rows
and one column,

99
00:07:16,020 --> 00:07:18,410
and that's just going to be the, the
standard dot product.

100
00:07:19,750 --> 00:07:23,440
And so what was important here was that
the number of columns,

101
00:07:23,440 --> 00:07:27,130
so in this case two, And the number of
rows that had to

102
00:07:27,130 --> 00:07:31,480
match and then I'm able to make this
product, so this is, this

103
00:07:31,480 --> 00:07:35,620
provides a very easy check whenever you're
doing any sort of matrix computation.

104
00:07:37,320 --> 00:07:41,080
you know if the dimensions of your
matrices don't fit in

105
00:07:41,080 --> 00:07:43,389
your products then you've done something
wrong.

106
00:07:49,340 --> 00:07:53,010
And so then the rule to find the actual
entries in the product AB.

107
00:07:56,680 --> 00:07:59,840
So we can say this is going to have the
dot products, so I

108
00:07:59,840 --> 00:08:03,920
think this is the easiest way, if you, if
I'm just interested in calculating.

109
00:08:03,920 --> 00:08:05,830
The product of two matrices.

110
00:08:05,830 --> 00:08:07,450
This is the easiest way to think about it.

111
00:08:07,450 --> 00:08:11,170
So, the entries in the matrix AB are the
dot

112
00:08:11,170 --> 00:08:15,160
products of the rows of A and the columns
of B.

113
00:08:16,290 --> 00:08:20,170
So I'm using this notation.
So AB is the, a matrix product.

114
00:08:20,170 --> 00:08:21,870
And then I

115
00:08:21,870 --> 00:08:24,509
want to take the ith, jth element of that.

116
00:08:26,770 --> 00:08:29,980
And the way I'm going to get that, so
that's going to be one single number.

117
00:08:29,980 --> 00:08:33,680
And remember dot products give me a scaler
value which is one single number.

118
00:08:34,700 --> 00:08:37,875
The way I'm going to figure out what that
number is, is I'm going to take the

119
00:08:37,875 --> 00:08:43,570
ith row of a, and take the dot product of
that and the jth column of B.

120
00:08:44,980 --> 00:08:47,620
And then, once I know what the dimensions
are,

121
00:08:47,620 --> 00:08:49,890
I'll know what the ranges of i and j are.

122
00:08:49,890 --> 00:08:52,530
And then I just have to fill in the matrix
one by one.

123
00:08:55,730 --> 00:08:58,670
You can also write this out using a sum
notation.

124
00:08:58,670 --> 00:09:03,170
So, here, just instead of writing AB.

125
00:09:03,170 --> 00:09:09,412
I'm going to call that matrix C, so C is
the product of the matrix A and B and then

126
00:09:09,412 --> 00:09:15,380
C sub ij are the entries of that matrix
and this is basically just

127
00:09:15,380 --> 00:09:20,489
writing out exactly the same operation
that this would be doing, so here,

128
00:09:20,489 --> 00:09:26,270
I'm summing over k, so k is the thing
that's changing.

129
00:09:26,270 --> 00:09:31,320
So, this i here is the same for all n of
the, the pieces of this

130
00:09:31,320 --> 00:09:37,460
sum.
And similarly, j is staying the same.

131
00:09:37,460 --> 00:09:40,659
So that means that the row of the matrix A
that I'm looking at.

132
00:09:42,060 --> 00:09:45,490
Is determined just by the position of C in

133
00:09:45,490 --> 00:09:50,470
the, in the answer, and then I'm going
across the row and

134
00:09:50,470 --> 00:09:55,030
down the column to compute the actual
value for that,for that entry C.

135
00:09:58,770 --> 00:10:03,650
And so, for example, you can just do a
quick two by two example, so If

136
00:10:03,650 --> 00:10:08,450
I want to know where this 5 came from,
this 5 is in the 1 1 position.

137
00:10:08,450 --> 00:10:10,370
So that tells me it's the dot product of
the

138
00:10:10,370 --> 00:10:14,400
first row of A, and the first column of B.

139
00:10:15,550 --> 00:10:20,370
So that would be 1 times 2, plus 1 times
3, which gives me 5.

140
00:10:20,370 --> 00:10:24,002
Or I can look at Cij, so C

141
00:10:24,002 --> 00:10:27,520
1 1.
So this number here would be C, 1, 1.

142
00:10:27,520 --> 00:10:34,100
Would be a, 1, 1 time b, 1,

143
00:10:34,100 --> 00:10:41,035
1 plus a, 1, 2 times b, 1, 2, which is
exactly the, the same thing.

144
00:10:41,035 --> 00:10:43,804
Ops, sorry.
B, 2, 1.

145
00:10:43,804 --> 00:10:48,963
So a 1 1, b 1 1, a 2 1, sorry,

146
00:10:48,963 --> 00:10:54,902
a 1 2, b 2 1, which gives me the same dot
product.

147
00:10:54,902 --> 00:10:57,825
So I find it tricky to keep track of all
these subscripts,

148
00:10:57,825 --> 00:11:02,130
as you just witnessed, so I prefer
thinking of it like this.

149
00:11:02,130 --> 00:11:05,629
Or, more likely, using a computer to
calculate these things for me.

150
00:11:09,270 --> 00:11:11,710
And one thing to keep in mind, so, for two
by

151
00:11:11,710 --> 00:11:15,920
two and three by three cases, generally it
seems pretty straightforward.

152
00:11:15,920 --> 00:11:20,248
But, really what your aiming at is solving
much bigger systems of equations.

153
00:11:20,248 --> 00:11:24,400
So you want to think about how much work
it's actually going to, going to take.

154
00:11:24,400 --> 00:11:27,700
So, you know, now again you have a
computer, so it's not so bad.

155
00:11:27,700 --> 00:11:30,080
At least it's not you doing the work.

156
00:11:30,080 --> 00:11:33,580
But imagine if you had to solve a problem
on a chalk board.

157
00:11:33,580 --> 00:11:35,140
You know, you would have really

158
00:11:35,140 --> 00:11:36,390
two considerations.

159
00:11:36,390 --> 00:11:40,410
One is going to be, how you know, how

160
00:11:40,410 --> 00:11:43,530
many different operations am I going to
need to do?

161
00:11:43,530 --> 00:11:47,720
So, for each cell in this matrix, so this
one is, if

162
00:11:47,720 --> 00:11:50,620
it's a two by two matrix, there's going to
be four cells

163
00:11:50,620 --> 00:11:51,120
[COUGH]

164
00:11:52,480 --> 00:11:58,330
I need to do n multiplications, so that's
just my dot product, and then to add those

165
00:11:58,330 --> 00:12:03,200
up, I need to do n minus 1 additions.
And then there's going to be,

166
00:12:06,100 --> 00:12:09,280
so in this case, it's square, so it's n
times n,

167
00:12:09,280 --> 00:12:11,929
so this algorithm, I'm going to have to do
something that takes.

168
00:12:13,400 --> 00:12:18,840
2n roughly steps, and I'm going to have to
do that n times n times, so it's going to

169
00:12:18,840 --> 00:12:22,900
take 2 times n cubed mathematical
operations, like simple

170
00:12:22,900 --> 00:12:26,482
mathematical operations, for me to do this
matrix product.

171
00:12:26,482 --> 00:12:31,160
And so the other consideration you might
want to think is

172
00:12:31,160 --> 00:12:32,840
how much memory is that going to take.

173
00:12:32,840 --> 00:12:34,740
So if I was doing this on a chalkboard or

174
00:12:34,740 --> 00:12:38,180
a piece of paper the chalkboard's nice
because I can

175
00:12:38,180 --> 00:12:41,080
actually reuse parts of it by erasing a
number I

176
00:12:41,080 --> 00:12:44,640
don't need anymore and writing another
number in that space.

177
00:12:44,640 --> 00:12:47,380
It's a little more difficult to do with a
piece of paper.

178
00:12:48,630 --> 00:12:52,178
surprisingly if you are programming a
computer, generally when you

179
00:12:52,178 --> 00:12:55,062
want to optimize an algorithm, you're
doing pretty much the same thing.

180
00:12:55,062 --> 00:12:56,180
You want to use the least amount

181
00:12:56,180 --> 00:12:59,320
of memory and do the least amount of
mathematics, so.

182
00:12:59,320 --> 00:13:02,510
A lot of what was developed initially when
people were trying to solve

183
00:13:02,510 --> 00:13:04,340
these problems by hand, is still really

184
00:13:04,340 --> 00:13:06,440
quite useful for solving them with
computers.

185
00:13:11,480 --> 00:13:14,770
Okay, so an inner product is a row times a
column.

186
00:13:14,770 --> 00:13:18,120
So this was the, the example I gave of

187
00:13:18,120 --> 00:13:22,340
a dot product being a simple example of
matrix multiplication.

188
00:13:22,340 --> 00:13:27,588
So, if I have a row times a column then
there's only going to be, so that's

189
00:13:27,588 --> 00:13:34,290
one row with several columns times one
column with several rows.

190
00:13:34,290 --> 00:13:35,970
So, the answer is going to be a scaler.

191
00:13:37,350 --> 00:13:43,130
I can actually move those and do, or do
that in the opposite order.

192
00:13:43,130 --> 00:13:45,280
So now I can do a single col, so a matrix

193
00:13:45,280 --> 00:13:48,740
that's a single column times a matrix
that's a single row.

194
00:13:48,740 --> 00:13:50,660
And that gives me something called an
outer product

195
00:13:51,780 --> 00:13:54,770
and this outer product is now going to be

196
00:13:54,770 --> 00:14:00,080
going to be a matrix so I have a three by
one matrix times a one by three matrix.

197
00:14:00,080 --> 00:14:02,560
And so it's that three on the outside and,
the,

198
00:14:02,560 --> 00:14:04,050
so at the beginning, and the three at the

199
00:14:04,050 --> 00:14:08,530
end that give me the dimension of the
answer.

200
00:14:08,530 --> 00:14:10,410
And then the ones that have to match up on

201
00:14:10,410 --> 00:14:13,340
the inside so I can actually do the matrix
multiplication.

202
00:14:14,880 --> 00:14:17,290
So, inner product gives me a scalar value.

203
00:14:17,290 --> 00:14:19,649
An outer product gives me a matrix like
this.

204
00:14:26,500 --> 00:14:30,160
And some useful facts about matrix
multiplication so each column

205
00:14:30,160 --> 00:14:33,770
of AB is a linear combination of the
columns of A.

206
00:14:35,670 --> 00:14:38,630
So if I look at A times the column of

207
00:14:38,630 --> 00:14:41,940
B this is exactly the same thing I was
doing.

208
00:14:41,940 --> 00:14:45,160
When I was multiplying a matrix times a
vector, and I said that I could

209
00:14:45,160 --> 00:14:50,000
interpret that using my column picture as
a linear combination of the columns of A.

210
00:14:51,380 --> 00:14:51,590
And so

211
00:14:51,590 --> 00:14:55,470
that gives me each column of the product
is going

212
00:14:55,470 --> 00:14:58,550
to be a linear combination of the columns
of A.

213
00:15:02,480 --> 00:15:08,300
And then I can get a similar result So the
rows of the product, so the row i of

214
00:15:08,300 --> 00:15:13,820
AB, the rows of the product are going to
be linear combinations of the rows of B.

215
00:15:15,850 --> 00:15:19,160
So here, this is, this is sort of how I
want to think, think about it.

216
00:15:19,160 --> 00:15:23,650
I take one row of i and that's, or sorry,
one row of A.

217
00:15:23,650 --> 00:15:28,650
And that's going to give me the
coefficients for the rows of B.

218
00:15:28,650 --> 00:15:35,638
They give me row i of AB.
And so then laws

219
00:15:35,638 --> 00:15:43,080
for matrix operations.

220
00:15:43,080 --> 00:15:44,520
We get a commutative law.

221
00:15:44,520 --> 00:15:48,360
So for addition we have A plus B is equal
to B plus A.

222
00:15:48,360 --> 00:15:50,230
And you can show that with just the same
arguments

223
00:15:50,230 --> 00:15:53,060
that I did for vectors because it's
defined entry wise.

224
00:15:54,680 --> 00:15:58,250
I get a distributive law, so if I take the
sum

225
00:15:58,250 --> 00:16:03,130
of A plus B and scale that by scaler value
c.

226
00:16:03,130 --> 00:16:08,390
Then that's equal to A scaled by that
constant and plus B

227
00:16:08,390 --> 00:16:09,660
scaled by the same constant.

228
00:16:11,560 --> 00:16:17,280
I get an associative law for addition, so
it doesn't matter if I want to add A+B+C,

229
00:16:17,280 --> 00:16:22,180
I can add B+C first or I can add A+B
first, I'm going to get the same answer.

230
00:16:24,300 --> 00:16:27,660
For multiplication it's a little bit
trickier.

231
00:16:27,660 --> 00:16:33,190
So I get left distributive law so if I
have C times

232
00:16:33,190 --> 00:16:38,100
A plus B that's equal to C times A plus C
times B.

233
00:16:40,690 --> 00:16:46,420
I get a right distributive law So A plus B
times C

234
00:16:46,420 --> 00:16:50,560
is equal to AC plus BC and the important
thing ops the

235
00:16:50,560 --> 00:16:56,190
important thing to keep, keep track of
here if is C comes

236
00:16:56,190 --> 00:17:00,620
first, it has to always come first when
I'm doing this distributive operation.

237
00:17:01,690 --> 00:17:04,000
If the A and B come first.

238
00:17:04,000 --> 00:17:05,820
Then the A and B have to

239
00:17:05,820 --> 00:17:08,180
come first when I'm doing this
distributive operation.

240
00:17:11,180 --> 00:17:15,000
And then I also get an associative law, so
if I want to calculate the product of

241
00:17:15,000 --> 00:17:20,300
three matrices, A plus, or, A time B times
C, they have to be the right dimensions.

242
00:17:20,300 --> 00:17:25,420
So The number of columns of A has to equal
the number of rows of B.

243
00:17:25,420 --> 00:17:27,920
And the number of rows of B has to equal
the number of.

244
00:17:29,450 --> 00:17:29,630
Sorry.

245
00:17:29,630 --> 00:17:32,670
The number of columns of B has to equal
the number of rows of C.

246
00:17:34,090 --> 00:17:35,130
I think I got that right.

247
00:17:36,522 --> 00:17:42,340
and, but if I can do those operations then
it doesn't matter what order I do them in.

248
00:17:42,340 --> 00:17:46,750
So, I can do The product BC first and then
multiply that by

249
00:17:46,750 --> 00:17:50,550
A or I can do the product AB first and
multiply that by C.

250
00:17:54,000 --> 00:17:59,530
So one law we don't get is a commutative
law for matrix multiplication

251
00:17:59,530 --> 00:18:05,650
so almost all the time A times B is not
even equal to B times A.

252
00:18:05,650 --> 00:18:06,780
And it's even worse than that.

253
00:18:07,840 --> 00:18:13,450
So, if p is not equal to m, so remember A
is an m by n matrix, and

254
00:18:13,450 --> 00:18:19,240
B is an n by p matrix, if p is not equal
to m, then I can't

255
00:18:19,240 --> 00:18:21,610
even do this operation, because the
dimensions

256
00:18:21,610 --> 00:18:23,360
won't line up when I switch the order.

257
00:18:26,690 --> 00:18:31,830
If both A and B are m by n matrices,
sorry,

258
00:18:31,830 --> 00:18:36,970
if A is m by n and B is n by m, then

259
00:18:36,970 --> 00:18:41,939
if I do the product AB I'm going to end up
using these outer dimensions.

260
00:18:44,370 --> 00:18:49,440
When I do the product BA, now the outer
dimensions are going to be n and n.

261
00:18:49,440 --> 00:18:54,960
So AB is an m by m matrix.
BA is an n by n matrix.

262
00:18:54,960 --> 00:18:56,570
So these things, they can't be equal

263
00:18:56,570 --> 00:18:58,670
to one another if they have different
dimensions.

264
00:18:59,860 --> 00:19:02,060
So, for equality, they have to be the same

265
00:19:02,060 --> 00:19:04,540
dimension and then each entry has to be
equal.

266
00:19:09,520 --> 00:19:13,510
And then when we have square matrices, so
if we have n by n matrices, at

267
00:19:13,510 --> 00:19:17,970
least I can do the products and they'll be
the right size.

268
00:19:17,970 --> 00:19:23,782
But suppose I let A equal 0,0,1,0

269
00:19:23,782 --> 00:19:29,666
and B equal 0,1,0,0.
So if I do this product AB ops- product

270
00:19:29,666 --> 00:19:35,068
AB that gives me 0 0 0 1.
But if I do the product BA, I get

271
00:19:35,068 --> 00:19:36,690
1 0 0 1.

272
00:19:36,690 --> 00:19:41,730
So even when I can do it and they're the
right size, you're still not

273
00:19:41,730 --> 00:19:45,990
guaranteed to get the same answer if I do
the multiplication in the opposite order.

274
00:19:51,130 --> 00:19:53,200
So one exception to this rule,

275
00:19:55,870 --> 00:20:01,270
so this is a constant c, a scalar value.
And this

276
00:20:01,270 --> 00:20:06,480
is the identity matrix, yeah.
It's kind of hard to see with this font.

277
00:20:06,480 --> 00:20:12,350
So, one matrix that always Commutes is the
identity matrix.

278
00:20:12,350 --> 00:20:15,880
And so, if it's scaled by a constant
value, that will also commute.

279
00:20:15,880 --> 00:20:21,200
So, if you have a identity matrix times
something, and they're square,

280
00:20:21,200 --> 00:20:23,360
then you can switch the order of that
multiplication.

281
00:20:23,360 --> 00:20:23,860
And

282
00:20:27,960 --> 00:20:30,660
then one more thing that I want to
mention, just because

283
00:20:30,660 --> 00:20:34,500
I don't know really where else it fits in,
matrix powers.

284
00:20:34,500 --> 00:20:36,920
So a power of a matrix if I tell, talk

285
00:20:36,920 --> 00:20:40,620
about A squared, then A needs to have the
right dimension.

286
00:20:40,620 --> 00:20:42,329
So basically it needs to be a square
matrix.

287
00:20:45,860 --> 00:20:51,150
if I have A squared times say A cubed
that's equal

288
00:20:51,150 --> 00:20:56,220
to A to the fifth power so these behave
just like numbers would and if

289
00:20:56,220 --> 00:21:01,350
I have say A squared and that quantity
cubed that's equal to A to the sixth.

290
00:21:03,110 --> 00:21:07,520
And then if I talk about A to the 0,
that's going to be equal to 1.

291
00:21:07,520 --> 00:21:11,680
And 1, when I'm talking about matrices is
the identity matrix.

292
00:21:11,680 --> 00:21:14,660
>> Did you say that A had to be a square
matrix for that to work?

293
00:21:14,660 --> 00:21:16,210
Because I, I was writing down.

294
00:21:16,210 --> 00:21:19,840
>> Well because you can only multiply A
by A, if it has the

295
00:21:19,840 --> 00:21:22,740
same number of rows and columns, so that
means it has to be square.

296
00:21:24,530 --> 00:21:24,760
Okay.

297
00:21:24,760 --> 00:21:25,260
[COUGH]

298
00:21:28,110 --> 00:21:32,820
Then, I can also do something called
putting a matrix into block form.

299
00:21:33,820 --> 00:21:36,670
So here I have a matrix with four rows and
six columns.

300
00:21:37,730 --> 00:21:41,130
And then I'm going to break it into six
blocks, and

301
00:21:41,130 --> 00:21:44,460
each block is going to be a two by two
identity matrix.

302
00:21:44,460 --> 00:21:47,700
So I could also write A like this, so
these

303
00:21:47,700 --> 00:21:52,850
are just six identity matrices, they're
all two by two.

304
00:21:56,980 --> 00:22:01,470
And then if I make these blocks the
correct size, I can do.

305
00:22:01,470 --> 00:22:04,160
Block multiplication following the same
rules

306
00:22:04,160 --> 00:22:06,360
that I would do for matrix multiplication.

307
00:22:06,360 --> 00:22:11,240
So if I have a matrix, A, that I can split
into four blocks like this,

308
00:22:12,830 --> 00:22:17,350
then when I want to figure out what the
product of this matrix is, I can do

309
00:22:17,350 --> 00:22:22,140
the, the product block-wise.
So I just was Just pretend like these

310
00:22:22,140 --> 00:22:23,100
are values.

311
00:22:23,100 --> 00:22:28,480
It would be A11 times B11 plus A12 times

312
00:22:28,480 --> 00:22:31,300
B21 which is exactly what I end up with
here.

313
00:22:31,300 --> 00:22:35,960
So, it's the same formula for matrices,
except now I'm talking about blocks

314
00:22:35,960 --> 00:22:41,139
of matrices, or sorry, blocks, which are
kind of sub matrices of a matrix.

315
00:22:43,180 --> 00:22:45,380
And the only caveat here is you have to
define

316
00:22:45,380 --> 00:22:48,540
your blocks so that all of these
operations are permitted.

317
00:22:52,010 --> 00:22:55,490
And the reason I want to do this is it
lets me do one last

318
00:22:57,580 --> 00:23:03,570
clever thing, which I can also now define
matrix multiplication in

319
00:23:03,570 --> 00:23:07,500
terms of columns, so I can get a sort of
column space.

320
00:23:08,600 --> 00:23:15,780
So my first definition was rows of A times
columns of B, if I make my blocks the

321
00:23:15,780 --> 00:23:22,009
columns of A and the rows of B and then I
use this rule here, what I end up with

322
00:23:22,009 --> 00:23:22,509
[INAUDIBLE]

323
00:23:25,580 --> 00:23:31,470
Is a column of A, times a row of B.
But if I have

324
00:23:31,470 --> 00:23:37,370
a column times a row, that was an outer
product, so that's actually a matrix.

325
00:23:37,370 --> 00:23:43,560
And it turns out that, what I end up with,
are n matrices.

326
00:23:43,560 --> 00:23:48,790
So here, ai, bi, is an outer product, so
that's a matrix.

327
00:23:48,790 --> 00:23:50,490
I have n matrices like this,

328
00:23:50,490 --> 00:23:55,380
one from each row-column, or, column-row
combination here.

329
00:23:55,380 --> 00:24:00,260
And then I add up those n matrices, and
that will also give me this product, AB.

