 Hi, we are discussing piecewise polynomial interpolations. We have seen that piecewise polynomial interpolations give good approximations to our functions. However, they are not differentiable at the node points right. In order to rectify this disadvantage, in this lecture we will discuss another type of piecewise polynomial interpolations called spline interpolations. We will first define spline interpolations and then we will learn to construct cubic spline interpolant of a given function. Let us see what is mean by a spline interpolating function. A spline interpolation function of degree d at the nodes x naught, x 1 up to x n for a given function f is a function which we denote by s of x with the following properties. Note that the degree of this plane is nothing to do with the number of nodes that are chosen. In polynomial interpolation, the degree of the interpolating polynomial depends on the number of nodes that is chosen right. So, we should not get confused with the degree of the plane with the degree of the interpolating polynomials. Let us go to see what are all the properties that this function s should satisfy in order to be a spline interpolating function of the given function f at these node points. The first property is that when you restrict to each sub interval x i minus 1 to x i, then the function s of x should be a polynomial of degree less than or equal to d. Up to here you can see that s of x is a piecewise polynomial and of course, if you also impose the interpolation condition, then it will become a piecewise polynomial interpolation that is what we have learned in one of our previous lectures. In addition to that, spline also demands certain smoothness of the function s in the entire interval a to b. Remember, since s is a polynomial in each of the sub intervals, this smoothness should be mainly achieved on the node points x i's. However, as a definition we say that s of x is continuously differentiable up to order d minus 1 in the interval a to b in which we are interested in approximating the function f by this plane. And the last condition is of course, the interpolation condition that the function s should satisfy the interpolation condition with the function f at all the node points. Therefore, the first condition and the third condition together will say that s is a piecewise polynomial interpolation and the additional condition that it should be d minus 1 times continuously differentiable on the interval x naught to x 1 is what is demanded in addition to the piecewise polynomial interpolation. In our course, we will restrict ourselves to d is equal to 3 in which case we call this plane as cubic spline interpolation. We will use a rather direct method to construct cubic splines. There are also other methods with which we can also construct higher degree spline interpolations, but we will only restrict to this simple case. Let us see how to construct cubic spline interpolation. Remember, we are given n plus 1 node points x naught x 1 up to x n. Let us have a notation m i to denote the second derivative of s at the i th node point x i. And the idea is to first obtain an expression for s of x in terms of m i's and then we will go to find precisely the values of this m i's. Now, once you take this notation, you can see that since s is a cubic polynomial in the interval x i minus 1 to x i, you can see that s double dash of x is a linear polynomial on this interval. Therefore, you can easily find the equation for s double dash in the interval x i minus 1 to x i because we know that it is a straight line joining the points x i minus 1 comma m i minus 1 and x i comma m i. With this, you can immediately write the expression for s double dash of x like this for all x in the interval x i minus 1 to x i. Now, once you have this, you can get s of x by integrating s double dash twice. So, that is what we will do. We will integrate s double dash two times with respect to x and that gives us this expression. Note that when you integrate for the first time, you will get an integrating constant because it is an indefinite integral. We will denote it by k 1 and then when you go to integrate it for the second time, we will get another integrating constant which we will denote by k 2. Therefore, in the interval x i minus 1 to x i, you need to now find k 1 k 2 m i minus 1 and m i. There are four unknowns to be determined in the interval x i minus 1 to x i and we have to do this in each of the subintervals. Let us first try to find k 1 and k 2. Remember, how are we going to find all these unknowns? We of course have certain conditions imposed in the definition of spline interpolation. One is it is a polynomial of degree d in each of the subintervals. In our case, d equal to 3. So, we have already used that condition that is s is a cubic polynomial in each of the subintervals. We have already used that condition in order to arrive at this expression for s in each subinterval. Now, what are all the other conditions we have? We have to use the interpolation conditions at the node points. In this interval, the node points are x i minus 1 and x i and we have certain smoothness conditions also. Let us see how to use these conditions in order to obtain all these unknowns. First, let us use the interpolation condition at the node points x i and x i minus 1. So, if you put x equal to x i minus 1, then on the left hand side, you will have f of x i minus 1, which is assumed to be known to as and now you have to put x i minus 1 here and x i minus 1 here. That will make the second term 0 and you will have x i minus 1 here. Similarly, you have another equation when you put x equal to x i and that will make this first term to become 0, but you will have the second term plus k 1 into x i plus k 2. So, you have two equations with of course, four unknowns, but now our aim is to only find k 1 and k 2 in terms of m i and m i minus 1. Therefore, we will not touch upon this m i's while evaluating k 1 and k 2. So, we will just treat k 1 and k 2 as unknowns and we will solve this linear system of two equations with unknowns as k 1 and k 2 and you can get k 1 as this expression and k 2 as this expression. So, you can easily check these conditions. Therefore, we got two unknowns k 1 and k 2 by imposing the interpolation conditions. Now, we have to get m i's that is m i and m i minus 1 in the interval x i minus 1 to x i. How are we going to do that? Well, for that let us consider the expression for S of x. Now, we have eliminated k 1 and k 2 in the expression of S by substituting these two expressions into it and we got this expression. In this, we are yet to find m i minus 1 and m i and we will use the continuity of S dash of x. Remember, we have used the fact that S is a cubic polynomial. We also use the fact that S double dash is continuous. How we did that? Because that is the way we have constructed S double dash. You can see that S double dash coincides at the boundary points because at x i whether you approach from this side or this side S double dash of x i has to be m i. So, in that way the continuity of S double dash is already used in this step and we have used S is a cubic polynomial. That is how we have taken the expression for S double dash as a straight line joining two points and we also used the condition that it is an interpolating polynomial. So, that is how we got k 1 and k 2. Now, we are left out with only one condition that S dash is continuous. We will use this condition in order to get the values of m i and m i minus 1. Let us see how to do that. What you do is at every node x i, you have a polynomial from this side and you have another polynomial from this side because S is a piecewise polynomial interpolation. Therefore, in each sub interval x i minus 1 to x i and x i to x i plus 1, you have different polynomials. Now, you take this polynomial say p 1 and p 2 and you find the derivative of this polynomial. Then you have to equate them in order to achieve the continuity of p dash at this node. So, what you do is you have S in this interval that is given by this expression in the interval x i minus 1 to x i. Similarly, you write S of x in this interval. Then take the derivative of S in these two intervals and then equate them. So, you just have to equate them and this has to be done for all the sub intervals. Note that you can do this at x 1 because you have the interval x naught to x 1 and x 1 to x 2. You can approach from the left and you can approach from the right for the function S dash to get a condition at this point. Similarly, to get a condition at x 1, you approach from left and you approach from right from this interval x 1 to x 2 and that will give you one condition here. Similarly, you can get up to x n minus 1. Note that at the points x naught and x n, you cannot impose this idea because we only have the polynomial approaching from one side from the other side. You do not have a polynomial to obtain m naught and similarly, you do not have the polynomial to approach from the right in order to get m n. Therefore, m naught and m n are excluded from this idea. Otherwise, for all i equal to 1 to n minus 1, you can find the corresponding values or m i using this continuity property of S dash and you can see that imposing the continuity property of S dash at each node x 1, x 2 up to x n minus 1 will give us a tridiagonal system of linear equations. You can derive and see, I will not show you the derivation. It is little lengthy, but very simple to do. I leave it to you to see how to bring this tridiagonal system. You can see that for each i, you have non-zero entries only on the tridiagonal positions. Otherwise, all other entries are zeros and this is a tridiagonal system with unknowns as m 1, m 2 up to m n minus 1. By solving this tridiagonal system, we can get all these constants except m naught and m n. We cannot get them using this idea. So, what we will do is we will take m naught is equal to 0 and m n equal to 0. There is no reason for why we choose like this. This is the way we choose the constants m naught and m n and we will call the resulting plane as natural plane. So, this is the construction of cubic natural plane interpolation of a given function. Cubic plane because we have imposed the smoothness of degree 2 at the nodes and also from the way it is constructed, you can see that s is a piecewise cubic polynomial and the name nature is because we have chosen m naught and m n like this. There are other ways to choose these constants. Different way of choosing these constants will lead to different planes, but natural plane means you have to choose m naught and m n as 0. There is no reason for why it is like this. This is the way in the literature people have used it. Let us see an example. Let us try to construct the natural cubic plane interpolation for the data set given to us. You can see there are four node points and the value of the function at these node points are given like this. From here you can see that the function that we are considering is f of x equal to 1 by x. Let us see how to construct the natural cubic plane. Since it is natural, first thing is you simply take m naught is equal to m 3 equal to 0. Here n is equal to 3 because we start from x naught, then x 1, x 2 and x 3. So, n is equal to 3. So, you have to take m 3 as 0, but you have to find m 1 and m 2 by constructing a system of linear equations. It is just a 2 by 2 system. Therefore, there is no clear tridiagonal structure is visible in this case. However, to construct the system, you can use this formula which we have derived in our construction. You just plug in the values of x i and f of x i given in this data set. You can see that for each i, this is just 1 and you have the corresponding values for this. Therefore, for i is equal to 1 and 2, you can get two equations for m 1 and m 2. They are linear equations given by this for i is equal to 1 and this equation for i is equal to 2. You can see that it is a linear system with two equations. Since it is only two, you do not see this tridiagonal structure in this system. However, you can easily solve this system by using Gaussian elimination method also and thereby, you will get the value of m 1 and m 2. Already, you have the values of m naught and m 3. Therefore, you obtained all the constants m naught, m 1, m 2 and m 3. Now, you have to plug in those constants into the expression of the cubic plane interpolation. Remember, you have to do this in each of the subintervals. From x naught to x 1, you have to plug in m naught, m 1 and you will get this cubic polynomial. Similarly, you have to do it for the interval x 1 to x 2, that is 2 to 3. Here, you have to plug in m 1 and m 2 and you will get this polynomial. Similarly, you will get this polynomial. Similarly, in the last subinterval, you get the polynomial as this. Here, you can see that S is a piecewise cubic polynomial. Here, cubic means the degree is at most 3, not exactly 3. So, this is how we generally define the interpolating polynomials. In the first interval, it is a cubic polynomial. In the second interval also, it is a cubic polynomial. But in the third interval, it is only a linear polynomial, but that does not matter. We want S to be a polynomial of degree less than or equal to 3 in each of the subinterval. Therefore, this is fine and this is the natural cubic plane interpolation for the given data set. With this, we will close this class. Thank you for your attention.