Hello, everyone. Welcome to our lecture, Use Python to Find the Inverse of a Matrix. In this video, I'm going to find the inverse of different size of matrix in the three-by-three, two-by-two, and so on. We import this library and then now we build the following matrix, M is a three-by-three matrix. To get the inverse of this matrix is a sympy matrix, so all we need to do is to type M dot inv. That is a method, and then this will return the inverse of matrix M. That is an error because the determinant equals 0. The determinant of this matrix is equal to 0. For a matrix to have an inverse, its determinant has to be a non-zero. For example, let me change this to 11. Now we'll be able to find the inverse of this matrix. That's very important. Not all square matrix has inverses. For a matrix to have inverse, the square matrix will have inverse, its determinant has to be non-zero. That's the first example. Second example we have is six-by-six matrix T, right here. Again, to find the inverse of this sympy matrix, we just type inv matrix dot and then hit enter. This is the inverse of the matrix T. Now, let's look at our identity matrix I. Look at this, it's a three-by-four matrix. Basically, here is not a square matrix. If I tried to find the inverse of this, I will get error message because it's now a square matrix. You see the error non-square matrix. You can only find the inverse of a square matrix whose determinant are not equal to zero. The zero's matrix. Again, if you want to find the inverse of this matrix, you use the same method inv. Now, because the determinant of the zero matrix is equal zero, this will also give us error message. It will say determinant equals zero. It's not sufficient to have a square matrix. You need to have the determinant to be a non-zero, also. Now the one's matrix, this is a four-by-four, we'll have no problem here. You just type inv for this matrix and then you have the inverse. Let me run it. It's a O, that inv. Again, the determinant is zero for this one. If you find the determinant, you will get zero. That's the result. Now look at this diagonal matrix it's a three-by-three, so let's look at the inverse of that. For the inverse to exist with determinant here must be non-zero, so you see the determinant here is non-zero. You can check that we learned that from the previous video. To find the determinant, you just type in det for determinant and then you have the determinant is six. Right here, If you type det for all, so all that det, you will see that this determinant is zero also, is equal to zero. That's why the inverse does not exist. It's very important for the determinant of the matrix to be non-zero for you to be able to talk about inverse. Now, this is a column matrix, It is not a square matrix, so as a result, I will not be able to find its inverse. I will get error message saying that is a non-square matrix. In this video, we'll learn how to find the determinant of a different size of matrix, square matrix. We notice that all the square matrix whose determinant are different from zero have inverse, in addition to that we learn that is zero matrix has no inverse. The one matrix which is square, has a determinant equals zero, which is because the determinant is zero, it's determinant inverse does not exist. With [inaudible] is that for you to be able to find the determinant of the matrix, the matrix needs to be square and the determinant need to be non-zero. Thanks everybody. I will see you in the next video.