Hi everyone. This is Professor Young-jin Yoon from KAIST, and this is the third session of Week 4 about basic mathematics for the beginner of AI, which is about the linear algebra. Onto to last session, we studied about the linear combination and also linearly independent vectors, end up with what is the inverse matrix of A by using row operations. From this session, let's study finding the inverse of matrix A by using row operation. Here, let's say that we have three by three square matrix A, 1, 1, 2, and 2, 3, 1 and 2, 1, 7. Find the inverse of matrix A if it exists. Let's make a tabular form. Then there is a lot of components here. It's much more complicated when you calculate the solution for the system of linear algebraic equation because we have identity matrix on the right-hand side, which is nine elements. Let's say this is a very long journey to go. Let's do it one-by-one. 1, 1, 2 and you say 2, 3, 1, 2, 1,7 on the left-hand side. On right-hand side, there is identity matrix 1, 0, 0, 0, 1, 0, 0, 0, 0, 1. As I introduced in the last session by doing this row operation, this right-hand side identity matrix changing with a certain different, like some matrix, and then once you change this left-hand side matrix A to the identity matrix, the right-hand side matrix become the inverse of matrix. I tried to make the second row element 2 become 0 and the row element 2 become 0 by using R_2 become R_2 minus 2 times R_1, and R_3 become R_3 minus 2 times R_1. The second row becomes 0, 1 minus 3, minus 2, 1, 0, and third one become 0 minus 1, 3 minus 2, 0, 1. Here I try to make 0 for the first row, 1 and 3, 1 minus 1, 2, 0, and fix the R_2 here. By using row operation, I change the R_1 first row by using R_1 minus R_2, it becomes 1, 0, 5, 3 minus 1, 0 and third one R_3, become R_3 plus R_2 and then they become 0, 0, 0, minus 4, 1, 9. As you see the right-hand side change from the identity matrix to another matrix. However, here the diagonal element for the third one becomes 0. Third row becomes 0. Here we need to stop because it cannot be our identity matrix. It should be the 1, 1, 1 on the diagonal element on the left-hand side. In this case, A is not invertible. We cannot find the inverse matrix of A. Let me find other case, find the inverse of A. Here's a four by four matrix. 1, 0, 2, 7, and 0, 2, 1, 1 and 2 minus 1, 0, 2, and 0, 1, 1, 2. Now, this is the tabular form, a very complicated. This is another long journey. Let's started together. But here I try to modify row three, R_3 become R_3 minus 2 times R_1, it become 0 minus 1, minus 4, minus 12, and minus 2, 0, 1, 0 like that. Then I try to make the third row 1 minus 1 and fourth row 1 to 0 by using the row operation as follows. Third row R_3 become two times R_3 plus R_2 and for the R_4, the row 4, I change to the 2 times R_4 minus R_2 and it become 0, 0 minus 7 minus 23 and minus 4, 1, 2, 0, and fourth row becomes 0, 0, 1, 3, 0, minus 1, 0, 2. Then I try to change the first row, the third column, the element 2 become 0 and second row, the column three element 1 becomes 0 and then last row, fourth row, column 3 element 1 become 0. By using this row operation, R_1 becomes 7 times R_1 plus 2 R_3, and R2 becomes 7 times R_2 plus R_3 and R_4 become 7 times R_4 plus R_3. It become like that. There is three more component need to be changed to the 0. Here what is that? The last column, 3 minus 16 minus 2. I tried to make the 3 minus 16 minus 23 becomes 0 by using this row operation, R_1 become 2 times R_1 plus 3 times R_4. R_2 becomes R_2 minus 8R_4 and R_3 becomes 2R_3 minus 23R_4. Then I can there, almost get the identity matrix by changing or the original matrix element becomes zero out of the diagonal element here. You can see the right-hand side identity matrix become very complicated number here and then those are almost like our inverse matrix of A. First row divide by 14, and second row divide by 14, and third row divide by minus 14, and last row divide into the minus 2 then it become like this. The left-hand side become the 4 by 4 identity matrix. Right-hand side become like this. Right-hand side is the inverse matrix of A. We finally find that the inverse of matrix A like this. It is very long journey but is successful to get the inverse of matrix. Here, you can see that during the operation, you can see the left-hand side original matrix remains in a diagonal part, remains as some number, is not 0 number, finally, we can get the inverse of matrix. In a big picture, the finding inverse of matrix A and solving AX equals B has a similar procedure. Finding inverse of matrix A is we set up the tabular form is A bar I. Solving the AX equals B, we also set up A the bar B like this and then by using the row operation, both part, for the finding inverse of matrix A, we change matrix A to the identity matrix and then you can find inverse of matrix V if possible. Then solving AX equals B, also we change A to the I and B becomes C, or before that, we change A to the U operational matrix and I put this, if possible. If possible means there is a case we cannot find inverse of matrix A, there is case we cannot find a solution for AX equals B. If it is possible to reduce A to the I, then A is invertible and AX equals B has a unique solution. If it is not possible to reduce matrix A to the identity matrix I, then A is not invertible and AX equals B has either no solution or infinitely many solutions. Let's consider the system of linear algebraic equation AX equals B. If A inverse exists, then you can write A inverse AX equals A inverse B. We can just multiply A inverse to the left side of the equation, so this becomes A inverse AX equals A inverse B. From the definition, A inverse A become identity matrix, so it becomes I times X equals A inverse B. X equals A inverse B. Here, if we know the inverse of matrix, then we directly can find the solution X here for the system of linear algebraic equations, which is X equals A inverse B. We need to note that to finding the inverse of A requires a lot of more work than reducing AX equals B to the UX equals C. When you solve AX equals B, I usually recommended that to use the method that reducing AX equals B to the UX equals C first. However, if you already find the inverse of matrix A, then we can use that inverse matrix of A to find a unique solution for the linear algebraic equation. For example, if you have some system of linear algebraic equation like this, AX equals B, here is, we have four unknowns, x, y, z, w. Then once we know that inverse matrix of A here is minus 1, minus 1, minus 3 like that, from our early work, we just simply multiply this inverse matrix on the left side of each side and then the left-hand side only remains x, y, z, w and right-hand side becomes A inverse times 1, 0, 1, 2 and you can easily find the unique solution x, y, z, w with 6, minus 15, 43, minus 13 like this. Here, we found that once you know the universal matrix, you can easily use that to find a new solution. Also, the process to find the inverse of matrix, then it's not easy, it's very hard work. However, if you use the computer by using no operation, you can easily find that inverse of matrix. Up to here is the Week 4, so let's meet in Week 5. Thank you very much.