.
Now, the second part where these n equations, or part of those n equations will
come from is that each spline
has continuous . . .
has . . . not continuous, but has same
slope at
the interior data points, or some people, what they call them
is knots, at the interior
data points.|Now, what does this mean?|So let's suppose I again
draw this, for the sake of completion.
If I look at the first two data points, and then I look at the next data
points right here, next two data points.|So this is x0, y0,
this is x1, y1, and this is x2, y2.
Now, I know that this spline here which goes through those two data points is
a1 x squared, plus b1 x, plus c1, and I know that the spline which goes through
here is a2 x squared, plus b2 x, plus c2,
but as we saw that in linear spline, we have a drawback was that, hey,
each spline is not going through consecutive data points . . . sorry,
the drawback was that the slope is not the same at the interior data
points.|So here what we can do is we can take this, since we have to generate n
more equations, this seems to be a good way of circumventing . . . of answering that
drawback with linear splines, that the slopes are not the same at the interior data points, what I will do is
I will make the slope of this spline to be same as the slope of this spline
at this particular point.|So what that means is that I will take the derivative of
a1 x squared, plus b1 x, plus c1,
and I'll equate it to the derivative of the second spline,
which is a2 x squared, plus b2 x, plus c2,
and I'm going to equate them, but not at any point, but at x equal to x1,
and this also should be at x equal to x1.|So only at x equal to x1,
I'm going to make the derivative of the first spline to be same as the derivative
of the second spline.|So what does that give me?|That tells me that if I take the
derivative I get 2 a1 x, plus b1, calculated at x equal to x1,
is same as 2 a2 x, plus b2, calculated
at x equal to x1, and that gives me 2 a1 x1,
plus b1 is equal to 2 a2 x1, plus
b2.|And since a2 and b2 are
unknowns, in order to be able to set up this equations, I'll have to take it to the left-hand side.|I'll get 2 a1
xi, plus b1, minus 2 a2 x1, minus b2
is equal to 0.|So what you are finding out is that I have been able
to set up an equation which forces the first derivative to be
the same, whether I am using the first spline or the second spline at x equal to x1.
So how many such equations will I get?|What I will get is I have n plus 1
data points, but there are two data points which are on the exterior,
like the first data point and the last data point, I don't have any spline before the first data point,
no spline after the last data point, so that means that I have n minus 1
interior points, and those are the only places where I can
set up this equation of this particular form.|So what I will get is I'll get n minus 1 equations
like that.|So now, if I was going to write down these n minus 1
equations which I'm get from interior data points for a general
point, let's suppose same thing as we did previously,
so let's suppose this is xi, comma, yi, this will be sub-sub-i-plus-1,
y-sub-i-plus-1, and then I'll have here, it will be x-sub-i-minus-1,
comma, y-sub-i-minus-1.|So this particular spline here
will be equal to ai
x squared, plus bi x, plus ci, and this line
here will be a-sub-i-plus-1 x squared, plus
b-sub-i-plus-1 x, plus c-sub-i-plus-1,
and I want the slope to be the same at this particular data point, which implies that 2
ai x plus bi, calculated at x equal
to xi will be same as 2 a-sub-i-plus-1 x,
plus b-sub-i-plus-1, and why we have . . . this
current expression is because we're taking the derivative of this, and that's this and the derivative of
this spline here is 2 a-sub-i-plus-1 x, plus b-sub-i-plus-1,
and that's at x equal to xi.|So then what that means is that 2 ai xi,
plus bi will be equal to 2 a-sub-i-plus-1
xi, plus b-sub-i-plus-1, and how many
such equations will I have?|I'll have n minus 1 equations, so i will take the value of
1 to n minus 1.
So it will take n minus 1 values of i will be taken
by this particular equation here, of course I have to move this, all this to the left-hand side to set
up those n minus 1 equations, so that's what we're talking about, there's n minus 1 interior data points, so we'll
get n minus 1 equations.|So what that implies is that
we already got 2 n equations from the . . . we got 2 n equations from saying
that each spline is going through consecutive data points, and then that
the first slope, or the first derivative, is continuous at the interior data points.
So we had 2 n equations coming from that each spline is going through two consecutive
data points, we have n minus 1 equations coming from the fact that the slopes
are same at interior data points.|So we're going to end up with 3 n minus 1 equations.
So what that implies is that we have to find one more equation, one more equation is needed,
because if I don't have one more equation, I don't have 3 n equations, 3 n unknowns,
so what I will do is I will look at the 3-nth equation will be as follows,
I might say, hey, let a1 be equal to 0, and that becomes my last equation.
So if a1 is equal to 0, that's basically assuming that the first spline is a linear spline,
as opposed to a quadratic spline, and some people will also may take
an equal to 0, based on whether the distance between x0
and x1 is smaller than the distance between x-sub-n-minus-1 and xn, that's
something which you can think about, but for my purposes, I'm going to take a1 equal to 0
to set up the 3 n equations . . . 3-nth equation.|So I have 3 n equations,
3 n unknowns, so once I have 3 n equations, 3 n unknowns, I solve for all
the ais and bis and the cis,
and then I can use those to be able to
interpolate at any point which I want to.|And I'm going to do an example in the next segment to be
able to illustrate that.|And that's the end of this segment.
.