Hello. In this video, we're going to learn how to use the matrix inverse to solve for a linear system of equations. In the previous video, we learned how to transform a set of simultaneous equations into a matrix representation of that format, AX = C. Now, the question is how to solve for X. Maybe when we look at this equation, it looks like a very straightforward algebraic equation, and we can say, "Okay, let's divide both sides by A so that I have a solution for X = C/A." While algebraically this sounds correct, this is not the right matrix operation. There is no operation called matrix division. Instead, we have to use what we call a matrix inverse. Okay, so if you consider the matrix inverse, it exists for square matrices. If it exists, we're going to denote the inverse as A⁻¹, such that when you multiply the matrix by its inverse, we get the identity matrix. As a result, we can prove that the solution for our unknown vector X is equal to A⁻¹ times C. Let's see the step-by-step solution for that. After we transform our linear system of equations into the matrix format, this is the equation that we have. We wish to solve for X, so we wish to have X on one side and everything else on the other side. One way to do so is to multiply this equation from the left by A⁻¹. Here, we multiply it by A⁻¹ from the left. A⁻¹ × A would give us the identity matrix, and on the right-hand side, we still have A⁻¹ × C. The identity matrix times any vector or any other matrix will give that matrix again, so I × X would give us X. Now, we have X alone on the left-hand side, and the right-hand side is now A⁻¹ × C. So, if we have a linear system of equations, we write it into this matrix format. Your solution would simply be: take the inverse of the coefficient matrix, multiply it by the right-hand side vector, and you have your solution. This is very straightforward, very simple, and doesn't require a lot of steps compared to the previous methods that we covered in an earlier video. Now, let's talk more about the properties of a matrix inverse. By definition, a matrix inverse only exists for a square matrix. This means that if we would like to use the matrix inverse to solve for unknown parameters, we should have a number of equations equal to the number of unknowns so that we can take the inverse of A. If I have a matrix A and I find another matrix B such that when you multiply A × B, you get the identity matrix, then you can immediately say that B is the inverse of A. If A has an inverse, then we call it invertible or, in other words, nonsingular. Okay, so we say that a matrix is invertible or nonsingular if its inverse exists. On the other hand, not every square matrix has an inverse. If you have a matrix that doesn't have an inverse, we call this matrix non-invertible or singular. If I have two matrices that are square matrices and you multiply them together to give you the identity matrix, this means that B is the inverse of A, and also A is the inverse of B. Both are invertible, and when you multiply them together, you're going to have the identity matrix. An invertible matrix is called nonsingular. A nonsingular matrix or an invertible matrix has these two properties: All rows and columns are linearly independent, meaning that I cannot get one row as a linear combination of the other rows. The same for the columns—I cannot get one column as a linear summation or linear combination of other columns. If this happens, this means that this matrix is nonsingular, and its inverse exists. Let's see this example: We would like to determine whether this matrix B is the inverse of A. Okay, so one way to do so is to multiply B × A. If B is equal to A⁻¹, then this multiplication should correspond to A⁻¹ × A, and the result should be the identity matrix. If B doesn't equal A⁻¹, this result here wouldn't equal the identity matrix. So, let's verify by doing the multiplication. We don't need to manually compute it. Let's multiply A × B or B × A—both would be the same. So, I have B = [3 2; 5 3], and A = [-3 2; 5 -3]. So, I have a 2×2 matrix times a 2×2 matrix. The result would be a 2×2 matrix. Start by first row, first column: 3 × (-3) + 2 × 5 = -9 + 10 = 1 First row, second column: 3 × 2 + 2 × (-3) = 6 - 6 = 0 Second row, first column: 5 × (-3) + 3 × 5 = -15 + 15 = 0 Second row, second column: 5 × 2 + 3 × (-3) = 10 - 9 = 1 When we do that, we're going to have [1 0; 0 1], which is the identity matrix. So, if I have two matrices, multiply them together, and get the identity matrix, this means that one is the inverse of the other. So here, yes, B is the inverse of A. Now, let's move to the computation of the inverse matrix. In this course, we're going to focus on a 2×2 matrix. If we have a larger matrix, we're going to use either MATLAB or a calculator to solve for the inverse. Okay, so let's analytically focus on a 2×2 matrix. Assume that I have a 2×2 matrix whose elements are [a b; c d]. To get the inverse of the matrix, we're going to divide by the determinant of that matrix. The determinant of a 2×2 matrix would simply be the multiplication of the diagonal elements minus the multiplication of the off-diagonal elements. So, it would be (ad - bc). Then, I'm going to swap the diagonal elements. Here, I have a and d—I swap them together. And then, I change the sign of the off-diagonal elements. Okay, so let's do this example together. I have this matrix A, and I'd like to compute its inverse. To compute A⁻¹, we're going to divide by the determinant. So, the determinant here would be the multiplication of the diagonal elements: (-3 × -3) = 9, minus the multiplication of the off-diagonal elements, which gives us 10. Then, we're going to have a matrix where we swap the diagonal elements. So, I have -3 and -3, and then I change the sign of the off-diagonal elements. So, it's -2 and -5. Okay, so this term here gives us -1. So, we have 1/(-1) × [-3 -2; -5 -3]. Completing the multiplication by this negative one, we're going to end up having [3 2; 5 3]. So, this is A⁻¹. So far, we have learned how to solve for the linear system of equations. If I have a linear system of equations, we can write it into a matrix format like that. And then, we learned how to use the inverse to get the solution for X, so X would be A⁻¹ × C. We also learned how to get the inverse for a 2×2 matrix. So, let's wrap this together and have a big example in which we solve a simultaneous set of equations using the matrix method. Okay, so let's assume that we have these two equations for two unknowns: 2X + Y = 4 X - Y = -1 So, I have two equations in two unknowns, X and Y. Again, those unknowns might be the current and voltage in your circuit that you'd like to solve for. And we'd like to solve for those X and Y using the matrix method. Step number one would be to put the two equations into the matrix format. So, put our equations into the matrix format. This would be a very straightforward process. We're going to have a coefficient matrix, a matrix of our variables X and Y, and on the right-hand side, we're going to have the result. And by the way, the order of the equations doesn't matter. So, this could be equation one and this equation two. You fill in the rows: row number one corresponds to equation number one—2 and 1 (coefficient of X is 2, coefficient of Y is 1). Then, you move to the second equation: coefficient of X is 1, coefficient of Y is -1, and the result for equation one is 4, and for equation two is -1. So, this is the matrix format. If you decided to start with equation two first, you're going to end up having a different matrix format, but the end result would be the same. So, let's assume that I'd like to have a matrix format where I'd like to start with equation number two first. So, I have my two parameters, X and Y. If you start by equation two, the coefficient of X is 1, the coefficient of Y is -1, and before you forget, you write down the corresponding answer, which is -1. Then, you can fill in the second equation: the coefficient of X is 2, the coefficient of Y is 1, and the result is 4. So, this also is an acceptable format. And if you do the matrix inverse here or here, you're going to get the same exact result for X and Y. Okay, so let's take the first format on the left. So, we have our matrix format: [2 1; 1 -1] × [X; Y] = [4; -1]. This is AX = C, where vector X is the vector that contains our unknowns, X and Y. So, we can solve for X as A⁻¹ × C. Step number two here is now to get the inverse of A—find A⁻¹. Okay, so A here is a 2×2 matrix, so we're going to divide by the determinant. The determinant is the multiplication of the diagonal terms minus the multiplication of the off-diagonal terms. And then, we swap the diagonal terms and change the sign of the off-diagonal terms. So here, I have 1/(-3). A⁻¹ would simply be: [1/3 1/3; 1/3 -2/3]. Once I have that, we use this equation to solve for our unknowns. So, we are ready for step number three, which is generating that solution. Step 3: X = A⁻¹ × C. So, we have an expression for A⁻¹: it's [1/3 1/3; 1/3 -2/3]. And here, we have C = [4; -1]. When we do this multiplication, we have the following: X = (1/3 × 4) + (1/3 × -1) = (4/3) - (1/3) = 1 Y = (1/3 × 4) + (-2/3 × -1) = (4/3) + (2/3) = 2 So, this is the solution for our parameters. X was the vector that contains our unknowns, X and Y. So, from here, we say that X = 1 and Y = 2, which is the same solution that we obtained using the other methods. But now, this doesn't require a lot of steps. Once you put your problem into the matrix format, you take the matrix inverse, multiply it by the results column, and it gives you the final solution. Thank you.