PROFESSOR: Hi, and welcome. Today we're going to do
a problem about least squares approximations. Here's the question. Find the quadratic equation
through the origin that is a best fit for these
three points: (1, 1), (2, 5), and (-1, -2). I'll give you a minute to
work that out on your own. You can hit the
pause button now, and we'll be back in a minute to
work the problem out together. OK and we're back. So what's the first step
in a problem like this? The first step is figuring out
what our equation looks like, the one that we're
going to find. So our equation is going to
look like c*t plus d t squared equals y. So that's what
we're looking for. We're looking for a quadratic
equation through the origin. Now, if it were just
any quadratic equation, then we would have
a constant term, but through the
origin just means that the constant term is 0. Now, what's the next step? Next we need to set
up a matrix equation. So we need an A, a
matrix A. And which matrix is that going to be? Well, let me start with the
first coordinate of these three points. And I'm going to put them in the
first column of this matrix, 1, 2, -1. And then my second
column is going to be the squares of these
coordinates, 1, 4, and 1. And my x hat--
that's just c and d. And my b-- this is going to be
the second coordinates, 1, 5, and -2. OK, why did I set this
problem up like that? Well, multiply A times x hat. The first coordinate of
A times x hat is 1 times c plus 1 times d. It's just the same as
plugging in this first point into the left-hand
side of this equation. And similarly, if I
took the second point and plugged it in here,
I would just get 2 times c plus 4 times d,
which is just the same as the second coordinate in the
multiplication A times x hat. 2 times c plus 4 times d. OK, and where did
the b come from? Well, b came from
plugging in these points to the right-hand side. So 1, 5, and -2 are
just the y-coordinates of these three points. So it would be great if we
could solve A x hat equals b. But we can't solve
A x hat equals b, because there isn't
a quadratic equation through the origin that
contains these three points. But we need to find the
best approximation to that, so that's the same as
solving A x hat equals the projection of b onto
the column space of A. Because we only have a chance
of solving A x hat equals something if it's in
the column space of A. And remember from our
projections part of the class that this is the same as solving
A transpose A x hat equals A transpose b. So that's what we're
really going to do. We're really going
to solve A transpose A x hat equals A transpose b. And now all we have to
do is just a computation. So let's do it. So what is A transpose A? I'm going to do this
kind of quickly, because you should be good at
multiplying matrices by now. Oh this-- I have the negative
in the wrong place, thank you. Thanks for that correction. I have the negative
backwards there. And what do I get
when I multiply these? I'll let you check. This is 6, 8; 8, and 10. And what is A transpose b? Well, if you multiply
this out, I'll let you check that
you get 13 and 19. So this is just
some computation. And so what we're solving
here is [6, 8; 8, 10] times x hat equals [13; 19]. And we remember how to do this
just by using elimination. We replace the second row
by 3 times the second row minus 4 times the first row. Again, I'm going to do this
quickly because you know this from other parts of the class. You similarly
change the b vector, and we backsolve
to get d is -5/2 and c equals--
let's plug that in and see-- think you're
going to get 11 over 2. So what's our final equation? Our final equation is y equals
11/2 t minus 5/2 t squared. OK. So this is our best
fit quadratic equation through the origin. Now before I end, let
me do a couple things. First, let me go back and
review what the key steps were. Whenever you're faced with such
a best fit equation, first, you want to see what the
general form of the equation is. Next you want to write
it in terms of matrices. Write down your matrix
A and your vector b. And lastly, you set up
your projection equation. And then all you have to
do is just a computation. But it might also
be worth noting that these three
points certainly aren't on this quadratic equation. For instance, if I plug in 1
here, I don't get (1, 1), I get (1, 3). But that's OK. This is as close as we can do. Thanks.