Quadratic Spline Interpolation Theory
|
In this
segment, we'll talk about quadratic spline interpolation; we will only
concentrate on the theory. If you want to see an example of quadratic spline
interpolation, just look at the link and, given in the description for the
playlist. So, before
we talk about linear spline, quadratic spline interpolation, let's recall
what we learned in the linear spline interpolation. In linear spline
interpolation, we took the data points which were given consecutively from
one point to another and simply drew a straight line, and one of the things
which you are automatically seeing is that the, look at this interior data
point where the slope, for example, coming this way is negative going this
way is positive. And what, and that is an artificial change in slope which is
taking place. So, the, there's a discontinuity in the slope at the interior
data points. So, how do we go about avoiding that? That's something which we
have to think about. The other thing is that, if you look at this particular straight-line
approximation of the data from this point to this point, it only depends on
the values of x naught and y naught and x1 and y1. Does not depend on any sub,
the other values. So, that also is sort of a pitfall of the linear spline
interpolation. So, how do we overcome that? We can overcome that by using
something called quadratic spline interpolation, or cubic spline
interpolation. In this particular segment, we are only going to talk about
quadratic spline interpolation. So, let's
look at the theory of the quadratic spline interpolation. So, you have n plus
one data points given to you, and what you want to do is you want to fit an
interpolating quadratic spline through the data. So, what that simply means
is that you want to have n such splines, n such quadratics, not splines,
quadratics going through these n plus one data points as shown here. So, like
for example, if you look at the first two data points right here, x naught
comma y naught and x1 comma y1, what you have is a second-order polynomial
quadratic going through those two points. And same thing is the case for the
next two, and so on and so forth all the way up to the last one, which is x
sub n minus 1 and y sub n minus 1 x sub n and y n. What you are finding out
that you have a second order polynomial, or a quadratic going through that as
well. So, what we are finding out here is that we are simply using quadratics
to approximate the curve, approximate the data from x naught to x n, and each
of these quadratics have three unknowns like you have a1 b1 c1 or a2 b2 c2. So,
you'll have n of the a, a's, a’s n of the b's and n of the c's, so that means
that hey, you have three n unknowns. So, we have three n unknowns, it makes
sense that hey, somehow, we have to find three n equations. Now, it's not
easy like in linear spline interpolation, where just by looking at the two
consecutive points we're able to find the unknowns because in this case, we
have only we know that each this spline here is going through two points. That
will only set up two equations, but we have three unknowns. So, let's see how
we go about trying to address the question that hey, if we have three n unknowns
how do we set up the three n equations, so that has to be able to solve three
and simultaneous linear equations? So, the
first thing which you have to recognize, is that each quadratic goes through
two consecutive data points. What does that mean? So. we'll take one example,
and then we'll generalize it. So, let's suppose we look at this first
quadratic, we have a1 x squared plus b1 x plus c1, and what you're finding
out that hey, it goes through x naught, y naught and it also goes to the
point x1, y1 right here. So, if it is going through those points that means
that a1 x naught squared plus b 1 x naught plus c1 should be equal to y
naught, and we call it the value of the function at x naught. Same thing that
a1 x1 squared plus b1 x1 plus c1 should be equal to y1, and that's nothing
but the value of the function at x1. So, we are setting up two equations for
each of the quadratic, which is going through two consecutive data points. So,
that'll be the same case here for the second quadratic also, you will be able
to set up two equations, and so on and so forth, `till you reach the last
quadratic, where you can also set up two equations two unknowns because it
goes through two points. So, let's go and see that how those look and how
many equations are we going to set up that way. So, in the
previous slide, we saw that how we derived that the each of the splines is
going through two consecutive points. So, we, right here is the is what we
had derived on the previous slide. So, this will be the case for all other
quadratics going from the second quadratic all the way to the nth quadratic. So,
if you look at the general formula, or general equations which you're going
to get for the i’th quadratic, it will be this one,
and this one. And there will be n such pairs of
equations available to you. This is the one which is going through the last
quadratic, it is going through the point x sub n y sub n minus 1, and through
the point x sub n y sub n. That's why we are getting an equation like this
one an equation like this one. So, if you look at what are the limits of i, you will say i goes from 1
to n because hey, this is the first quadratic and this is the nth quadratic. So,
each of the quadratics results in two equations. So, that means that you have
two n equations which you will be able to write down from the premise that
each quadratic is going through two consecutive points. Since the total
number of equations which we have to develop is 3 n, so that implies that we
have to develop n more equations, and let's go and see where those n
equations are going to come from. So, we have
to develop n more equations, so as to be able to set up our total of 3n equations
and recall from the linear spline interpolation that what we found out is at
the interior data points, we are not getting continuity in the slope, or
continuity in the first derivative. So, maybe by using the quadratic spline
interpolation, we can ensure that happening now that the first derivative
will be continuous at the interior data points. So, let's go and take this
part right here. So, if you look at that part there what we have here is that
this is the first quadratic, and this one is the second quadratic. This point
is the first data point, let's suppose, and this one is the second data point,
and this one is the third data point which we have here. And what we are
saying is that at this common data point which we have between this spline
and this spline, that the derivative is going to be the same. So, what that
means, that we have to equate the derivative of the first spline and make it
equal to the derivative of the second spline, but you've got to keep in mind
that it is not same everywhere. It's only same at the common point, which is
at x equal to x1. So, the derivative of this will be 2 a1 x plus b1, and we
want to calculate it at x1, and the derivative of the right-hand side will be
2a 2 x plus b2, and we want to calculate the same point x1, which will ensure
that the first derivative is continuous at that interior data point. So, we
get 2 a1 x1 plus b1 is equal to 2 a2 x plus b2, and since a2 and b2 are the
unknowns, we'll have to take them to the left-hand side. We'll get 2 a2 x1
plus b1 minus 2 a2 x1 minus b2 equal to 0. So, that is the equation which we
are getting by saying that the first spline and the second spline have a
continuous slope at the common point x equal to x1. And since we have so many
interior data points, let's go and see how many such equations can we develop. So, going
back, this is the equation which we developed for the continuity of the slope
at the interior data point x1 y1, and so for the i'th
interior data point, our continuity of slope will be given by that particular
equation right there, and this one is for the last interior data point right
here which is this one right here, is then we get equation from there and
this one we got from the first one. So, what you got to, what you got to
think about now is that hey, how many such equations do I have? I have n plus
1 data points, and I have n minus 1 interior points, because there are two
exterior points. One is this one, and one is this one. Those two are exterior
points at which we cannot apply the condition that the slopes are continuous,
because there's no quadratic before this one and there's no quadratic after
this one. So, we'll get only n minus one equation so we're going to get n
minus equations from equating the slopes at the n minus one interior data
point. So, so far, so far, we have two n equations coming from that each
quadratic goes through two consecutive data points, and then we have n minus
equations coming from the slopes are continuous at the interior data points
from the common, from the splines, which are connected to that point. And we
get 3n minus 1 equations. So, this leaves us a
little bit of query that hey, where am I going to get that last equation from,
so that the total number of equations turns out to be 3n? So, since we have 3
equations, 3n minus 1 equations, we need 3n
equations. We got to find that what that one last equation would be. So, what
we do is we choose either a1 equal to 0 or a n equal to 0. So, what do we
mean by that, is that if you look at the first spline, that is this one, and
if we choose a1 equal to 0 as our last equation, that means that we are
basically assuming that the first plot, first quadratic is a linear one actually. And if we look at the last, last quadratic,
which is this one, by assuming an equal to 0 we're basically saying the last
quadratic is also a straight is, is a straight line. So, the question arises
that since we only need one more equation, do we choose a1 equal to zero or a
n equal to zero? A simple thing can be simply to check hey, is x1 minus x
naught, which is the distance between the two point first two points, and we
look at the distance between the last two points on the x-axis right here. If
this turns out to be less than, so if you find out that hey, x1 minus
x-naught here is less than or equal to what we have as the distance between
the last two points on the x-axis, then we will choose a1 equal to zero
because the smaller distance. So, assuming it will be linear in the smaller
distance part might be a better assumption to make. Else, we choose a n equal
to zero. So, it's a nice if loop which is taking place based on what criteria
you're going to use, based on the criteria you're going to use. Whether a1,
a1 would be 0 or a n equal to 0. So, we have 2 n equations coming from that
each quadratic spline goes through two consecutive data points, we have n
minus 1 equations coming from that hey, the slopes
are continuous at the interior data points, and then we have one which is
coming from this one right here, and that gives us 3n equations. So, now we
have 3n equations 3n unknowns and all we have to do is to solve these 3n
simultaneous linear equations by any method which is plausible and be able to
find out what the coefficients of these quadratics are. So, let's
go and summarize again, and set up these 3n equations here. What we said that
each quadratic goes through two consecutive data points, so these are the two
equations which you're going to get the i'th, for
the i'th quadratic, and since we have n quadratics,
we're going to get 2n equations from here. Then the first derivative is same
of the quadratics at the common point, so like these common points. Whatever
spline is going through that common point, you'll find out that the first
derivative will be the same. So, we'll get n minus 1 such equations because
we have n minus 1 interior points because two of them are exterior. Total
number of points is n plus one, and then we said hey,
we're going to get one equation from here because either we'll assume that
the first spline is, the first quadratic is linear or we're going to assume
the last quadratic to be linear. So, we get 2n equations, plus n minus one
plus one. We are reviewing it this again, we get 3n equations we have 3n
unknowns. So, we have 3n unknowns, and those 3n unknowns which we have are the a sub i's, are the a sub i's which is going from one to n, the b sub i is going from
1 to n, and c sub i is going from i is equal to 1 to n. And you
can also look at it that hey, since each quadratic has 3 unknowns, and since
we have total of n quadratics, we'll get 3n unknowns. So, we have 3n
equations three unknowns, and we are able to find out what these unknowns are
a sub i's, b sub i's and c sub i's, and that's the theory behind the
quadratic spline interpolation, and that is the end of this segment. |