Quadratic Spline Interpolation Application
|
In this
segment, we'll talk about quadratic spline interpolation. We'll look at an
example of how to apply the theory of quadratic spline interpolation. So,
let's recall what we learned in our quadratic spline interpolation theory, you
can always go into the description to find the full playlist of quadratic
spline interpolation. Here, what
we have is that we are given n plus one data points, and what we are doing is
that we are making quadratics go through two consecutive data points. And the
bottom line in quadratic spline interpolation becomes can we find the
coefficients of these quadratics? So, if we have n plus one data points, we
are going to have n such quadratics, and in each quadratic, we're going to
have these unknowns and hence, it becomes a problem of having 3n unknowns and
wanting to find three n equations so that we can solve them simultaneously. So,
let's go and look at look at it through an example. So, here we
are given velocity as a function of time for six data points, and we are
asked to find what the value of the velocity will be 16 seconds, but we're
also asked to find the acceleration 16 seconds, the distance covered from 11
to 16 seconds. So, it is a it is an application
which goes beyond interpolation itself, but let's concentrate first on trying
to find the quadratic splines themselves. So, here is
the data, which was given to us, six data points and I’m showing to you here
in a graph these particular six data points. So, what we are doing is that we
are going to take one spline, this is the first quadratic, the second
quadratic, the third quadratic, the fourth quadratic, and the fifth quadratic.
So, you will have five quadratics which we have to find in order to be able to
develop the quadratic spline interpolation. So, let's make a note of it, we
have five quadratics which we have to find, and there will be 15 unknowns
because each quadratic has three unknowns. So, since
we have six data points, we'll have five quadratics, and these are the
quadratics which are going to exist in the domains given. So, let's suppose
we have the first quadratic which is a1t squared plus b1 t plus c1; it will
exist for the domain of 0 to 10. Then the next one will go from 10 to 15, and
so on and so forth. So, as you can see from here, that we have five
quadratics and each of the quadratics have three unknowns. So, that makes it
the 15 unknowns which we have to find. So, once we've established that we
have to find 15 unknowns, and what domains each of those quadratics are valid
for, let's go and set up the equations. So, the
first part of the theory, which we talked about in the previous videos, that
each spline goes through two consecutive data points. So, if you look at this
particular spline right here, which was termed as a1 t squared plus b1 t plus
c1, and it is from 0 to 10 as mentioned here. This is going through this data
point where the velocity is 0. and the same spline is going through this
point right here at t equal to 10 where the velocity is 227.04. So, that
gives us the two equations for saying that each spline is going through two
consecutive data points. So, let's go and see what the aggregate number of
equations we get by applying this principle that each spline goes through two
consecutive data points. So, we can
see that these two equations which we just derived, we get them or not
derived, we found, was by saying that hey, the first spline is going through
0 and 10. And if we look at this one, that is for this spline going through
10 and 15. As you can see here, the second spline which has a2 b2 and c2 as
its coefficients, but they are going through two points 10 and 15 and using
the corresponding velocities for 10 and 15 there. So, that's the second
spline. The third spline is going between 15 and 20, that gives us this
equation. Then the fourth spline is going from 20 to 22.5, and we get this,
these two equations. And then the last spline is going from 22.5 to 30, and
that gives us this set of equations. So, basically, since each spline is
going through two consecutive data points and we have uh five splines, we'll
get five times two, ten equations from there. So, we are five to go, because
we need 15 equations. We have been able to show that hey, these, this particular
part of the algorithm tells us each spline goes through two consecutive data
points, gives us 10 equations. We also
know that the derivatives are continuous at the interior data points, so we
have six data points but four of them are interior right here. So, if you
look at this particular interior data point right here, it has this spline
that is this one right here, and then it has this spline the second spline
which is right here. They both go through the common interior data point
which is at t equal to 10. So, what that means is the derivative at t equal
10 of the first spline will be same as the derivative of the second spline at
the same point, at t equal to 10. So, derivative of the first spline is 2 a
sub 1 t plus b1, and the derivative of the second spline is 2 a sub 2 t plus
b2. By plugging in the value of 10, we are able to find out what the equation
is, and then we take all of these to the left-hand side because these are the
unknowns. Because whenever you set up equations, you always put the unknowns
on the left-hand side and knowns to the right-hand side. So, since a2 and b2
are unknown, that's why we will take them to the left-hand side and that
gives us the equation which comes from, that the derivatives are continuous
at the interior data points. Since we have three more interior data points
like that, we'll get three more equations, for a total of four equations
coming from the fact the derivatives are continuous at the interior data
points. So, these four equations, which we are getting from that the
derivatives are continuous at the interior data points from the splines,
which go through the common data points. So, at t equal to 10, we have the
first and the second spline going at t equal to 10, they are, they are, they
have a common point there. So, the derivative will be the same, which we just
derived this equation. So, similarly you're going to get another equation for
t equal to 15, another one for t equal to 20, and another one for t equal to
22.5. So, this gives us four equations. We already had 10 equations from
saying that hey, each spline goes through two consecutive data points. Now,
we have four equations which are coming from that the derivatives are
continuous at the interior data points from the, from the splines, which are
going through the common interior point, so we have 14 equations. So, what
that means is that we're still looking for one more linear equation to be
able to set up our 15 equations and 15 unknowns. So, how we're going to do
that? So, the way
we want to do it, was going to say that hey maybe the first spline is linear,
or the last spline is linear. So, we can make this assumption that first
spline is linear, or we can say last spline is linear, and that's going to
allow us to set up the 15th equation because we don't have any other choice
here, or a better choice. Now, the question is that hey, should I choose the
first spline to be linear or should I choose the last spline to be linear
will depend on which one is the better assumption to use. So, we can already
see that hey, the difference here is 7.5 of the x values, of the t values,
and the difference here is 10 so far as the distance between the two points
is concerned. So, it's better to choose the last spline to be linear, because
the distance between the two last points is less than the distance between
the first two points. So, that's why we chose a sub five equal to zero, that
is the last spline is linear. So, we can
see that we can go and recall that we have 15 equations, and we have 15
unknowns and let's recap. The 15 equations came from: 10 equations came from
that each spline goes through two consecutive data points, four equations
came from that the derivative is the same at the common points of the two
splines which go through that point, that gives us four more equations, that
makes it 14, and then we had to somehow find out what the 15th equation would
be. And in this case, we chose that the last spline is linear, giving us a
sub 5 equal to 0. So, here
what we are doing is that we are taking all those 15 equations and putting
them in the matrix form because you want to solve them in the matrix format
to be able to make any sense out of it. So, you can also see that this
coefficient matrix right here is very sparse. In fact, you can make it more
banded; banded meaning that there'll be more zeros in the, in this area, and
more zeros in this area. If you rewrite these equations where, for example,
this number here or this equation is written somewhere close to, let's
suppose, this equation right here. We're not done that because what we did was,
we took the first 10 equations, wrote them here and then we wrote the next
four equations and then we wrote the last equation. But if they are written
in the proper format, you're going to get a banded coefficient matrix:
meaning there are lots of zeros in the off-diagonal areas here, lots of zeros
here in the off-diagonal areas here because there are some special algorithms
written for solving equations which are banded in nature so far as the
coefficient matrix is concerned. But we're not getting into that, we're
simply saying we have 15 equations 15 unknowns, let's go and solve it by any
method which is available to us. So, we
found out what the 15 unknowns are, because we have 15 equations 15 unknowns.
So, here what we are doing is that since each quadratic is of the format,
this one. So, we are just writing those coefficients of the quadratics here,
and since we had six data points hence, five quadratics. So, we'll have five
such values, five such rows here for the values of a b and c. Now what we're gonna do is, we're going to write it in the quadratics
format which we assumed, and let's go and see what we're going to get. So, here we
have the, the coefficients which we found out by solving 15 equation, 15 unknowns.
This is there just for reference, so you can see that hey, this will be my
first quadratic, that's my second, third, fourth and fifth quadratic. And keep
in mind also, that each quadratic is only valid for a certain domain. So,
that's very important to understand that hey, that this is not like
polynomial interpolation where it is valid between the minimum value of x and
the maximum value of x. That's not the case here because each quadratic is,
has, has its own domain in which it is valid. So, this is the graph of the
quadratic polynomial interpolation, quadratic spline interpolation which
you're seeing here, and you can maybe not visually see it here, but you can
also see that the slopes seem to be continuous right here at the interior
data points based on what we have found out. Let's go and solve the problem
at hand, which is finding the value of the velocity at 16. So, part a
of the problem was to find the value of the velocity at 16. Now, we have
these five quadratics here, so we cannot just simply pick and choose which
quadratic needs to be used. So, since it is 16, we know that this is the
proper quadratic to use because this quadratic is valid between 15 and 20.
So, having said that, we will go ahead and take this quadratic right here,
and put the value of t equal to 16 seconds in there. So, as to be able to
find out what the value of the velocity is at16. The next
part is asking you to find the acceleration at 16. Again, what we have to do
is we have to find the proper quadratic to use, and since 16 is between 15
and 20, we will use this quadratic right here. But since we are trying to
find the acceleration at 16, what we have to do is we have to take the
derivative of the velocity expression, or the velocity quadratic and then put
t equal to 16 in there. So, let's see how we can go about doing that. So, we
chose the proper quadratic; we'll take the derivative of the quadratic, one
derivative of it, and this becomes our acceleration expression now, for which
is valid in the same domain as the velocity expression between 15 and 20. And
we want to find the acceleration at 16, all we have to do is to put t equal
to 16 in there, and we get an acceleration of 32.261 meters per second squared. Let's look
at the last part, which is saying hey, can you calculate the distance covered
by the rocket from 11 to 16 seconds? So again, you may have to you will have
to choose the proper quadratic or quadratics in order to do this problem. So,
you can see that hey, if I want to go from 11 to 16, part of it is in this
domain, and part of it is in this domain. So, that means that you'll have to
use this spline as well as this, sorry you'll have to use this quadratic as
well as this quadratic of the quadratic spline. So, that means that this has
to be broken from 11 to 12, 11 to 15 for the first spline, and then from 15
to 16 for the next spline. So, this will be, this velocity here will be
coming from the second spline here, because that's the value between 11 and
15, and this one will be coming from the quadratic, which is valid between 15
and 20, but of course we'll integrate only from 15 to 16. So, let’s go and
see what we get from there. So, we
already chose the proper two quadratics, we need two quadratics for here. We broke
it up into two integrals: one going from 11 to 15 and one from 15 to 16 so
that we can put the proper quadratics in there. So, what we do is we put the
first quadratic for the integral going from 11 to 15, and the second
quadratic from 15 to 20. When I say first quadratic meaning, the first one
which is in the domain of 11 to 16, it is the second, second quadratic and
the third quadratic which we are using if you look at all the quadratics. So,
you get the point; so, here we're going to integrate this function and
integrate this function by using our integral calculus knowledge, and we get
that the location difference between 11 and 16 seconds, which would give us
the measure of the distance covered from 11 to 16 seconds turns out to be
1590.7 meters. And that is the end of this segment. |