 In this video, I wanna start introducing vocabulary and operations that are unique to matrices that don't have a counterpart when you talk about them for vectors. So the first idea is about the diagonal entries of a matrix. So the diagonal entries in an in-by-in matrix, let's say A is given as the I, whose generic entry is AIJ there. The diagonal entries are gonna be those entries whose indices are identical. So we want the A11 position, the A22 position, the A33 position. That is all of the numbers of the form AII. These are called the main diagonal of your matrix. And so if we have a matrix, let's say like one, two, three, four, five, six, seven, eight, nine, 10, 11, 12, to be very, very creative right there. The main diagonal is gonna be those entries right here because this right here would be the one, one position. This is the two, two position. And this is the three, three position. So one, six, and 11. This would be considered the main diagonal of the matrix. Another vocabulary term here. If a matrix has as many rows as columns, so it's an in-by-in matrix, we say that this is a square matrix. And that's because when you draw it, of course you're going to have the same number of rows and columns. So it looks like a square. So to take the example we have right here, if I just take off to say the last column and then draw it again, this is now an example of a square matrix. And then lastly, we're gonna introduce a notation here. We're gonna say I, I sub n. This is gonna denote the in-by-in matrix whose has eyes along the main diagonal and zeros everywhere else. So as an example of such a thing, if you take I one, this would be the matrix with just a one. And really a one-by-one matrix is really indistinguishable from just a scalar. But I do wanna mention it here. It is an example of a square matrix. I two would be the matrix one, zero, zero, one. I three would be the matrix one, zero, zero, zero, one. Like so you can keep on going with the idea. And these, and so the matrix does depend on the subscript I right there. And these are referred to as the identity matrices. The one-by-one identity, two-by-two identity, three-by-three identity are illustrated on the screen. We could do four-by-four, five-by-five, et cetera, right? It gets the name, the identity matrix because it'll be the multiplicative identity of the matrix multiplication, which we will introduce very shortly. But I do wanna mention in general that if you take the matrix I n, this will actually be the sum of E one one plus E two two plus E three three all the way down to E nn. Where these E, these Eijs here are the unit matrices that we introduced in the previous video here. So I keep on talking about it. We finally should get to it. Let's talk about the idea of matrix multiplication. What does it mean to multiply together two matrices? Well, we are capable of multiplying a matrix A by a vector. And it turns out, and since matrices are themselves the sets of vectors, we can actually extend the matrix vector product to form a matrix multiplication, a matrix product. So let's say we have two matrices. A is an M by N matrix and B is an N by P matrix. Notice here that the number of columns in A is equal to the number of rows in B. In order for a matrix product to be defined, we do have to have this compatibility condition. The number of columns in the first matrix has to equal the number of rows in the second one. But it is not required anything about the rows of A or the columns of B. We need that the columns of A has the same number as the rows of B. Now let's also say that B has the form of the following where the column vectors are given as B one B two all the way up to BP. So now the matrix product A times B. So since B, we know the column vectors, we can express it like this. What we're gonna do is we're gonna basically think of it the following. We're gonna distribute this matrix A onto all of the columns of B and therefore we define the matrix product A times B as the matrix whose first column is A times B one, whose second column is A times B two, whose third column would be A times B three all the way up to whose final column, whose P column would be A times BP. Now notice this matrix, this product, this is a matrix and this matrix will be an M by P matrix where M was the number of rows that A has and P with the number of columns that B has. So basically that number N, which was the number in the middle, it kind of cancels out and so to speak. The way I like to think of it the following, if you take an M by N matrix and you times it by an N by P matrix, well, if the numbers in the middle are the same, they kind of disappear and you end up with an M by P matrix when you're done. That's the general rule when it comes to matrix multiplication. And to clarify that, the fact that we have P mini columns should be very clear because we have A times B one, A times B two all the way up to A times BP. You do this for each column of B so you're gonna get P mini column vectors when you're done. But why do we have M mini rows? Well, that comes back down to this matrix product matrix vector product we had done previously, right? So remember how this was defined. This is going to equal the linear combination where you take B one one times the first column of A, A one. Then you're gonna take B one two times A two and then you do this all the way up to B one. Let's see there was N mini columns and then A N. So you get this linear combination to expand the vector A B one. You'd add these things together. But these are the vectors, these vectors right here A one A two up to A N. These are column vectors of A. So how many entries will there be in those vectors? There will be M mini entries. So this vector A B one would belong to the vector space F M. And that's gonna be true for each of these column vectors. And there's P mini of them. So we get this M by P matrix. Now in the case of a square matrix, so A is N by N, then if you have a square matrix, you could actually take A times A. Cause you have an N by N times an N by N that product would be N by N. So you could talk about having an A squared. But you could also talk about A times A times A, which would give you A cubed. Cause every time you multiply A by another A, you're still gonna be an N by N. And so we can talk about the generalized exponent, the power of a matrix here. So for example, A to the K for some natural number N, sorry, natural number K, we can define A to the K, which just means A times A times A times N, you do it K times. We will also include the definition that A to the zero is equal to the identity. And this is from the fact that if you take a number and raise it to the zero power, that's supposed to equal one, where one is the multiplicative identity. We're kind of alluding to the fact that this is gonna be our identity matrix. So we're gonna use that. Now, so we define matrix multiplication by extending the vector matrix product we saw before. But another way that we like to define matrix multiplication is sort of the following. Let's not describe it as column vectors. Let's describe it as individual elements. So if you take A times B, what's a generic entry in that matrix? And what you're gonna do is the generic entry, the IJ position, is you're gonna take, and so if I can try to make this to make sense, you're gonna take the ith row of A and you're gonna multiply it by the jth column of B. And we'll see a specific example what that means. And that's where we get this thing right here, this AI1 times B1j plus AI2 times B2j plus AI3 times B3j all the way up to AIn times Bnj. So you take all the possible combinations. So you're gonna take the first entry of the, you're gonna take the first entry of the first row of A and you're gonna times that by the first entry of the first column of B. Again, this will be much more precise in a moment what this formula looks like. And this is often referred to as thinking of linear matrix multiplication as by the dot product or the inner product, something we'll define later in our series. I often like to refer to this as the finger multiplication method, because again, this will be much more clear when we have a specific example. So let's actually look at the original definition of matrix multiplication. Then we'll get to this finger multiplication just a second. So notice that A is a two by three matrix and B is a three by three matrix. So this matrix multiplication will be compatible and we would anticipate that A, it's gonna be a two by three matrix, grabbing the first number here and the last number right here. So we expect a two by three matrix. By definition, the three columns of A times B will be A times the three columns of B. So we're gonna get this right here times A, we're gonna get the second column of B times A and then the third column of A times, third column of B times A, which we see right here. Now, if we were to expand these things, what happens exactly? Well, if you take the first one, for example, if we go through the definition of matrix vector product, this should look like nine times, I can't see A anymore, this should look like nine times two zero, then you're gonna get three times one four and then you're gonna get negative two times negative one, negative two. For which when you add those things together, you're gonna get an 18 plus three plus two as the first entry and then for the last entry, you're gonna get zero plus 12 plus four, like you see right here and right here, okay? And so that's what A times B one would look like. We would do a similar thing for A times B two right here. Let's see the original matrix. So we're gonna take negative five times two zero, we're gonna take nine times one four and we're gonna take four times negative one, negative two. And so when you look at those linear combinations, you're gonna produce numbers that look like this right here. So notice you got two times negative five over zero times negative five, then you're gonna get one times nine over four times nine. Then you're gonna get negative one, excuse me, yeah, negative one times four over negative two times four. So you work this thing out. But a way to kind of simplify it, I mean, so it is good to think of in terms of linear combinations, but one method that might simplify it a little bit is if you take like the first row of A and you times it by the first column of B and you think of it as like you're running your finger over this row and then you run your finger over this column right here and you multiply together the things that are in corresponding position. So two times nine, you're gonna add that to one times three and then negative one times negative two. So that's how you get the one one position, the first row times the first column. The next thing is to take the first row times the second column. So you're gonna get running your finger along this one and then down this one, you're gonna get two times negative five, you're gonna get one times nine and you're gonna negative one times four like so. That's gonna be the one two position of A times B. To get the one three position, you take the first row times the third column. So you're gonna get two times negative three plus one times one plus negative one times six. That gives you the first row of A times B. Now we're gonna take the second row of A times B as R of A and times it by the first column of B. So running your finger along this row and then this column right here, you are gonna get zero times nine plus four times three plus negative two times negative two. Then take the second column times, sorry, the second row times the second column, I'll give you the two two position. You get zero times negative five, four times nine and negative two times four like so. The next one, then we're gonna take the second row times the third column to get the two three position, zero times negative three, four times one and negative two times six. And so you get all six possibilities by looking at the combinations of two by three, that the two rows by the three columns of the matrix. Now you simplify these things of course. So for example, two times nine is 18, one times three is three, negative one times negative two is going to equal positive two. You get 18 plus three plus two, which is equal to 23. That gives you the one one spot. The one two spot, you take negative two times negative five which is negative 10, one times nine which is nine, negative one times four which is negative four. You add those together and you're gonna end up with negative five and you do that for the other remaining positions. I'll let you kind of fill in the rest of the arithmetic. This is how one computes the matrix product between two matrices right here. And we can transcend this, right? Because we can add matrices, we can scale matrices and we can take products of matrices. This means that in certain situations we can actually evaluate a polynomial out of matrix. What do we mean by that? Well, if you have a polynomial, a polynomial will have coefficients. These are just scalars. You're gonna have powers of your variable X. So you have to have exponents. You have to be able to multiply your variable by a scalar. So scalar multiplication. And you have to add together these different monomials. That just means addition. So if you have exponents, addition, and scalar multiplication, you can do polynomials. So if you have a square matrix that is, it's n by n. An n by n matrix, you can take exponents of it like we talked about before. And so that means you could evaluate a square matrix by a polynomial P of A. In which case for the constant term, you're gonna take A zero times the identity. Then you're gonna take, you'll add that to A one times A plus A two A squared plus A three A cubed all the way up to A M times A to the M. And this is an example of a so-called matrix polynomial. It uses scalar multiplication, addition of matrices and exponents of matrices, which is just matrix multiplication here. So let's take the two by two matrix four two zero three and we'll say the scalars live over Z five. So we're gonna reduce mod five and let's take the polynomial X square plus three A plus two. So what does it mean to evaluate the polynomial at the matrix A? Well, everywhere we see an X we're gonna replace it with the matrix A. Now in the terms of the constant position, we have to put the identity because we can't add two to a matrix. How do you add two to a matrix? Well, we can add two times the identity and that's what we want right there. So what does this mean? Okay, A given right here four two zero three we're gonna square this matrix we'll do in a moment. We have the times A by three and we have the times the identity by two. The scalar multiplication is gonna be pretty easy. If we times everything by A by three we're gonna get three times four which is 12 which reduces to two mod five. You're then gonna get three times two which is six which is congruent to one mod five. Three times zero which is zero and then three times three which is nine that reduces to four mod five. If we times the identity matrix by two you're gonna get two zero zero two no reduction was needed there. How about A squared? How does one do that calculation? What that means is we take the matrix four two zero three and we're gonna multiply it by four two zero three. And so we're gonna do our finger multiplication take the first row times the first column. That's gonna give us four times four which is 16. 16 reduces to one mod five. Next we're going to get plus zero which that adds up to be a one. Next we're gonna take the first row times the second column. You get four times two which is eight eight is the same thing as three and then you're gonna get two times three which is six which reduces to one mod four three plus one is equal to four. Next we're gonna take the second row of A times the first column of A. You're gonna get zero plus zero that adds up to be zero. Next you're gonna get zero plus nine. Nine is the same thing as four mod five and so therefore you get four and that's where this A squared came from. Now if we add these things together you're going to get one plus two plus two which is five which reduces to zero mod five next you're gonna get four plus one plus zero which is also five and thus reduces to zero. You're gonna get zero plus zero plus zero which gives you a zero and then lastly you're going to get four plus four plus two which adds up to be 10 which 10 also reduces down to zero right here. And so this is that one could evaluate a matrix polynomial. Kind of interesting here we evaluated this polynomial and got the zero matrix. So in some regard you could say that this matrix is the root of this polynomial. This is a topic we might talk about a little bit more about in the future but I wanna show you in this example how we can do matrix multiplication and then combining that with addition and scalar multiplication we can actually evaluate any polynomial expression on a matrix.