 Hi, I'm Zor. Welcome to a new Zor education. I would like to continue talking about matrix multiplication. In this case, after two introductory lectures about multiplication of two by two square matrix and three by three square matrix, I would like to talk about general multiplication of matrices. Well, sometimes people just give the definition of what is the product of two matrices, and then they investigate the properties, like for instance, associativity and some others. I have chosen a different approach, starting from matrices as representation of linear transformations and from approaching product of two matrices as a composition of linear transformations. So basically my most important goal was to define something like this. So if I apply matrix A to a vector and then I will apply another linear transformation reflected by the matrix B by the result of the first one, then matrix product is defined as a transformation matrix, which does with the vector B exactly the same thing as the composition. I think this is a much more natural approach and from seeking this type of relationship, I have defined the product using certain rule basically. It seems to me it's more natural, but now whatever the formula I have derived by basically trying to fulfill this particular requirement in some small cases, like two by two and three by three, now I will just use the same formula as a definition, because now it seems to be much more natural to accept this as a definition of the product of two matrices, rather than just start from this definition without any explanation, without any foundation, etc. So now let me get back to the formula, which I was basically talking about. So if my matrix A is having elements lower case A, now these are indices and index K is from one to K and index M is from one to M. Now matrix B contains B lower case elements with dimensions. This one is the same from one to capital M and N is from one to capital N. So basically matrix A has dimension K by M, K rows and M columns and B has M rows and M columns. So I am defining my multiplication of two matrices which have one and only one requirement that the number of columns here is supposed to be the same as the number of columns there. Then I can define the multiplication of A times B. I don't need this anymore, plus it might be confusing because there I was multiplying B times A, which is not the same thing. So I am defining multiplication of matrix A by matrix B, where A I am defining as a left component in the multiplication and B as the right component in the multiplication. So again the only requirement is the number of columns in A should be number of columns in A supposed to be equal to number of rows in B. Now why is it supposed to be that way? Well if you remember for C elements i, j I had the formula i's roll from the matrix from the left matrix and i's roll vector I was using this notation A i star. Star means all elements in the i's roll and it's actually a roll vector. The length of this vector is equal to the number of columns, right? Multiply by B star j, which is a j's column vector. So it's a j's column. So all the elements of the j's column are supposed to be basically elements of the vector B. And this is a scalar product of two vectors. Now if I'm using a scalar product of two vectors I can only do this if the dimension of both vectors is the same. Remember if you have a vector A1, A2, A3 and the vector B1, B2, B3 then their scalar product would be C1, C2, C3 where C first is equal to where C i is equal to A i times B i where i is one or two or three. So the number of elements must be the same otherwise I would not be able to form the scalar product. So this is the reason why the number of columns in the A matrix is supposed to be equal to the number of rows in the B. Because the number of columns in A is exactly the dimension of the row vector, right? So if A is a matrix then each row vector, which is this one, has dimension equal to the number of columns. Now in case of a B where I'm using the column vectors the dimension of any column vector is number of rows. So that's why they're supposed to be the same and that's why I'm using the same letter here and here. And after I've done that I'm defining this matrix C in exactly the same way as I did it for two-dimensional case and two-dimensional case. And the only thing which I have to say is that I should change from one to K and J should change from one to N. So since the number of row vectors which is number of different A I stars is equal to the number of rows in the matrix A. So the first index I must be within this interval, number of rows in the A matrix. And since the number of different B star J's and B star J is J's column so the number of different columns is basically the number of columns in the B which is N. So that's why I have it here. So that's why C has a dimension K times N. So you multiply K times M dimension K rows M columns. You multiply it by a matrix with M rows and N columns and M is in the middle and it's equal and K and N are on both sides and these will be the dimensions of the result. So this is basically a definition. So the definition of the product is a new matrix which has dimensions K by N and each element of this matrix is calculated according to this formula. So I'm just using exactly the same formula, exactly the same expressions which I was using in two particular cases before, two by two matrices and three by three matrices. And I'm just generalizing it for everything. Okay, now using this type of a definition I can view certain things which I was doing before from the viewpoint presented in this matrix multiplication. I can view many different things as a particular cases of matrix multiplication. For instance, my first example is a scalar. Now a scalar is just a number, right? Now any number, let's say A, any number I can actually consider as a matrix with one and only one element is one by one matrix, one row, one column. Well, nothing prevents me from this, right? According to my definition of the matrix multiplication I can only multiply this by something which has dimension one times N, right? So my number of rows which is number of columns which is one should be equal to number of rows which is also one. Now, but this is not really fixed which means what is this? Well, let's take a look at this. Sometimes N means one row and N columns, right? So it's like A1, A2, etc., AN. Now what is it? Well, this is a vector. So any vector I can consider to be a matrix of the dimension of one row and N columns where N is a dimension of the vector. And what's interesting is what if I multiply this matrix by this matrix? Well, according to the rules the multiplication of, let me call this K. So this is K and this is A, alright? Matrix A. So the multiplication of K times A, this is what? This is multiplication of matrix K by matrix A1, A2, etc., AN, right? Now the result would be dimension one times one and this is one times N. So result would be one times N. Let's call it B1, BN. Now, according to the rules, B, I, J, where I is one, only one actually and J can change from one to N should be equal to AI star times, sorry, K. First is K. K I star times A star J. So I's row vector and J's column vector, where I should be from one to one, right? Because that's the number of rows here, the number of columns here. K is from one to N, that's number of columns here. Now, K I star is supposed to be a vector. Now what's the dimension, number of columns in the I's row of this matrix? Now, but this matrix is one by one. So there is only one dimension here, there is only one element in this scalar product. And only one element in this product, because there is only one row here, right? So basically it's only N's element, this is equal to K times AJ, that's what it is. And this is actually, since BIJ and I is equal to one only, so this is actually BI on the left. So what is this? This is a multiplication of a vector, this vector by a constant K. So what my point is, that multiplication of a vector by a constant is just a particular case of the multiplication of matrices. Right? Now, what else? How about scalar product? Well, basically the same thing. Let's say you have vector A1A, well, let's use letter M in this particular case. This is a vector and this is another vector, B1VM. Now what I will do, I will use this as a row vector which is actually a matrix with one row and elements from A1 to An. Now this, I will write it differently. I will write it also as a matrix but as a column matrix, column row. This is just another representation of the vector, right? Vector can be either one times M, this is M by the way, one times M matrix which is this, or I can write it vertically. It doesn't really matter how I write a sequence of M, an ordered set of M numbers, I can write it vertically as well. If I write it vertically, that would be M times one. It would be M rows and one column, right? So if I multiply matrix one by M times matrix M by one, I will get matrix one by one. Now what is matrix one by one? It's a scalar, right? So my scalar product actually can be expressed by multiplication of this matrix by this matrix. Why? In exactly the same rule. I have row, I have to scalarly multiply by a column. So A1 times B1, etc., up to An by Bm. So the scalar product A by A by B is exactly the same as matrix product of A1 An times B1 Bm M. I should use M, not M here. So the matrix multiplication of these two matrices which both represent actually vectors of the same dimension M. Is their scalar product. It's from the definition of the matrix multiplication. So scalar product I also can view as a matrix product of two matrices. One is of this dimension, one times M and another is this dimension M times one. So not only multiplication of matrices which are really tables, certain number of rows and certain number of columns can be actually researched, but also things can be viewed from the matrix perspective which we viewed from different angles before. So vector is also a matrix. It just has only one row or one column. And even scalar is or this can be considered as a matrix with one row and one column. So matrices are more general instrument in mathematics. And we can use rules applied to the matrices in general to all particular cases including scholars and vectors. Now what else I wanted to talk about matrices. Alright, how about multiplication of matrices which are not really square. Now you remember that I started from two by two matrix and actually two by two matrices and two three by three matrices. And I was interpreting them as transformations, linear transformations. And then I basically defined their product. Now the general definition which I gave before didn't really contain this particular requirement that the matrices should be square. Any matrices can be multiplied as long as the left matrix has the same number of columns as the right matrix has the number of rows. Now let me give you an example when a linear transformation actually involves not the square matrix but just a matrix with different number of rows and columns. Now for this I would like you to take a look at the linear transformation itself. Now what is a classical linear transformation I was using let's say in two dimensional case. v1 was equal to a11u1 plus a12u2 and v2 was equal to a12u1 plus a22u2. Now how can that be viewed? Well it can be viewed very easily. Now matrix of two rows and one column which is actually a column vector v is equal to a matrix multiplication by the matrix of its coefficients, the matrix of transformation as we see by a vector u1, u2 which is a column vector and matrix again. This has a dimension 2 times 1, right? Two rows one column, this is 2 by 2 and this is also 2 by 1. So if I multiply 2 by 2 by 2 by 1, the middle ones are the same number of columns here and number of rows there and the outside are the resulting dimension 2 by 1. So everything is fine. Now let's find out how this is supposed to be multiplied. Well again my formula is equal to ai star times u star j, right? That's my general formula. So let me just write down as two individual formulas basically because I have only two elements in the matrix vij because i is changing from 1 to 2 and j is equal to 1 and only 1. So I have v1 and I don't even want to write the second index because it's always 1 anyway and v2. Now what is this? Now this is i is equal to 1 so this is i1 star times u star 1 and this is a2 star times u star 1, right? The second coefficient is 1 here and here so that's why it's 1 here and I didn't really have to write it down. Now what is this? Well this is on the right, this is the first column with different rows. Different rows are 1 and 2, right? Now this is the first row a11 and a12 so we multiply the first row by the first column which is equal to 1, a11, u1, first times first plus a12, u2. In this case we are multiplying the second row by the first column and only. So the second row is this, the first and only is this and scalar multiplication are first times first and second times second. So we have our equations, right? So this is a matrix representation of this particular system of two equations or transformations. So linear transformation from u to v is actually a multiplication by a matrix. But now I was talking about multiplication by matrices which are not really square. In this case it's a square with two-dimensional u we transform into two-dimensional v. Well, can there be any transformations which are not square? Well, yes, but let's just make a very interesting example. And the game example is very real and that's why I think I like it. I mean I can obviously have some very abstract example, something like I will take the matrix 1, 2, 3, 4, 5, 6 which is 2 times 3 and multiplied by matrix 7, 8, 9, 10, 11, 12 which is 3 by 2. So 2 by 3 times 3 by 2. The middle ones are the same and the outer ones would be a dimension of new matrix. So it would be something like a, b, c, d and I can calculate a, b and c and d just using the formula. Like a for instance which is an element of first row and first column. So it's first row and first column. 1 times 7 which is 7 plus 2 times 9 is 18 so it's 25 plus 33, 50, whatever, 8. So a is equal to 58. I mean I can do these manipulations but that's not interesting because they don't really have any more substantial things behind them. But I'm going to do just as an example of linear transformation which is reflected in a non-square matrix is the following. Let's have the matrix this. And I will multiply it by, now this is what? 2 by 3, right? 2 rows, 3 columns. I will multiply it by this vector. What will I have? Well in theory from, now these number of columns here is equal to number of rows. But number of rows here and number of columns there would be a dimension of the vector which I will receive. So I will receive a two-dimensional vector, right? Let's put it a, b. Two-dimensional column vector by the way. It's 2 rows and 1 column. Now what is a? Well a is an element 1, 1 which means first row times first column. Which is 1 times x which is x, 0 and 0, nothing more. Now what's the b? b is second row first column. So it's second row first column which is 0 times x plus 1 times y which is y and 0. So here I have x and y. So multiplying vector x, y, z times this matrix, vector considered as a matrix actually. So the column vector I multiply on the left with this particular matrix and I'm getting this. Now what is this transformation of x, y, z into x, y? Well let's just think about it. If you have a three-dimensional space and here is your vector which has coordinates x, y and z. Now you drop down the perpendicular onto the x, y plane, right? So if this is p, this is q. q is a projection of the point p. And it has projections here. I prefer z to have on the top in this case. So this is y, this piece and this piece is x. And the vertical thing is z, right? So from x, y, z I get only x, y. So this particular transformation transforms this vector into its projection on the x, y plane. So my point is that if transformation matrix is non-square, then we are changing the dimension actually. We are changing from three-dimensional vector to two-dimensional vector on the plane which is a projection. So this is a projection. If you remember I gave you some examples when you can have a matrix which like stretching for instance by the factor of k, that would be a square matrix with k on the diagonal. Or something like a reflection, then some of the coefficients were equal to minus one or whatever. Well this is just an example of a non-square matrix which not only does something, but also it just projects the three-dimensional vector onto two-dimensional space. That's what's very important. And the last thing which I wanted to mention is the following. Now you remember that I started explanation about matrix multiplication by requiring that this be equal to this. So the transformation by matrix A and then consecutively transformation of matrix B would be the same as if I will multiply B times A and then apply this as a matrix of transformation to it. That's how I started. Now what is this? This is basically associative law because forget about application of matrix of transformation to the vector. This is, as I was just showing before, a real multiplication. And this is also a real multiplication. And this is also a multiplication. So whenever I'm saying that we have a transformation reflected by a matrix and this transformation is applied to the column vector. So I can replace right now all these words like transformation which is reflected by a matrix and the transformation is applied to the vector and the equations I was writing where matrix are the coefficients actually is the reflection of this transformation. I can basically replace all this with saying, okay, we are multiplying matrix A by column vector x. Or then matrix B we apply by a product of matrix A and column vector x. Or in this case we are multiplying B and A and the result we are multiplying by x. Now what is this? This is an associative law. The only thing in that particular case associative law was applied only when two matrices were square and this matrix is actually a column vector. So in a two and three dimensional cases which I was basically starting my multiplication agenda. I was using this particular case of associativity when this is a column vector and these two are square matrices, two by two or three by three. But in general the definition which I was just making before, the definition of the product of any two matrices is associative. And this is one of the properties which I am going to discuss in the next lecture. So that's how I am preparing for the next lecture actually. So that's it for today. I do recommend you to go to Unisor.com and the comments for this particular lecture contain basically the material which I am explaining. And don't forget that if you register you can take exams and you will need the supervisor who will enroll you into certain topics. Or you can yourself be a supervisor just signing with a different name and different role as a parent or supervisor. Alright, so that's it for today. Good luck. Thank you very much.