Curve Fitting
X
00:00
/
00:00
CC
Hello wonderful mathematics people.
This is Anna Cox from Kellogg Community College.
Curve fitting a polynomial of degree N is a function of the
form F of X equal a sub not plus a sub One X + a sub two X ^2
plus...
plus a sub NX sub N where the coefficients a sub zero a sub 1A
sub two...
A sub N are constants.
The data points X1Y1 lies on the curve Y equal F of X provided
that F of XI equal Y sub I.
The condition that this be true for each I starting at 0 going
through N yields the n + 1 equations A sub not plus a sub
1X not plus a sub 2X not squared plus, etcetera.
And what this really does is if we think about looking at our a
sub not and our a sub one and our a sub two as coefficients
that we're trying to solve, then we can come up with the
Vandermonde matrix.
And the Vandermonde matrix says that basically we're going to
take one and then X not and X not squared, X not cubed plus...
Till we get to X not to the north.
And the reason is we're trying to solve for this a sub not and
this a sub one and this a sub two.
So if we thought about what's being multiplied by the a sub
one, it's the X not or what's multiplied by the a sub two,
it's the X not squared.
So when we put it into a matrix that we're trying to solve,
we're really doing the 1X not X not squared, etcetera.
And we're doing that for each of those i's.
So for I equal 1, I equal 2, I equal N.
Now we have a matrix that we can solve, and if the X coordinates
are distinct, then the matrix A is non singular.
Thus the system has a unique solution for the coefficients of
the mate of the polynomial.
So there's a unique polynomial if all of those are unique or if
all of those are non singular.
Three points determine a circle.
Our generic equation of a circle is the quantity X -, H ^2 + y -,
K ^2 equal R-squared.
If we do some manipulation, we can see X ^2 - 2 H 2 HX plus H
^2 + y ^2 - 2 KY plus K ^2 equal R-squared.
Manipulating things around, we can realize that if we do some
replacement with generic variables, this could turn into
a * X + b * y + C equaling negative X ^2 + y ^2.
So if we thought about putting this into a matrix when we're
solving for AB and C, because we know our X and our Y, we would
end up with a matrix that said XY one, and then whatever that
negative X ^2 + y ^2 was, and then XY one for our next point.
So that's X ones, X twos.
I could have used X knots, etcetera.
So, and we'll do an example in a moment.
Three points determine a central conic and the central conic is
of the form AX squared plus Bxy plus Cy squared equal 1.
And remember this B is basically telling us a rotated conic.
And so if it's a rotated conic, then we can look at the
determinant and figure out whether it's an ellipse, a
hyperbola, a parabola, a circle.
So looking at a polynomial with the points negative 1115216,
we're going to use the equation or the matrices that says one
negative one, one and one, then 11515, 12416.
This is going to be a cubic because we have three, or a
quadratic because we have three points.
So what we're really doing is we have Y equal A+, BX plus CX
squared.
Actually, let's put the Y at the other end.
So if we have A + B * -1 + C * -1 ^2 equaling 1 or A + B * 1 +
C * 1 ^2 equaling 5A plus B * 2 + C * 2 ^2 equaling 16.
So if we're solving for these ABS and CS, we can see that the
coefficient on the A is just one.
Hence this column of ones.
Here the coefficient on the BS is going to be -1 one and two,
which is this column.
Here the coefficient on the C's -1 ^2, 1 ^2, and 2 ^2.
And then our last column is just going to be the Y's or what they
were equaling.
Now, using our rules and matrices, we're going to come up
with the diagonal identity matrix with whatever equals on
the end.
So if we started with negative 111 and we took row 2, subtract
row one and then row three and subtract row one.
1 - 1 zero -1 - 1 row 2O root 2 minus one 1 - -1 two 1 - 1 zero
5 - 1 four.
I chose row 2 minus row one instead of row 1 minus row two
just because it gave me positive numbers there.
Row 3 minus row 103315.
So now I'm going to divide by.
I'm going to take row two, divide by two.
I'm going to take row 3 and divide by three.
So one negative 1-110-102-0115 Now if I just take row one and
add it to row two, we're going to get 1013.
And if I leave that middle row alone for a minute and then
we're going to take row 3 minus row two.
So 1 - 1 is zero, 1 - 0 one 5 - 2 three.
I want to get this one to be gone also.
So I'm going to take row 2 Nope row one and subtract row 3.
So now we get 100001020013 what that matricy tells us.
Because each of the rows is unique, we know that Y is going
to equal a X + b at no A+, BX plus CX squared.
But this matricy tells us that my A is 0, my B is 2 and my C is
13.
Three.
That was separate one, then the three.
So my answer for this is going to be Y equal two X + 3 X
squared is the polynomial that fits the given three points.
So the quadratic Y equal two X + 3 X squared goes through
negative 1115 and 2:16.
Looking at a circle, we know it's going to be of the form AX
plus BY plus C equaling negative the quantity X ^2 + y ^2.
Now we want to solve for AB and C So when we make our matrices,
our coefficients are going to be the X.
The YC has a coefficient of one with it, and then we're going to
take these two terms and square them each separately and then
take the opposite of it.
So 3 + 16, then the opposite of it, so -25 S five, 10125 and 100
negative -912 one 81144, negative 225.
Sometimes it helps us to choose a different column to get rid
of.
So we're going to actually start with our ones and zeros in that
third column because we already have a one here.
If we look here, we'd have to divide by three or multiply by
two and subtract.
But this way we can just subtract rows.
So if we take row 1 minus row 3 and row 2 minus row three, and
we leave that row 3 alone, so -912 one negative 225 and then
twelve negative 16, zero 214, negative 20100.
Now whenever I can, I try to keep my number small so I can
look at this top row and realize everything is divisible by 4.
And this next row, everything is divisible by two.
So I'm going to take this top row, row one, divide by 4 and
row 2 and divide by.
Actually, let's divide row two by a -2 because that will put a
one in this location, which is what I want.
So now we're going to have three negative 4050, negative 710,
negative 50, negative 912, one negative 225 S Now let's take
row 2 and multiply it by 4 and add to row one and row 2 * -12
and add to row 3.
So when I do that, let's see what am I going to get?
Row 2 * 4 so -28 and three negative 2500 times 4 negative 2
hundreds -150 we're going to leave row two alone.
Row 2 * -12 so 84 and -975 zero one -12 and 50 and OK, 375.
So now we can see that this row one, we could divide by -25 and
we'd get a one in the right location there.
So if we take that one and divide by negative 251006,
negative 710, negative 50, 75 zero 1375 S, now we're going to
take row one, multiply by 7, add to row two, row one, multiply by
-75 and add to row 3.
Remember, there are lots of ways to do this.
This just happens to be the method I'm seeing.
OK, so now what that tells us is we're going to have six X -, 8 Y
-75 equaling negative X ^2 + y ^2.
If we want to come up with the actual equation of the circle
and the center and radius, we're going to need to get the X's and
Y's all on one side, and then we're going to have to complete
our square.
We can take that constant to the other side if we want.
So we're going to take half a -6 three and square it nine.
If I add 9 to one side, we're going to add 9 to the other.
I'm going to have take half of the -8 four and square it.
If I add 16 to one side, we're going to add 16 to the other.
So this is going to factor into X plus oh, that was an ** plus
three quantity squared plus y -, 4 quantity squared equaling 75
and 9 and 16100.
So our center is -3 four and our radius is 10.
What if we wanted to look at a central ellipse with the points
00430 and 55?
Remember, our equation for a central ellipse says AX squared
plus bxy plus Cy squared equaling 1.
So when we do our matricy here, it's going to be the X ^2 term
as the coefficient on the A, the X&Y multiplied together as
the coefficient on the B, and then the Y ^2.
And they're all going to have one in the last column.
So then we get 9001 and 252525 and 1:00.
So I can change rows and columns.
I'm going to take the 2nd row and move it to the first row.
So row two to row one and I'm going to divide by 9 and then
I'm going to take row one to row 3 and divide by 16 so we get
1001 ninth.
So that row is exactly how I need it.
00 one 116th that rows how I need it.
So now I'm going to need to deal with this other row and I might
go ahead and leave them as 20 fives for yeah, 20 fives for
just a second.
So now we're going to take row 1 * -25 and add it to row 2.
So if we do that, we're going to get 1001 ninth zero 2525 and -25
ninths plus one ninth.
So -25 ninths, no -25 row one.
Nope.
Row one negative 25 ninths plus one.
So one is 9 / 9 negative 16 ninths.
So now we're going to take row 3 and multiply by -25 and add to
row 2.
So we're going to get 1001 ninth zero 25 zero negative 25
sixteenths plus -16 ninths -25 sixteenths -16 ninths.
Common denominator 144 -48481 / 144 Oops.
Put it in the right spot though -481 / 144 and then this one is
00 one 116th.
So then finally we're going to take row 2 and divide by 25.
So when we do that we're going to get our matricy that says
1001 ninth 010 dividing by 25 negative 481 over 360000 one
116th.
So we know that this is going to be one 9th X ^2 -, 481 three
1006 hundredths XY plus 116th y ^2 equaling one.
And just because we usually like integer coefficients, we're
going to multiply everything through by 3600 and we're going
to get four hundred X ^2 -, 481 XY plus 225 Y squared, equaling
3600.
Rotation formula for conics, recall is AX squared plus bxy
plus Cy squared plus DX plus Cy plus F = 0, where B does not
equal 0.
The angle of rotation is cotangent to Theta equaling our
coefficients a -, C / b.
And if it's a non degenerate, non degenerate conic, then it
has the property that the determinant b ^2 -, 4 AC.
If it equals zero, it's a parabola, it's less than 0, it's
an ellipse or a circle, and if it's greater than 0 it's a
hyperbola.
So on the example that we were just working on.
We can look at our cotangent of two, Theta being our A term 400
minus our C225 all over our B -481.
So we can find Theta being 1/2 of the cotangent inverse of -175
/ 481.
So that's approximately -.003175°.
So that's going to tell us that this is going to rotate by a
very small angle in the negative direction.
So then we can figure out what kind of an angle it is or what
kind of a figure it is.
So our b ^2 minus our four times our A * C, When we compute that,
we can see that that's -100 128,639.
So it's going to be an ellipse or a circle.
Now, with a lot more math, we could figure out exactly what
this ellipse or circle would look like as far as how far out
it goes and whatnot.
But let's just start over, OK?
So if we draw our segment and we put in a line very, very, very,
very, very small negative value, and then maybe I move that line
a little bit up so it looks like it's going through there and now
I've lost the whole thing.
So then an ellipse is going to be somewhere along that's going
to be sort of perpendicular, not even close to perpendicular.
OK, I hadn't originally planned to sketch this, so maybe I
should just give up.
So the idea would be that we could actually figure out the
extremes of the ellipse, how far up and down, etcetera.
We do know that it's going to be longer on the X than the Y due
to the fact that the coefficient on the X was bigger.
So let's look at our last type, which is an application problem,
and it talks about wanting to figure out a curve fitting for
information that's given for the West from 1970, nineteen, 80 and
1990.
And we want to come up with a cubic equation for this.
So what we're going to do is we're going to actually write a
matrix and we're going to let our time equal 0 for 1970.
And this is a technology problem.
So we can do these in our calculators.
If our time is 0 in 1970, it's going to be 10 in 1980 and 20 in
1990.
So when we look at this, we're going to come up with a
polynomial, so in this case P of T where it's going to equal A+,
BT plus CT squared.
So we're needing to find AB and C So if we write our matricy, we
would have one for our A coefficient.
Our B coefficient for 1970 is going to be 0 because our time
is 0.
Our C coefficient is going to be 0 and the given information was
34.838.
Then if we do 1 coefficient 10 years 10 ^2 or 100 and the given
43.171 and then one 2020 ^2 or 452.786.
Now if we use our calculator to put this in reduced row echelon
form, we can see that our P of T is going to equal 34.838, which
we can actually also see from this top line plus .769 two t +
.00641 T squared.
Then the problem wants us to go on and add 1960 and instead of
having a quadratic, make it into a cubic.
And what we're really trying to do is we're trying to determine
if having more data makes it a better fitting curve or not.
So we're going to add and make this into a cubic equation doing
the same steps that we did a moment ago.
So our new matricy, we're going to let our T be zero for 1960
and 1020 and 30.
So we're going to have 100028 point O 531 ten 10 ^2 10 ^3
34.83812020 ^2 20 ^3 43.17113030 ^2 30 ^3 52.786 grabbing our
technology.
This case, I'm going to use my calculator.
I can get my PT equaling 28.053 + .592233 three t + .00907 T
squared minus .000044333 T cubed.
If we had wanted to add more information we could have taken
it to 1950 and we would have had 010203040 and it would have made
us a quad or a fourth degree equation.
Thank you and have a wonderful.