 In this video, we'll provide the solution to question number 14 from the practice exam number three for math 2270. In which case, we need to find the least square solution or solutions to the following system of linear equations. 2x1 plus 2x2 equals negative 5, negative 2x1 equals 8, and 2x1 plus 3x2 equals 1. Now, as we're trying to solve the least squares problem, the original linear system could be consistent. It could be inconsistent. We don't actually know and we don't actually care. It seems that since it's over-determined, we have three lines trying to intersect in the plane. It's very likely it's inconsistent and we just kind of draw random lines right there. And so we might be looking for some type of like, you know, curve of best fit or something like that. That's this least square solution that we're trying to find here. Now, to find that, what we have to first do is recognize the coefficient matrix A, which in this case is going to be 2, 1, negative 2, 0, 2, and 3. Like so, we look at the augmented matrix B, which is going to be negative 5, 8, and 1. And what we need to do is we need to solve the normal equations, which look like A transpose AX hat equals A transpose B. So normally we would solve the equation AX equals B if we're trying to solve the linear system, but we want to solve the least squares problem instead, not the linear problem. And in this case, we don't want this one. We want the normal equations right here. So we have to compute A transpose A, which A transpose is just you take the rows of A and turn them into columns and columns into rows, right? So A transpose would look like 2, negative 2, 2, 1, 0, 3, and then A leaving just, you know, taking what it was, 2, 1, negative 2, 0, 2, and 3 here. And so when you take the matrix times its transpose, we're just looking at all the possible dot products between columns of A with the different columns, right? So if you take the dot product of the first column of A with itself, you end up with 4 minus 4 plus 4. That's going to look like just a 4, right? Then we're going to take the first column of A dot the second column of A that gives you 2, 0, and 6. It's going to give us an 8 right there. I did it again. Oh, because it's positive. Okay, let's back up. Let's start again in 3, 2, 1. Now, notice that computing A transpose A is just the same thing as just taking the dot product amongst all the possible columns of A, in which case if we take the dot product of the first column of A with itself, you'll end up with 4 plus 4 plus 4, 4 here, which that's going to give us in the end a 12 right here. If we take the first column of A dot the second column, you end up with 2 plus 0 plus 6, which is an 8, like so. A transpose A is always going to be a symmetric matrix. You'll notice that the next one is you take the second column of A dot the first column of A, in which case you're going to again get a 2 plus 0 plus 6, which is another 8. And then the last one, if you take the second column of A transpose times the first column of A, that's just the second column of A dot itself, in which case you get 1 plus 0 plus 9 will be the sum of squares. And so you get a 10 right there. And so this is our A transpose A. We need to do the same thing with A transpose B, A transpose B, which you can take the transpose matrix 2, negative 2, 2, 1, 0, 3 times it by B, which was, you can't see it on the screen anymore, most of it at least, or at least some of it, negative 5, 8 and 1. Which again, in this situation, we're just looking at the dot product between the columns of A with the vector B right here, in which case we're going to get a negative 10 minus 16 plus 2, that gives us a negative 24. And then we're going to take the second column of A dot product with B, in which case we get a negative 5 plus 0 plus 3, which gives us a negative 2. And so like we saw earlier, we have to solve the normal equations A transpose A, x hat equals A transpose B. So we need to solve the system of equations where we get 12, 8, 8, 10, augment, negative 24, negative 2. So we could row reduce this matrix, right? We could row reduce this matrix to get 1, 0, 0, 1, x hat. So you could just do row operations to do that. I want to demonstrate how you can do it using the inverse matrix of A transpose A. So we want to compute the inverse of this matrix right here. So A transpose A inverse, it's just a 2 by 2 matrix. So we're going to get 1 over its determinant, which you're going to get 12 times 10, which is 120 minus 8 times 8, which is 64. So that gives us the determinant. Then the adjugate, we're going to swap the locations of the diagonal entries so we get 10 and 12. And then we're going to negate the off diagonal entries, negative 8, negative 8 here. For which then we see that the determinant turns out to be 6 to 56. So you get 1 over 56 right here times 10, negative 8, negative 8, and 12. For which notice everything is divisible by 2. Like you factor out a 2 out of the matrix there out of the adjugate. And then it goes into 56, 2 will go into 56, 28 times. So you get 1 over 28 times 5, negative 4, negative 4 and 6. For which then the solution, our solution x hat, this then will equal A transpose A inverse times A transpose B. For which this is just a matrix product at this moment. So we're going to take 1 over 28 times 5, negative 4, negative 4 and 6. You'll notice that's also a symmetric matrix times negative 24, negative 2, like so. For which when we do the matrix product, I'm going to postpone the 1 over 28 for a moment. When we do the matrix product, we're going to get 2 times, we're going to get, well actually I notice here that everything in A transpose B is actually divisible by 2. If I factor out the 2, I can even make my fraction a little bit smaller. You get 1 14th times 5, negative 4, negative 4 and 6. And you're going to times that by, I'm actually going to take out the negative sign as well. So you get a negative 1 14th there. So you're going to get 12 and 1, like so. Now when we multiply out the matrices, we end up with 5 times 12, which is going to be 60 minus 4, 4 times 1. And then we're going to get 4 times 12, which is negative 48 plus 6 right there. Combining like terms, we end up with a 56 for the first one. And then negative 48 take away 6 is going to be a negative 42. For which then, you'll notice that actually both of those numbers are divisible by 14. We end up with a negative 4 and 3 as our least square solution. This is a unique solution right here. Now, I tried solving this using the inverse of A transpose A. You didn't have to do that. You could have row reduced that instead back here. We could have row reduced it. The advantage of using the inverse matrix here is that it kind of procrastinated fractions until the very end of the problem. For which you could do that if you want to or you could just row reduced it from the very get go. Again, there have been some fractions, but in the end it turns out they clean up. And we end up with the solution like we saw a moment ago, negative 4 and 3.