Practical lesson 1. The operations on matrices
Let’s work out the operations on matrices introduced at the lecture.
Let’s start with this task. Two matrices are given, we calculate their product, and, as we know, the product operation is not commutative in general, so we can formally write two products A by B and B by A. However, it is not obvious that we will be able to find these products.
Let’s remember what conditions are necessary in order to be able to multiply two matrices. Matrix A has a size of 2 by 2, matrix B has a size of 3 by 2. In order to multiply the matrices, the number of columns in the first matrix must be equal to the number of rows in the second matrix. So, you can’t multiply A by B. We simply won’t be able to apply the specified scheme. But we can already multiply B by A since B has two columns, and A has two rows. So, let’s find the product of B by A.
Let’s write the matrices A by B and calculate the elements of the product. So, we take the first row in the matrix B, which we have written in the first place and the first column in the matrix A. Multiply the row by the column. 2*(-7)-14 + 3 = -11. Then we multiply the first row by the second column: 2*1+ 2*3 =8. And the second line similarly. The second row is multiplied first by the first column, so here is a zero, so you need to multiply only one by one, you get 1. The second row on the second column gives us the number 2. Then we forget about the second row, look at the third one. First, we multiply by the first column, we get -14, then we multiply by the second column and get 2. The product is found.
Now we will perform another transformation for the same matrices. We find the matrix C, which is the sum of three terms, and here we have the square of the matrix A. Note that the square A is understood in the usual sense. A is multiplied by A, just like the square of a number (this is a number multiplied by itself), and the multiplication is what we have for the matrix, that is, we do not square each element, but multiply 2 matrices by the generally accepted rule. So, we write two identical matrices and repeat the procedure: row by column: -7 *(-7) +1 = 50.
Next, the first row by the second column: -7+2 = -5. We filled in the first line. Now fill in the second line. For the first matrix, we fix the second row, multiply by the first column: -7+2=-5. The first row by the second column: 1+4=5. Next, A in the square must be multiplied by the number 1/5. Each element of the square A is multiplied by one-fifth, that is, divided by 5, it turns out (10, -1/ -1, 1). Then, we need a matrix transposed to A. As a reminder, you must swap rows and columns. Row -7 1 will go to the column, row 1 2 will also go to the column. Next, we are given a second-order unit matrix, multiply it by 5, we get (see the video). I remind you that the unit matrix is made up of unit vectors.
Now the addition and subtraction operations of the found matrices are performed. We need to add the first two matrices and then subtract the 3 matrix. 1/5*A2 + AТ-5Е.
Let’s write it down in detail: the first element of the first line is 10-7-5, the second element of the first line is -1+1-0. We turn to the second line -1+1-0 and, finally, the second element of the second line is1+2-5. We calculate. The first line is -2 0, the second line is 0 -2. The result is obtained. Please note that the matrix can be written a little differently. We can take -2 out of the matrix and get the unit matrix. Thus, the answer can be written as -2*Е. So, the matrix is C = -2*E.
Now let’s take a more interesting task. The matrix A(1 1, 0 1) is given. Let me remind you again that matrix multiplication is not commutative, that is, multiplying matrix A by some, for example, by (1 2, 3 4) in this order, we get (4 6, 3 4), and multiplying in a different order, we get the matrix (1 3, 3 7). This example shows that the multiplication operation is not commutative, the order is important. However, in some cases, the matrices can be swapped with each other.
So, we need to find all such matrices X for which A*X equals X*A. As we can see, there is no matrix B among these matrices, but we will find all such X, if of course they exist. Let’s write the matrix X in a general form. The dimension of the matrix X is exactly the same 2 by 2, i.e. it has four elements. Let’s denote them by the letters (x y, z t). X is the matrix itself. And we write down in general what the product A*X is. So, (x+z y+t, z t). Now in a different order X*A, we get the matrix (x x+y, z z+t). We want these matrices to be equal. We see that, for example, the elements of the second row of the first column are already obviously equal, as in our example, the triples are the same, but the three remaining elements, generally speaking, have a different form. So, if we want equation to hold, all the corresponding elements must be equal, that is, x+z must coincide with x, y+t must coincide with x+y, and, finally, t and z+t must be equal.
This is the necessary system of equalities. Let’s explore it. It is not difficult to transform it. From the first equation, x is crossed out, and we get z=0. In the second equation, the variable y is crossed out, the equality t=x is obtained, and from the last equation, the equality z=0 is already known. It turns out that nothing depends on t, y, as well as x can take any value, and t =x. So, the required matrix X has the following form (x y-any, 0 x-any). So, for any values of x and y, the matrix of the specified type is a permutation matrix with the matrix A, that is, the order of multiplication is not important here.
If A is like this (see the video), then X looks like this. Please note that the matrix X can be represented as (x 0, 0 x)+(0 y, 0 0). So, let’s check, if we add up, we get a matrix X, we take out x from each matrix. Here, we get a unity matrix (see the video), and here we get this type (0 1,0 0), that is, keeping in mind the previous wording, we presented the matrix X as a linear combination of two specific matrices. x and y are the expansion coefficients.
Now let’s speak about the concept of the inverse matrix. We investigate the question on whether the matrix A will have the inverse matrix. We have already said in the lecture that not every matrix has an inverse matrix; however, often the inverse matrix exists. Let’s remember the definition. By definition, if there is an inverse matrix, it must satisfy this equality A*A-1=Е. And, in a different order, it is the same.
Let’s analyze the first equality. To do this, we again denote the elements of the unknown matrix (x y, z t) as in the previous problem and multiply (1 3, 2 6) by this unknown matrix. And so, we apply the row-by-column rule again. We get the matrix (x+3*z y+3*z, 2*x+6*z 2y +6*t), but if it is not known that the matrix is inverse, in the end, we should get a unity matrix, which means that x+3*z=1, and 2*x+6*z=0. We have a system. I suggest subtracting the first 2 lines from the second one.
So, we subtract. At the same time, I will once again turn to our previous material. Perhaps, someone has already noticed that these expressions are proportional. Due to this, after the specified subtraction operation, we will get contradictory equations, that is, the second equation will take the form 0*x+0*z=-2, which means that there are no solutions to this system. In other words, you will not be able to find the required x and z. This means that the original matrix does not have an inverse matrix. А-1 does not exist.
Finally, we will solve the problem in which the inverse matrix exists, and we will find it using the algorithm specified at the lecture. So, the matrix A has a size of 3 by 3. Here, by definition, the problem can be solved, but it is difficult because in this case the inverse matrix will be the same size, which means that it has nine unknown elements. We recall the algorithm to find the inverse matrix. Formally, we assign the unit to the original one on the right and start performing elementary transformations, trying to convert the matrix A to the unity one.
To do this, we first try to get a step form. We subtract the first 3 lines from 3. The line is drawn conditionally, I look at the matrix as a whole. We get a matrix of the form (see the video). And so, we see a lot of zeros, if we swap the last two rows, we will get a step matrix. I suggest you do it. And so, we rewrite it (see the video). Almost a unity matrix, but you need to multiply the last row by 1. We multiply. So, if there is one in the first row of the second column, it is very easy to get 0. We subtract the second line from the first one. Note that due to the fact that we get a step matrix, this subtraction does not change the first element in any way, which is important. Therefore, at first, we have a step matrix.
We get the necessary zeros under the leading elements, and then we get the zeros above the leading elements. So, we get the first line (1 0 0 4 0 -1), and all the others remain unchanged. The following matrix is obtained (see the video). So, what we see is that the matrix to the left of the line is a unity matrix, which means that by virtue of the theorem from the lecture, the matrix obtained on the right is inverse. So, let’s write down the inverse matrix and turn to the second point of this problem. We suggest that you check the correctness of this matrix yourselves, and to do this, you need to multiply the original matrix by the inverse one, and you get the result E. Check it yourselves.
And we will solve the second point of this problem. I remind you that we have found the inverse matrix, and then we are required to find the matrix X from the equation, and we will not solve it as before, denoting the elements with the letters x, y, z, t, but we will apply the knowledge of the inverse matrix.
We multiply the original equation А-1 on the right. In this case, by grouping the product A*A-1, we get this equality (see the video). We applied the associative property, which allows us to arrange parentheses in the product as you like, without changing the sequence. The multiplier is A*A-1= E, which means X = B*A-1. So, the solution to this equation is this matrix X. we substitute the matrix B and A-1 obtained and find X, once again performing the multiplication operation.
Let’s check whether the dimensions of these matrices coincide. Matrix B 2 by 3, and A-1 3 by 3, in the end, we get the matrix of 2 by 3, so you can multiply, so everything is correct. Again, I no longer say what is multiplied by what, we immediately calculate. So, the matrix X has the specified form (see the form).
The problem is solved.