 In our last lecture, we considered piecewise linear and piecewise quadratic approximation. Today we are going to consider piecewise cubic polynomial approximation. So, first we will consider piecewise cubic Hermite interpolation in that our approximating function is going to be continuously differentiable and we will interpolate the given function and its derivative values at the partition points of our interval a b. Next we will consider cubic spline interpolation. Cubic spline is going to be a piecewise cubic polynomial which is overall differentiable c 2. That means it is two times continuously differentiable and it will interpolate the given function f its values at the partition point. In the case of piecewise cubic Hermite interpolation we will show that the error is going to be less than or equal to constant times h raise to 4, where h is length of the sub interval which is b minus a by n if we are dividing our interval a b into n equal parts. In case of cubic spline interpolation the error is going to be less than or equal to constant times h square or constant times h raise to 4 depending upon the end conditions which we impose. In the case of cubic spline interpolation it will be necessary to add to the n plus 1 interpolation conditions two more extra conditions which will make our cubic spline a unique function. For the cubic Hermite polynomial the construction is going to be straight forward and the error analysis also is straight forward. It will be like in the case of piecewise linear and piecewise quadratic polynomial. The drawback in piecewise cubic Hermite interpolation is we need to know the derivative values of the function at the partition points which may not be available that is why one goes to cubic spline interpolation. Let me recall cubic Hermite interpolation. So, when we have a function f defined on interval a b to real line look at p 3 to be a polynomial of degree less than or equal to 3 such that p 3 at a is equal to f of a p 3 at b is equal to f of b and p 3 dash at a is equal to f dash a p 3 dash b is equal to f dash b where dash denotes the derivative. So, that means we need to assume the function f to be differentiable. We have seen that p 3 x can be written in terms of divided differences as f of a plus x minus a f dash a plus f of a plus f of a plus f of a plus divided difference based on a a b the point a is repeated twice multiplied by x minus a square and plus the divided difference based on 4 points a a b b a repeated twice b repeated twice x minus a square x minus b. The error f x minus p 3 x is given by f of a a b b x multiplied by x minus a square x minus b square for x in the interval a to b. So, this is the error. Now, if f is 4 times differentiable then we can write the divided difference as 4th derivative of f evaluated at some point c, c is going to depend on x divided by 4 factorial x minus a square x minus b square. Now, we look at the maximum error. So, maximum of modulus of f x minus p 3 x x belonging to a b to be less than or equal to maximum of mod of f 4 x is equal to f of a plus f of a plus f of a plus f of a plus x divided by 4 factorial x belonging to a b and multiplied by maximum of modulus of x minus a x minus b square x belonging to a b. Thus norm of f minus p 3 infinity norm is going to be less than or equal to norm f 4 infinity divided by 4 factorial and the maximum is going to be attained at the midpoint a plus b by 2. So, that will give us b minus a by 2 raise to 4. So, thus we have obtained the norm of f upper bound and upper bound for the cubic hermit interpolating polynomial. This upper bound we are going to use for finding an upper bound for the error in the piecewise cubic hermit interpolation. So, it is this bound is applicable on interval a b. So, the same bound we will use with interval a b replaced by interval t i to t i plus 1, where i going from 1 to up to n minus 1 and that will give us the an upper bound for the error in the piecewise cubic hermit interpolation. If defined on interval a b taking real values, the differentiability property of f which we are going to need is f should be 4 times differentiable on a b and the fourth derivative should be continuous on interval a b because we are going to take the maximum of mod of f 4 x for x belonging to a b. We look at uniform partition a is equal to t 0 less than t 1 less than t n is equal to b, t i plus 1 minus t i which is length of the sub interval which is equal to h that is b minus a by n. Let us look at x n to be set of all f or let me write g set of all g belonging to c 1 a b. So, the all functions which are continuously differentiable such that g restricted to t i to t i plus 1 is a polynomial of degree less than or equal to 3. Then the dimension of x n is equal to we had done such calculation before on each interval it is a polynomial of degree 3 degree less than or equal to 3. So, we have got 4 degrees of freedom, there are n intervals so that it will be 4 n minus there are n minus 1 interior nodes t 1, t 2, t n minus 1. We want the function to be continuously differentiable that means at each of the interior node we are putting two constraints. So, then those two constraints they will decrease the dimension of our space. So, it will be 4 n minus 2 into n minus 1 so that is going to be equal to 2 n plus 2. So, we have dimension of x n to be equal to 2 n plus 2. If we consider a value of function f at t i's and the derivative values at t i, we have got n plus 1 partition points and if we say that look at a function g which is going to be continuously differentiable and which is piecewise cubic on the interval t i to t i plus 1 and it interpolates our function f and the derivative at this n plus 1 point. So, dimension of our space is 2 n plus 2 we are putting 2 n plus 1 condition 2 n plus 2 conditions and then such a function is going to be unique. We have f is from a b to r and g n should belong to x n such that g n at t i is equal to f at t i and g n dash at t i plus 1 plus 1 t i should be equal to f dash at t i i going from 0 1 up to n. So, we have this is our partition and we are specifying at all the partition points value of g n at t i and value of g n dash at t i. So, by very construction our g n is going to be belonging to x n and g n x will be given by on the interval t i to t i plus 1 because it is a cubic polynomial it is g n at t i plus g n dash at t i into x minus t i plus g n t i t i t i plus 1 the divided difference into x minus t i square plus g n dash at t i plus 1 divided difference based on 4 points t i t i t i plus 1 t i plus 1 x minus t i square x minus t i plus 1. So, exactly similar formula as on the interval a b only now the interval is t i to t i plus 1 we had found the bound for the interval a b and that bound was norm of f minus p 3 infinity norm to be less than or equal to norm f 4 infinity divided by 4 factorial b minus a by 2 raise to 4 and hence maximum of mod of f x minus g n x x in the interval t i to t i plus 1 this will be less than or equal to maximum of mod of f 4 x x belonging to t i to t i plus 1 divided by 4 factorial and then we have to replace b minus a by h. So, we are going to have h by 2 raise to 4 now this will be less than or equal to norm f 4 infinity divided by 4 factorial h by 2 raise to 4 the bound which we I am writing now that is true for each i and hence when we look at maximum of mod of f x minus g n x x belonging to a b this is going to be equal to maximum over i maximum of mod of f x minus g n x x belonging to t i to t i plus 1 0 less than or equal to i less than or equal to n minus 1 which will be less than or equal to norm f 4 infinity by 4 factorial h by 2 raise to 4 and this is norm of f minus g n infinity this is the error for the error piecewise cubic hermite interpolation. Let us recall the bounds for piecewise linear and piecewise quadratic. So, in case of piecewise linear our function was continuous and the error it was less than or equal to constant times h square where the constant in one order is called the second derivative. In case of piecewise quadratic again the function is continuous and the error now is less than or equal to norm f triple dash infinity that means the third derivative is coming into picture divided by 92 root 3 into h cube and now for piecewise cubic hermite interpolation our function is continuously differentiable and the error is less than or equal to constant times h raise to 4. So, the constants in the three cases they are going to be different, but these are the constants which are independent of h. So, in case of piecewise cubic hermite interpolation we have got the error to be constant times h raise to 4 which will tend to 0 faster than in the case of piecewise linear and piecewise quadratic polynomials and in addition our function is continuously differentiable the approximating function is continuously differentiable. The only problem is the derivative of f at t i's they may not be known. Next we go to cubic spline interpolation we want our approximating function to depend only on the function values at the partition points and if possible we will like to make our function to be two times differentiable. When we looked at joining of two polynomials together we have seen that if you join two cubic polynomials together in C 2 fashion still we retain the piecewise nature of our function. On the other hand if we say that the there are two cubic polynomials and you join them together such that the function value derivative value second derivative and third derivative values they should match then it has to be a single polynomial. So, the best we can do by the still retaining the piecewise nature is a piecewise cubic polynomial which is two times continuously differentiable. Now, here the construction of such a function is going to be little more complicated. So far we could write we could look at the divided differences and then we could write down the explicitly our approximating polynomial or approximating piecewise polynomial. Now, here in case of cubic spline interpolation. So, look at as before the uniform partition and look at the space x n to be set of all f belonging to C 2 a b such that f restricted to T i to T i plus 1 is a polynomial of degree less than or equal to 3 i is equal to 0 1 up to n dimension of x n is going to be 4 times n minus 3 times n minus 1 n intervals on each interval a polynomial of degree less than or equal to 3. So, that is why 4 n degrees of liberty and then at the interior partition points T 1, T 2, T n minus 1 we want the function to be 2 times differentiable. So, that is why you have got minus 3 into n minus 1. So, then that is going to be equal to n plus 3 suppose our function f is defined on interval a b to real line and look at g n belonging to x n such that g n at T i is equal to f at T i, i is equal to 0 1 up to n. So, these are n plus 1 conditions the dimension of the space is n plus 3. So, in order to have such a unique interpolating function we will need to add two conditions. Now, these two conditions generally they are put at the two end points and those are the end conditions. So, we will come to the end conditions little later. Let us look at the construction of g n on the interval T i to T i plus 1 g n is going to be a polynomial of degree less than or equal to 3. So, suppose you have got g n at T i and g n at T i plus 1 they are already fixed they are equal to f is our function which is given to us. So, g n at T i is equal to f at T i, g n at T i plus 1 is equal to f at T i plus 1 treat the derivative values g n dash at T i and g n dash at T i plus 1 as unknowns and use the fact that our g n is going to be two times differentiable to get a relation which will be satisfied by g n dash T i. So, the unknowns g n dash T i they will be obtained by solving a linear system of equations and then once you get g n dash T i on the interval T i to T i plus 1 our polynomial of degree less than or equal to 3 will be determined because we know g n T i, g n dash T i, g n at T i plus 1, g n dash at T i plus 1. So, let me explain how we are going to get the relation. So, let us look at two intervals. So, this is our interval T i to T i plus 1 and this is interval T i minus 1 to T i. Here let me denote the polynomial by T i. So, that is g n restricted to T i to T i plus 1 the polynomial here we denoted by T i minus 1. So, it is going to be g n restricted to T i minus 1 to T i. The polynomial P i we are going to write in terms of the value of g n at T i and value of g n dash at T i. So, at present the derivatives are unknown. So, we have got P i x to be equal to the same cubic hermit polynomial g n at T i plus g n dash at T i into x minus T i plus divided difference based on T i, T i plus 1 x minus T i square plus g n T i, T i, T i plus 1, T i plus 1 x minus T i square x minus T i plus 1. So, how is it different from the cubic hermit interpolation? In case of cubic hermit interpolation we wrote exactly the same formula, but g n dash at T i was given to us g n dash at T i was equal to f at T i. Now, in our case g n at T i is going to be equal to f at T i that is given to us, but at present g n dash at T i they are going to be unknown. So, this is we have found or we have written down a formula for the cubic polynomial in the interval T i to T i plus 1 in terms of g n at T i, g n dash at T i of which g n dash T i are unknown. Now, you look at the second derivative. So, we can calculate P i double dash x. You calculate the second derivative and then you look at P i double dash of T i plus and P i double dash at T i plus 1 minus. We have got a formula for P i x take its second derivative. The second derivative will be in terms of again g n at T i and g n dash at T i. I have written P i double dash at T i plus because our P i is defined on the interval T i to T i plus 1. So, the second derivative is at T i is going to be the right handed derivative and at T i plus 1 it is going to be left handed derivative. So, we calculate these values then from here we write P i minus 1 double dash at T i plus double dash T i minus 1 plus and P i minus 1 double dash T i minus. So, once we obtain the formula for this you have to just shift replace i by i minus 1 in order to get this expression. Now, this continuity of second derivative comes into picture. What we want is we want P i double dash at T i plus is equal to P i minus 1 double dash of T i minus. The value of the second derivative from the right and value of the second derivative from the left we equate these two and that is going to give us a relation which the derivatives they should satisfy. So, now what comes is the technical thing like I have explained to you what is the idea and now let us work out the details. Look at the interval T i to T i plus 1 and then we have written G n x in terms of G n T i G n dash at T i and then the divided differences. These divided differences they also will be in terms of the value of G n at T i and value of G n dash at T i. Now, look at the derivative. So, when you take the derivative you get G n dash at T i the G n at T i is constant. So, the derivative term vanishes then we have G n dash at T i plus the divided difference based on T i T i T i plus 1 the derivative of x minus T i square which will be 2 into x minus T i plus the divided difference based on T i T i T i plus 1 T i plus 1 and then the derivative of x minus T i square x minus T i plus 1 that is going to be 2 times x minus T i x minus T i plus 1 plus x minus T i square. So, we have found the first derivative. Now, you differentiate once more to get the second derivative. So, when you look at the second derivative G n dash at T i being constant its derivative will be 0 derivative of x minus T i will be 1. So, that gives us term 2 times divided difference based on T i T i T i plus 1 plus divided difference based on T i T i T i plus 1 T i plus 1 and then the derivative. So, we are going to have 4 times x minus T i plus 2 times x minus T i plus 1. So, this is expression for the second derivative of P i on the interval T i to T i plus 1 and P i is nothing but restriction of G n to the interval T i to T i plus 1 the value of P i double dash at T i. From the right that is given by putting x is equal to T i. So, when you do that you get the expression on the right the term x minus T i vanishes x minus T i plus 1. So, that is T i minus T i plus 1 that gives us minus h. Next you put x is equal to T i plus 1 in the expression. Then you get 2 times G n T i T i T i plus 1 the divided difference plus 4 h times divided difference based on T i T i T i plus 1 T i plus 1. We want to equate P i double dash at T i plus and P i minus 1 double dash at T i minus. So, in the expression for P i double dash at T i plus 1 minus replace i by i minus 1. So, you get it to be equal to 2 times G n divided difference based on now T i minus 1 T i minus 1 T i plus 4 h times divided difference based on T i minus 1 and T i repeated twice. And now we will do the simplifications. So, look at P i double dash at T i plus use the recurrence relation for the divided differences. So, the divided difference G n T i T i T i plus 1 will be G n T i T i plus 1 minus G n dash T i divided by T i plus 1 minus T i which is going to be equal to h. Then similarly use the recurrence relation for the divided difference based on T i and T i plus 1 repeated twice. Do the simplifications and you get the second derivative to be 6 times divided difference based on T i T i plus 1 minus 4 times G n dash T i minus 2 times G n dash T i plus 1 divided by h. The simplification of P i minus 1 double dash at T i minus gives us minus 6 times G n T i minus 1 T i plus 4 times G n dash T i plus 2 times G n dash T i minus 1 divided by h. Look at the expression 6 times G n T i T i plus 1 in P i double dash T i plus. So, that divided difference is going to be G n at T i plus 1 minus G n at T i divided by h and we know that G n at T i has to be equal to f at T i. So, that is known whereas G n dash T i minus 1 G n dash T i G n dash T i plus 1 these are unknowns. So, we will equate these two expressions on the left hand side we will leave the unknowns which involve the derivatives of G n and on the right hand side we will have the function values of G n at T i which are known and thus equating we get the system to be G n dash T i minus 1 plus 4 times G n dash T i plus G n dash of T i plus 1 is equal to on the right hand side we have G 3 times G n of T i plus 1 minus G n of T i minus 1 divided by h and which we denote by beta i here i is going to vary from 1 to up to n minus 1 because the equating the second derivatives that we need to do only at the interior node point. This was our uniform partition T 0, T 1, T 2, T 3, T 4, T 5, T 6, T 7, T 7, T 8, T 9, T 9, T 9, T 8, T 2, T n minus 1 and T n. We want G n to be in C 2 a b, G n restricted to T i to T i plus 1 is a polynomial of degree less than or equal to 3. So, on the interval open interval T i to T i plus 1 our G n will be infinitely differentiable it being a polynomial when you look at say interval T 1 to T 2 and T 2 to T 3 here we have 1 cubic polynomial say P 1 here you have another cubic polynomial P 2. So, on the open interval T 1 to T 2 P 1 is infinitely many times differentiable on the open interval T 2 to T 3 P 2 is infinitely many times differentiable the problem is the problem is the problem is the problem is the problem is the problem partition point T 2 that is where the two polynomials we are joining them together. So, thus what will come into picture will be the interior partition points T 1, T 2, T 3, T n minus 1 when you look at T 0 there is nothing on the left for T n there is nothing on the right. So, that is why we need to equate the second derivatives only at the interior node points we have got a system of equations G n dash at T i minus 1 plus 4 times G n dash T i plus G n dash of T i plus 1 is equal to beta i, i going from 1 to up to n minus 1. So, these are n minus 1 equations whereas, unknowns are going to be G n dash at T 0 G n dash at T 1 G n dash at T n. So, we have got n plus 1 unknowns. So, n minus 1 equations and n plus 1 unknowns. So, it is going to be under determined system and we will have two variables to be free and hence in order to do the fix the uniqueness or in order to determine G n uniquely we add two extra conditions. So, now the first one the first extra condition we do is that suppose you know the derivative value at two end points if we know derivative value at all the partition points then we have cubic piecewise cubic hermite interpolation. Now, suppose your function values they are known at T 0 T 1 T n and only at the two end points we know the derivative of the function. Then in that case let G dash at T 0 be equal to F dash at A G dash at T n to be equal to F dash at T n. So, then our unknowns are only G dash T 1 G dash T 2 G dash T n minus 1. So, we have got n minus 1 equations in n minus 1 unknowns and then the system of equations it is coefficient matrix is diagonally done in a dominant matrix. So, if the matrix is diagonally dominant then it is invertible and hence the system of equations will have unique solution and thus we calculate G n dash at T i at i is equal to 1 2 up to n minus 1 by solving this system of equations the right hand side it is known and this is known as complete cubic spline interpolation. In this case what one can show is that if your function F is 4 times differentiable then the error is going to be less than or equal to constant times h raise to 4. Now, this proof of the error it is a bit involved and I am going to skip that, but let us look at another end condition that end condition is known as the natural end condition. So, in this case we have got the we consider or the end condition which we put is second derivative at two end points it should be equal to 0. So, G n is the approximating function which is piecewise cubic it is two times continuously differentiable and we put that G n double dash at A is equal to G n double dash at B is equal to 0. This condition is known as natural end condition because it comes from a minimization problem. When the cubic spline they were discovered they were considered or they came as solution of a minimization problem, but what happens is these conditions they are arbitrary in the sense that we are trying to approximate a function F. This function F may not have second derivatives to be equal to 0 at the two end point. So, if this is not the case then our natural end conditions they will have the error to be only less than or equal to constant times h square. So, see in case of piecewise linear interpolation we had the error to be less than or equal to constant times h square and it is much easier to construct piecewise linear interpolation. Of course, for piecewise linear interpolation we had only continuity now this function is going to be two times continuously differentiable, but still there is a loss of order of convergence. So, then one looks at what one will have like to have is the best of both that your error should be less than or equal to constant times h raise to 4 and it should depend only on the function value. May be even the derivative values at the two end points are also not known. So, that gives rise to one more condition. So, before we consider that condition which depends only on the function values and which has order of convergence h raise to 4. Let us quickly look at the system of equations in case of the natural end condition. So, we have g n double dash at a is equal to g n double dash at b is equal to 0, g n double dash at a is going to be second derivative p 0 double dash at t 0 plus. So, we have got the formula. So, you substitute that formula we had the formula for p i double dash at t i plus in that formula you put i is equal to 0 and then we get the formula which involves the value of the function g n at t 0 and t 1 and value of the derivative of g n at t 0 and t 1 keeping on the left the knowns g n dash t 0 and g n dash t 1 and on the right hand side the known values which are g n t 1 and g n t 0 they are respectively equal to f at t 1 and f at t 0. So, we get an equation similarly look at the g n double dash b is equal to 0 and obtain and a condition which involves the derivatives of g n at t n minus 1 and t n and a function value. So, we get two additional equations we already had n minus 1 equations to that add these two equations. So, total there will be n plus 1 equations in n plus 1 unknowns with the coefficient matrix to be diagonally dominant and hence invertible. So, here is the coefficient matrix it is a tridiagonal matrix with diagonal entries to be 2 in the first and last row and all other diagonal entries to be equal to 4 sub diagonal and super diagonal entries are equal to 1 n plus 1 equations in n plus 1 unknowns. So, one solves those gets g n dash at t i's g n at t i they are equal to f at t i and that will completely determine piece wise cubic polynomial which is c 2 look at the order of convergence. So, as I said for complete cubic spline interpolation it is constant times norm of f minus g n infinity norm to be less than or equal to constant times h r s to 4 for the natural n conditions it reduces to constant times h square. So, we look at one more condition which is known as not a not condition. So, in this case what we do is we look at the partition points t 1 and t n minus 1 only two partition points at these partition points we say that the function should be three times continuously differentiable. So, at all other partition points it is only twice differentiable, but at t 1 and t n minus 1 we say that it should be three times differentiable. So, in the interval t 0 to t 1 it is a polynomial of degree 3 in the interval t 1 to t 2 it is a polynomial of degree 3 then when you say that third derivative should match then it is going to be only a single polynomial in the interval t 0 to t 2 and in the interval t n minus 1 t n minus 2 to t n similarly it is going to be a single cubic polynomial. So, such a polynomial is going to be unique and in this case the order of convergence it is restored to h raise to 4. So, now this completes our polynomial interpolation our next topic is numerical integration. So, what we are going to do is now we have got interpolating polynomial. So, the function f x is equal to interpolating polynomial p n x plus there is some error then integral a to b f x d x is going to be approximately equal to integral a to b p n x d x p n is the interpolating polynomial interpolating given function at x 0 x 1 x n. So, depending on the choice of n and choice of the interpolating points we are going to get different numerical quadrature rules. So, this is going to be the topic of our next lecture.