 So, in our last lecture we were looking at interpolation, interpolation polynomial, we also looked at cubic spline interpolation. So, I talked about piecewise polynomial interpolation towards the end, but let me explain a few things before I move on about piecewise polynomial interpolation, we have this function u z and we know values of this function at different points and then we wanted to fit a polynomial that passes through each of these points. So, one possibility was to develop a very high order polynomial which passes through each of these points. So, that would be a continuous function passing through each of these points. There is there are other options as I said that finding out coefficients of a very high order polynomial higher than 3 or 4 becomes an ill conditioned problem difficult to find the coefficients. So, we resort to what is called as piecewise polynomial approximation and one particular type of approximation I talked yesterday. So, if I want to develop a piecewise polynomial approximation what is the simplest piecewise polynomial approximation? Well not cubic the simplest one will be linear line you know. The simplest one would be just a line that I could develop a line that connects these two points then another line that connect these two points. What is the problem with this? This is fine in some cases this works this is useful I am not saying this is not useful, but this approximation piecewise linear approximation is not is not differentiable at the boundary points it is not differentiable ok. So, it is continuous, but it is not differentiable. So, that is why we want to have higher order approximations we could then think of approximating this using second order that is quadratic equation. So, each one of them instead of a line can be a quadratic equation ok. So, this might be and so on. Now, if you are fitting in general you could fit kth order polynomial say quadratic cubic fourth order we normally stop at cubic and among the piecewise polynomial approximations the approximation for which we match derivatives up to k minus 1. Suppose you are fitting a kth order polynomial between each segment and you match the derivatives up to k minus 1th order then that is called as a spline approximation ok. So, cubic spline when I say cubic spline that is because we are matching first order and second order derivatives polynomial order is 3 first and second derivatives are matched for smoothness purpose. So, that is why it is cubic spline normally we use cubic spline because beyond that it is not worth fitting higher order polynomials beyond cubic many times suffices for most of the applications. So, you can very well develop piecewise linear approximation piecewise quadratic approximation piecewise cubic approximation ok. So, depending upon what is your you know what level of smoothness you need in your application in some cases differentiability is not so important you can have piecewise linear ok. In some cases differentiability is important. So, you should have higher order polynomials and match derivatives and so on. So, this is a small point. The next point that I want to make here is that when I am developing this when I am developing this approximation is it necessary that I only do a polynomial approximation it is not necessary that I only do polynomial approximation I can do function approximation ok. So, in general my approximating I mean this is just we are not going to use when we do boundary value problem discretization or when I develop this orthogonal collocation method I am not going to use function approximation this is just a side note that well I am using the word approximation function interpolation function interpolation we will be using approximation in a different context. Just like I can do polynomial interpolation I can do function interpolation. So, in general let us say I have this you know I will just slightly change the notation you have this uz here and till now we were looking at polynomial approximation which means we said that pt is alpha 0 plus alpha 1 and then this was the initial Lagrang interpolation and then we know this values of uzi is equal to ui we know these values at i going from 1 to up to n plus 1 we know values of ui and then we wrote n plus 1 equations in n plus 1 unknowns and then we had a you know simple way of finding out alpha 0 alpha 1 by matrix inversion this we have discussed earlier it is not necessary that I approximate only using or I interpolate only using polynomials not approximate I interpolate approximation will come when you approximate boundary value problem right now interpolation is something in which you try to construct a function that passes through every point. So, this is a polynomial function that passes through every point here passes through every point now I could also develop say another function g sorry not t here gz this is a function of z not of t I could develop another function which is interpolating function and I would call this as some beta 1 f 1 z plus beta 2 f 2 z let us let us let us keep the notation similar. So, let us call this beta 0 f 0 beta 1 f 1 up to beta n in general I need not I need not approximate using simple I need not represent this polynomial using simple polynomial functions I could have more complex functions appearing here. So, this is called function interpolation each one of them is a function of for example, for example, I could use some of the standard polynomials say Lijandra polynomial here or I could use shifted Lijandra polynomial depending upon the context you could use different kinds of I could use here sin n cos I could use here sin n cos. So, it is not necessary that interpolation should be only through polynomial interpolation can be through functions these are this will be called an interpolating function and how do you estimate beta 0 to beta n the same thing you know you take write this equation u 1 is equal to beta 0 f f 1 z 1 plus beta 1 f 0 f 1 and then u 2 is equal to beta 0 f 0 z 2 plus beta 1 f 1 z 2 z 2 and likewise you can write this for all the points and I have u n plus 1 is equal to beta 0 f 0 z n plus 1 plus beta 1 f 1. So, I have n plus 1 equations in n plus 1 unknowns what are the unknowns here beta 0 beta 1 up to beta n these are the unknowns these functions here f 0 f 1 interpolating functions I have chosen them I know these functions like sin cos or whatever you choose I am chosen these functions I have chosen these functions. So, I can substitute values of z and find out the value of that particular function. So, here this would be known this would be known because I have chosen the function I can evaluate the function at a particular point and you know I can then write this into the standard form because this will give rise to you know u is equal to a matrix into theta where theta is nothing but beta 0 to beta n this vector theta is beta 0 to beta n a matrix will have what will a matrix have all this f 0 z 1 f 1 z 1 all these values of this this a matrix is known and then you can find out you can find a interpolating function you can find a interpolating or this is called a function interpolation function interpolation. So, this is a special case of function interpolation you have chosen a special function which is simple polynomial, but that need not be the only way to construct interpolating function you can do in general function interpolation. So, interpolation is if you look at textbooks on applied mathematics you will find much more material on interpolation interpolation right now my interest is in discretizing a problem. So, I am going to restrict myself to whatever I need for problem discretization. So, my aim is now to convert a boundary value problem or a partial differential equation into a set of either algebraic equations which have to be solved simultaneously or in some cases it could be differential equation that need to be solved simultaneously. We have seen several cases right what is going to be different here is how we approximate the derivatives what was the key in the earlier case when you use Taylor series method the key was approximation of first order and second order derivatives. So, interpolating function or interpolating polynomial is going to be used for approximation of local derivatives. So, the word approximation comes when you start discretizing not when we constructed interpolating polynomial. So, the trick is going to be same I am going to develop some what did we do when we developed finite difference method we started with Taylor series we looked at a point right and we said local derivative of this particular local derivative of this particular function can be approximated using Taylor series expansion and then we had this forward difference backward difference formula for approximating the local derivative at ith grid point we divided the entire domain into number of grid points right and then at a particular grid point ith grid point we had a way of constructing local approximation of the first derivative and second derivative. Same thing is going to be done here I am going to use this interpolating polynomial to construct local derivatives approximation of the local derivatives at the grid points at the grid points. Now, just look carefully at the development because this is something which is new for you for most of you and somewhat different from you know finite difference in some sense you know is covered when you in your undergraduate in many cases many of you would have visited finite difference, but orthogonal collocation probably is not part of typical undergraduate program. So, now let us start looking at how we develop this orthogonal collocation. So, I have this so this is again this is z is equal to 0 and then this is my z is equal to 1 I have this similar notation. So, this is my z 1 this is my z 2 this is my z 3 this is z i in a domain 0 to 1 well this domain appears in the context of let us say a boundary value problem. So, let us rewrite our boundary value problem again. So, the general boundary value problem is so in the domain 0 to 1 I want this differential equation to hold actually at every point, but when we do discretization we will end up forcing this equation only at certain grid points the same way that we have done for finite difference and then I have this boundary conditions f 1. So, I have two boundary conditions and I have this second order differential equation I need to develop approximations for d 2 u by d z square d u by d z and then at a particular point let us say ith point I want to develop local approximation for the derivatives and now the way I am going to proceed is let us denote the value of the solution at these points as u 1 u 2. So, basically the same idea where we had said that u i is equal to u of z i well u is the dependent variable here the solution of the problem it could be temperature distribution it could be concentration distribution whatever is the problem at hand. So, this is this is by solution now the trouble is trouble is in when you are solving a partial differential equation and when you are trying to develop an interpolation polynomial you do not know these values u 1 u 2 u 3 up to you do not know these values. So, the trick is use interpolation polynomial together with this differential equation to find u 1 u 2 u 3 up to u n plus 1. So, when I begin the development I am going to develop everything in terms of u 1 to u n as unknowns now let us see how we do this. So, now what I am going to do is my approximate solution to this problem I am going to represent as a polynomial as a interpolation polynomial. So, let me call this as u z as u 2 u 3 is equal to alpha 0 plus alpha 1 z this is my proposed solution this is my proposed solution approximate solution for this particular problem. Now, if you want to develop interpolation polynomial what will you do you will write these equations u 1 is equal to alpha 0 plus alpha 1 z 1 up to alpha n z n right then u 2 alpha 2 plus to z n. So, you would write all these equations I will write all these equations u 1 u 2 up to u n these are the values of these are the values of this solution approximate solution at the grid points right now I have not talked about how to decide this grid points in this context they are often called as knots or collocation points they are not really called as grid points just a matter of terminology they are same as grid points they are often called as collocation points. So, these points here will be called as collocation points. So, now I can write this and then I can I can put this into the standard matrix form 1. So, these equations n plus 1 equations into n plus 1 unknowns I have transformed into a standard matrix equation. Now, there is a trouble here in normal interpolation when it is not connected with a differential equation you are given some values of the function at the grid points. So, in normal polynomial interpolation you know these values you know these values now I do not know these values right now does not matter I am going to do play some tricks first of all in this equation I do not know 2 things I do not know alpha 0 alpha 1 2 alpha n I do not know u 1 2 u n plus 1. So, both I do not know. So, I cannot really solve this problem and find the solution that is not possible the solution is tied up with the differential equation. So, we have to go to differential equation to get these values but what I am going to do here is let us call this matrix as a matrix this vector as theta vector and this vector here as capital U a theta equal to u. So, this my equation is a theta equal to u. So, I am going to transform this equation and write theta is equal to a inverse theta is equal to a inverse into capital U capital U is this vector U n 2 u n plus 1. So, what I have done is I have said that this set of unknowns can be represented in terms of this set of unknowns. Let us leave here and then let us continue with the next part. Now, let us come to i th i th collocation point. So, at i th collocation point what is the solution approximate solution you see i u z i before I go to the i th collocation point what is the general solution u z is alpha 0 plus alpha 1 z up to alpha n z n right this is the approximate solution what is its first derivative what is d u by d z d u by d z is is 0 plus 0 plus 0 plus 0 plus 0 alpha 1 plus 2 alpha 2 z up to n alpha n z n minus 1. Everyone with me on this I am going to write this in slightly different way I am going to say that this is 0 1 2 I am going to write this as a inner product of 2 vectors 1 vector is 0 1 2 z 3 z square 4 z cube and so on. So, this has been written as inner product of 2 vectors dot product of 2 vectors so far so good. So, now we need so here now this first derivative is actually. So, this is d u by d z is equal to 0 1 2 z n z raise to n minus 1 into theta into theta we agree with me because this is the theta vector this is my theta vector. So, this into theta vector which is same as 0 1 2 z into a inverse u I am just replacing theta unknown theta are not so convenient for me to work with I am going to work with unknowns u 1 to u n plus 1. So, this is a known matrix a is a known matrix I have chosen the collocation points so I can compute a matrix I can compute a inverse. So, this is a known matrix to me now this multiplication of this vector into this matrix I am going to denote it by see this is a vector this is a row vector this is a n cross n matrix n 1 n plus 1 cross n plus 1 matrix and this is a vector which is 1 cross n plus 1. So, multiplication of these 2 this vector row vector into this matrix what will it give you another row vector I am going to call that row vector as I am going to call this row vector as s i s i is the ith row vector or the row vector associated with the ith collocation point. So, I have represented one minute so there is one more step in between one more step in between we have to do. So, this is the general expression for the derivative now I want to find a derivative at the ith collocation point. So, how will you find out? So, here you will have to put z i so d z i by d z 1 2 z i where is to n minus 1 into a when I want to compute the derivative at the ith collocation point I am just going to substitute for z equal to z i I will get this expression a inverse u. Now, this quantity I am going to denote as s i that is 0 1 2 z i into a inverse this is my row vector this is a row vector what you get here is a row vector. So, this will be this will be 1 cross n plus 1 row vector and then what I get a very simple expression d u z i by d z is equal to s i into u is everyone with me on this right so d. So, the derivative approximation derivative approximation at ith collocation point is this vector times u what is u? u 1 2 u n plus 1 u 1 2 u n plus 1 likewise I can develop my second order derivative can you do that. So, what is my d 2 u by d z square what is my d 2 u by d z square. So, this would be 0 0 2 0 second derivative will give you only 2 then 2 then what you will get 6 z into n minus 1 z raise to n minus z raise to n minus 2 am I correct. If I write it in terms of into theta but what is theta a inverse u so a inverse u I am just skipping in between steps they are very simple same derivation as previous derivation for the first order derivative. So, I am just directly writing the final form here you will get this vector and you will get this a inverse times u when I want to compute the derivative at ith collocation point. So, I would just substitute d 2 u by d z square by d z