 So, are there any questions regarding box functions, hat functions, what we have done so far, no okay that is fine. So, what we have done so far in the last class is we have defined hat functions, we have defined hat functions and the hat function was defined as follows. The hat function centered about the point i, centered about the point i right. So, there is some interval a, b, we have created n plus 1 points which results in n intervals. The hat function centered about the point i, for now for just for the sake of this discussion we will assume that all the intervals are equal in size but you see the way I have defined the hat function and they need not be of equal intervals okay. So, the points involved are xi, xi plus 1 and xi minus 1. So, the hat function that is centered about xi takes the value 1 at xi and drops in a linear fashion to 0 at xi minus 1 and xi plus 1. And from there over the rest of the interval, rest of the interval in our problem is 0. So, the support of the function, it is a support of the hat function spans 2 intervals as opposed to the box function which was over only one interval fine. So, the ni's are not quite orthogonal to each other. So, if you take ni dot nj, ni and we take the dot product with nj, they are not quite orthogonal to each other. So, what is this turnout to you? What is ni dot nj? Well, if ni and nj were two functions, i and j are two functions that have absolutely no overlap then we know what the answer is. So, they have absolutely no overlap right. So, if this is nj then ni dot nj is 0. On the other hand, if they do have an overlap, the overlap can come in different forms. One is that the overlap can be over the interval xi minus 1 xi, it could be over the interval xi xi plus 1 or it could be over the whole xi minus 1 to xi plus 1 okay. So, we have three cases. So, what are what do they work out to? What is ni minus 1 dotted with ni right? ni minus 1 dotted with ni is a hat function that is centered at i minus 1 is centered at i minus 1 and is 0 everywhere. See, the overlap clearly is over the interval xi minus 1 xi okay. So, this in fact turns out to be the integral xi minus 1 to xi. What is this? xi minus 1 to xi, I think I had obviously right, alpha of i x times 1 minus alpha of i, alpha of z i or i minus 1. They call that i or i minus 1 dx, where alpha of i is a function of x is x minus xi minus 1 divided by xi minus xi minus 1. I have a feeling I defined it as alpha i minus 1. It does not matter. I have a feeling I may have defined this as alpha i minus 1. It does not matter. What does this integral turn out to be? xi minus xi minus 1 divided by 6. You can check this out. Let me check that out okay. Now what about the other possibility which is ni that ni that is i equals j right. This was j is i minus 1. This is j equals i. This gives me the integral xi minus 1 to xi plus 1 ni squared dx okay. And what will this turn out to be? You have to split this into 2. This is just integration. So, I am going to leave you to do it xi ni squared dx plus xi to xi plus 1 ni squared dx. Each one of them is basically, each of these elements here is basically linear. Linear squared gives me a quadratic. Integrated gives me a cubic right. There are 2 of them. So, this in fact turns out to, you can check this out. Two-thirds xi plus 1 minus xi and we are assuming equal intervals. You have to be a little more careful here because these intervals may not be the same. That is xi plus 1 minus xi is the same as xi minus xi minus 1 is like some h okay. Since I have introduced the idea of an h here, this is like h by 6 and this is like 2h by 3 fine okay. And what is the other one? The other one is going to be the same now. ni plus 1 dotted with ni is going to be basically h by 6. So, ni dot nj otherwise, so if for all other j, for all other j, other j meaning j not equal to, for all other j, j not equal to i minus 1 i i plus 1 for all other j, what do we have? ni nj ni or ni nj equals 0 okay. Not quite orthogonal. So, it is not as good as the box functions right. So, we have an overlap that consists of 3 of these functions. So, we will have to worry about that. Every time we take a dot product or something of that sort, we will have to worry about that. But what did we get in exchange for that? What we got in exchange for that is that we can represent on any given interval, we can represent a linear function. So, if you take i minus 1 i i plus 1 using the hat function, using the hat function, of course using one hat function, if you have only one hat function, you can only change that one value right. Using one hat function, you can only change one value. But the minute you introduce another hat function, you can actually represent a linear interpolant between the two. Is that fine? So, what we have got, what we have is that we have an overlap of the hat functions and therefore, we do not have pure orthogonality. But we have locality. We have locality in the sense that if I were to change, if I were to move, change this one value, all it would do is influence the function in these two intervals. It is not one interval like in the box function, it is only two intervals. It is not as though over the whole interval if I have a polynomial and I change the value, then the function changes on the whole interval okay. On the whole length of our problem domain. Whereas here we have broken it up into sub intervals right. And in the length i- we can restrict any change that I make here, we can restrict it to those two intervals. Is that fine? Okay. So, we do not quite have orthogonality. But we have some element of orthogonality between the various functions okay right. So, both in the case of the box functions and in the case of hat functions, I am not going to bother to make these orthonormal okay. I am not going to try to make them normal, which means I am not going to try to make their magnitude 1. And in the case of the box function also, I did not bother to make the magnitude 1. I did not bother to make the magnitude 1. Why would I do that? What do I gain from it? Why would I do that? Look at this function or look at this function. Why would I do that? Why would I leave the value to which the function grows, the hat function grows? Why would I leave it at 1? Clearly ni ni ni ni, which is the magnitude is 2 thirds right, 2 thirds h. So, instead of going to instead of going up to 1, if I go up to square root of 3 to h, then the magnitude ni dot ni would be 1. Why do not I bother to do it? So, constructing, finding the coefficients will be easier. That is the key. Finding the coefficients will be easier. I will tell you what I mean by that. So, let me leave that because I will need that a little later. I will tell you what I mean by this. So if we were to say that f of x, I am going to represent as summation over i. I am not going to look at the upper limit and lower limit. We will look at that. That is why that figure is left there, ai ni. And since I have already introduced the idea that h is like xi plus 1 minus xi for any i. So, I have changed it from h equals to h is like. Because we know that they need not be actually equivalent rules. So, I will introduce this notation. I may not consistently follow this notation but this is just so that you are aware of the notation. Where it is clear, I will drop h. But very often to distinguish between the function that we want to represent and its representation, to distinguish between them, we stick an h on top. I may use different f's but we stick an h on top to distinguish between a representation that is on some grid. I am using this word grid for the first time, some grid which is typically of size h. I will call it f of h and f is the original function that we are trying to represent. I do this because we are aware now that these two need not be the same. That there is an error in representation. So, to distinguish between the two, I give it a notation that is like this. So, f of h is ai ni. If we follow the usual process, what we would have to do is, we would have to take dot products to find the coefficient. But if I let ni go only up to 1, then I have the advantage that if the function value at the ith grid point is say 0.5 and ni itself takes a magnitude only 1, then ai turns out to be 0.5. That is the idea. So, finding the coefficients is easy. If you have tabulated data, you perform an experiment, you perform an experiment, you have tabulated data, you want to find the hat function representation to it, you have the coefficients in the tabulated data. You already have it. That is the idea. That is the advantage. That is why I do not make it normal. I do not make it a unit vector. If I make it a unit vector, then I lose that. I will have to go through and process the data more. So, it helps me in a situation here, it helps me not to have to process that data. So, the ai's become automatically the values, the function values at those modal points. Is that clear? Everyone? So, ai is the function value or the value of the function f of xi. So, this in fact becomes f of h, x is summation over i f of xi which I will very often just call i fi ni. And this should be from, this should really be, the summation should really go from 1 to n, but we need to have, we have to say something about what happens at the end points. So, let us go back here and see what happens at the end points. So, what do I have here? So, apparently I have one interval here. So, I have that. And finally, there is nothing on the, there is nothing on the left hand side. My problem starts here. So, I only get half a hat function. I only get a half a hat function. So, my very first function, if I were to draw it separately, my very first function would be this, n1 or n0 depending on, I have to, actually I do have to be a bit careful with my, because I have, the count starts from 0. So, I have that is 0, that is 1. And it goes on, that is i, i plus 1. Then we go to the other extreme. Let us go to the other extreme. What do we have at the other extreme? You have one more hat function here. One more hat function here. And finally, I have one last hat function here. And that will turn out to be the last hat function. It will turn out to be this function. There are n intervals. And this is going to be, the count starts at 0. The count starts at 0. That is going to be n. So, the upper limit is going to be n. Is that fine? Okay. Are there any questions? Using these functions, it is actually possible now that we can represent any function that we want as a piecewise linear straight line, polyline. So, if you had some functional variation, you have the function values, the f set xi. It is actually possible for you to represent it as a polyline, piecewise straight lines. And it is continuous. Are there any questions? Unlike the box function, integral f of x and integral f h of x is the same. Well, we actually have to find out. Is it not conserved? We need, so we need to do a little analysis as to what we have right now. So, one of the things that we have to do is, maybe some things I will do, some things I will leave for you to try it out. So, first question that you have is, what is f of x minus f h of x? The norm of this. So, this is one question. What is the norm of this? Am I making sense? So, in a sense, that is connected to what you are saying right now. So, what is this norm? What does this turn out to be? Why did it work there? What is the, in the case of the box function? In the case of the box function, right here it is very clear. Here I said I left it as 1 so that the function value comes out immediately. In the case of the box function, what did we get in exchange? So, in the case of the box function, do you understand the question? I said that I have a box function. And I said that I left this at 1, right. I left this magnitude, magnitude of the box function. I left it at 1. I could have made it a unit vector by making its magnitude square root of n. I could have made the magnitude square root of n and it would have been a unit vector. The dot product itself would have been 1 whereas I did not do it. So, I left it at 1. There must be some advantage that I got because of that. So, this will turn out that this is basically the average value. The area under this is what, the value here will be the average value of the function over this interval. You can just check and see whether that has a consequence with, right, okay. So, on the other hand here, we need to know what this is. Just like we did for the box function, you need to try it this out and make sure that, right, you get an expression for this. Just try it out. I would suggest that you try functions of various kinds. Let us look at, I will just name a few and we will see what happens. So, if I have a constant function, hat functions, I can represent it exactly, right. This norm is 0 meaning I can represent it exactly. If I have a linear, again 0. So, the representation is definitely of order 1. If it is quadratic, then I am going to have a problem, right. So, you can use a quadratic, try to represent a quadratic and see from there what is this error. See if you can get an expression for the error, okay. See if you can get an expression for the error. So, that will tell you something about the nature of the, nature of the error, the error term. Please do this. The error term will tell you the nature of the error and it will also tell you what happens as we shrink, as we allow h to go to 0, what is the rate at which that error goes to 0. So, it is important that you derive that expression, fine. The other thing that we want is, I want to make sure that we get this that hat functions provide a first order representation, right. The box function was a 0th order representation. That means a polynomial, a constant was represented exactly. In the case of the hat function, it provides a first order representation. We can up to a linear can be represented exactly. Is that fine? Okay. Let us see what else we can now do. Is it possible for us to go for higher order representation? Is there a way that we can get higher order representation? Okay. So, we would obviously want to use polynomials of higher order. We want polynomials of higher order, okay. We want polynomials of higher order. But I suspect just like going from a constant to a linear, when we went from constant to linear, we went from one interval to two intervals. I suspect if we go from linear to a quadratic, that possibly we will have to go to three intervals, okay. So, what does the nature of those functions that we can use? So, we saw that alpha of x was like x-alpha i of x, xi by xi-1-xi was something that we could start off with a linear. It turns out we can actually use these to construct polynomials of higher order, okay. So, if I define three functions now on a given interval ni0 is alpha i of x squared. It is clearly a quadratic. Ni of 1 is alpha i into 1-alpha i. Also clearly a quadratic, ni2, I will have three such functions, will be 1-alpha i squared, will be a 2 there. And ask the question, how do you know there is a 2 there? How do I know there is a 2 there? All of these ni0-ni1-ni2, ni2 add to 1. Does that work? Why should they add to 1? No, no, but why? See, this is over the same interval. Please remember this is over the same interval. This is over the interval xi, xi-1. This is over the interval xi, xi-1. What do these functions look like? One is going to be a quadratic, that is like this. One is going to be a quadratic, this slope is not 0 here, that is like this. And the third is going to be a quadratic, that is like this, okay. This would in fact be this one, okay. So, question that we have is why should these add up to 1? In fact, if you look at the hat functions, you will see that they are there too. Even there they add up to 1. Why do they add up to 1? If you look at the hat functions here, ni0-ni1, ni0, my notation has changed a little. I called it ni plus 1, 0 and ni1. Add up to 1. Why do they add up to 1? If they did not add up to 1, what is the big deal? You cannot represent the constant. You will not be able to represent the constant, right? And there will be some sort of funny interpolation going on now over and above, right? If this did not add up to 1, that means that it would be, it is varying in some fashion. If it did not add up to 1, it is varying in some fashion. If it did not add up to a constant, if it did not, 1 is convenient. If it did not add up to a constant, that means it is varying in some fashion. I am making sense, right? Okay. And at any given point in the interval, at any given point in the interval, we want the function value there to be, it is a linear combination of these 3. It is a convex combination of these 3. Is that fine? Okay. So we do not want any other variation. We want the variation that we have picked here and that should be picked up by these 3 functions. And therefore they have to add up to a constant and 1 is a very convenient constant to pick. Okay. So in this case, just like we did A i B i there, we could actually say A i, A i, N i, 0 plus B i, N i, 1 plus C i, N i, 2. We would have the sum of these 3 quantities. Is that okay? As we go along, you will see that I will leave more and more of the details of working things out to you. Is that fine? This is quadratic. So what it allows me to do again is I have a function that is 0 at this end, 1 at that end, right? Starts at 0 at this end, goes to 1 at that end. Okay. Fine. So it is possible for me to independently vary what happens to the function on either sides of the interval, right? And also there seems to be, this seems symmetric about this. This figure does not, but it should be symmetric about that, right? And there is a slope that is fixed at both sides. I do not have that much of a great preference for quadratics. I just do it for completion, so to speak. I will go on to something that is more important, which is qubits. So in the case of qubits, we would define how many? 4 functions. We will define 4 functions, which are ni0, ni1, ni2, ni3 and these should be relatively easy for you to figure out now. So ni0 would be alpha i cube, it is a function of x. I am not going to keep writing that. Ni1 would be alpha i squared, 3 of them into 1-alpha i, right? So in your mind, you should be thinking a-b whole cube. Ni2 would be 3 of 3 times alpha i, 1-alpha i squared. And ni, the last one, would be 1-alpha i cube. Is that fine? So this is just a simple algebraic process that I am going through. And clearly the sum of these, sum over j of nij is again 1, because the sum of the 4 of these will give me alpha i, alpha i plus 1-alpha i whole cube, right? Which is 1, which is where these constants came from. And now it is actually possible for you yourself to construct, right? Any order, any order that you want. Now that you have seen this process, it should be obvious that you can construct any order that you want. Is that fine? So why did I skip quickly over the cube, quadratic and go to the cubic? Well, the cubic is an interesting function. The cubic is an interesting function, because it gives me control over the function values at the end points. And so this is, well, I will just call it y right now, xi, xi, xi plus 1. The cubic allows me to do this. The cubic, the slope here is 0, the slope there is 0, right? So it is going to go the 0 slope to 1 there, right? The other function 1-alpha i cube is going to start at the 0 slope and 0 value here. That is important, 0 slope and 0 value and goes up to 1 there. Is that fine? Okay. The next 2 functions, do something that is interesting. Let me choose the next 2 functions, do something interesting. So they start with a non-zero slope on the one side and have a 0 slope on the other side, okay. They start with a non-zero slope on one side and have a 0 slope on the other side, okay. So by, on this interval, by using these 4 functions and using ai, okay, ai ni 0 plus bi ni 1 plus ci ni 2 plus di ni 3 by using these 4 functions and these 4 coefficients. It is possible for me using the first one ai to move this value up and down. You understand what I am saying? Just to change the single value alone. It is possible for me to use di and to change move this value up and down independent of the others. It is possible for me to use bi and ci to actually manipulate the slope. Do you understand what I am saying? So in a sense in representing the function value, I have now got what I would call as the ultimate in locality. I have managed now, right? It is not quite the ultimate. Obviously you can go to higher order but we like the direction in which we are going that we are able to manipulate the function value and you are able to simultaneously manipulate the slopes at these points, okay. And what is the cost that we paid? What is the price that we paid in exchange for this? We have a higher order polynomial of course. We have more coefficients to handle. We have more intervals involved, right? There will be more, more intervals involved, more intervals involved. So we will end up having overlap over multiple intervals. So what I want you to do is I want you to try the following for both quadratic and cubic representations, right? I just basically say quadratic and cubic representation. You know that the quadratic will represent anything up to a second degree polynomial, right? And the cubic is going to represent any polynomial accurately up to a third degree polynomial, right? And beyond that of course then you are going to have errors. So for both of these you need to find, please make sure that you are able to find f-x-fh of x, the norm. What else do we want? Which means that for a quadratic, obviously it will represent a quadratic properly. It is likely that a cubic would not work. Try a cubic, try a quartic even with a quadratic. Try higher order polynomials to see what is it that you get. And for cubics it is the same thing, right? Up to a cubic it works. If you have a doubt try it out and try a quartic, try a quintic to see whether what does the error term turn out to be? How does the error term work out? Okay. How does it work out? One, what is the error term and how does it converge? So one is find this and look at it to see as h goes to 0. How does it converge? What is the order? What is the rate at which it goes to 0? Is it like h? Is it like h squared? Is it like h cubed, right? What is the rate at which it goes to 0? Is that fine? Okay, right? So what we have now is a way by which we are able to represent functions of various orders on any interval. We have a mechanism by which we are able to find the error in our representation. We are hopefully once you have done the assignment you will see that for all of them you are in a way, you have a mechanism by which you are able to find the rate at which you get convergence, okay. We will say a few words and know about what I mean by that. The rate at which we get convergence, the magnitude of the error and you have a mechanism by which you know what is the order of representation, right? The idea of what is the order of representation is something that is clear, okay. So what do I mean by convergence? In this context what do I mean by convergence? We take some of these terms that we have used. What do I mean by convergence? So as h goes to 0, h which is like xi plus 1 minus xi for all i's. So they are all of the same order of magnitude as this goes to 0 which means that n goes to infinity, the intervals get smaller and smaller and the number of intervals becomes larger and larger. We are asking the question does f of h go to f? First question, does f of h go to f, right? Which means that it converges and the second question is at what rate? Do you have convergence and at what rate? Okay. Right? So this is the first definition that you are seeing of convergence. We will see different types of convergence. I want to make sure you have to be, it depends on the context. I want you to keep this in mind. So this is as h goes to 0, we have a representation. The question that we have is what is the rate at which the representation that we have goes to the actual function? What is the rate at which the representation error goes to 0? Okay. So as I said there is always this question does it indeed go to 0 and if it goes to 0, what is the rate at which it goes to 0? Is that okay? Fine. So what we will do is maybe we will consider now how useful this is in what we have set out to do which is all differential equations. We have figured out the way to find out what is the order that is if you give me the data. That is the reason why the example that I gave you earlier was if you perform an experiment you have tabulated data. From that tabulated data it is very easy for you to fit. You understand? Especially for hat functions it is very straightforward for you to just extract the data and use it, right? Directly plot. All you are doing is linear interpolation if you think about it. The only thing that I am telling you now is every time you use linear interpolation earlier you are actually using hat functions. It is that awareness that I want. Every time in an experiment or in any work that you have done earlier every time you had data and you connected it by straight lines you are actually using hat functions. That is what you have to be aware of. You understand what I am saying every time you connected it by piecewise straight lines you are actually using hat functions, okay. That is the key. So this is the situation where you have the data points ahead of time. This is the situation where you have the data. What happens if you do not have the data points ahead of time? This is what we encounter typically when we are trying to solve differential equations. So if I had a dynamical equation, a dynamical system, a system that is varying in time I want to predict its behavior in the future. So I could in a sense have some dx dt which is f of x, t and this is something that is varying in time and I do not have x, this could be a particle that is travelling for instance, right propagation of a particle x could be its position. So I have dx dt related in this fashion. I may not have a priori before I start. I may not have the data points in hand for me to fit a function, okay. So I can decide that I am going to use linear interpolants of some kind. I can make that decision but is it possible for me to say beforehand get an estimate as to what is the error that I am likely to make or are they related? Is it the same? Does this question make sense? See in the one case it should be clear to you that if I give the data that you are able to use the data and interpolate. It is all a matter of representing the function but we saw the motivation that we used for why we are setting out the represent functions on the computer is that we do not know what the function is and we want to come up with an algorithm to hunt for the function. There are different ways by which this can happen. In fact it is possible to use this. We will see how to use those functions later on but right now as it stands, right, the problem that I posed to you is if I had a differential equation which I am integrating out in time, I deliberately choose time because that is in the future and I am saying you do not know what the value is, right. So if I deliberately integrating out in time, is there a way for me before I start the integration to say this is the nature of the function, this is the representation that I am going to use, this is how it is going to, this is the error that I am going to make in my representation, fine. So there is a different kind, I want to march off, I want to step off given that I have some initial condition x0, I would like to find x1 somehow which is very different from a situation that we had there which was basically given data representing the data, okay, right. So what we are going to do is we are going to take a slightly different tack. We are going to see, here we have already seen especially for the box function, we have already seen that the error was of the order of 1 over n which basically means that the error was of the order of h. And you will see when you do this, you will find out errors again, errors in terms of h, okay. So this may not be an obvious trigger for you but what I would say is we will see whether we can approximate a function at time t plus delta t given the value, okay. So I will use an example that may make you uncomfortable but what the heck. So you have, you all been taking quizzes, exams and all of that kinds of stuff so far, right. So 6 semesters are done. Next semester you go for interviews, people look at your grades, they say at this point in time after 6 semesters this is your cumulative grade point average, this is your grade. What is your grade likely to be at the end of 8 semesters? That is the question that we are asking. Given at time t that I have a function value, your grade point average at a given time, what is your grade point average likely to be at t plus 2 semesters? Someone interviewing you, giving you, sitting across the table and asking you questions, they look at your score sheet and they want to make an estimate, fine. So give me a good estimate. What would, so if you say I have a grade point average which is 8.5, what would you tell them? What would I do if I were interviewing you? What would you do if you are interviewing me? What is a good estimate? It is likely that it is the same, right. One good estimate is it is likely that it is the same, okay. You made this, this is the cumulative grade point average over the last 6 semesters. It is likely that after at the end of 8 semesters this is going to be your CGPA. Am I making sense? So it is likely, so one thing, one way by which we could do it is so if you give me x of t, it is likely that x of t plus delta t is like approximately x of t. That is an approximation, right. And I have changed the language that I am using now. So far I have been talking about representations on the computer but our experience so far I am now admitting it is an approximation. It does not look like we are going to be able to represent functions exactly on the computer, right. So it is going to be an approximation. So now I come, we have to lose this reality. I come now to the point where we say it is an approximation. It is an approximation. I want to now ask the question what is the approximation, what is the value and what is the error in that value, okay. And I pose this question in this fashion because it immediately motivates, it immediately motivates if you look at something like x plus t plus delta t what do you want to do? I am not using Taylor series. Am I making sense? You will look at something like x plus t plus delta t. You say oh why do not we just expand using Taylor series, okay. So that is basically what we are going to do. Essentially what we will do is we will now sort of reset, right. That was the notation we introduced so far but we will go into standard notation. So if I have f of x given f of x what is f of x plus delta x? I introduce the notion of t and time just to motivate the fact that you may not know the function ahead of time. That is the only reason why I use t. So the question is given f of x what is a good approximation for f of x plus delta x? Well you can say f of x plus delta x. A good approximation is f of x, right. So if I am getting something today, if my salary is f of x today, a good approximation is f of x plus delta x, right. Then it is the same salary. So it is a reasonable approximation. It may not always be right but it is a reasonable approximation. So what is the nature of the error? Use Taylor series. f of x plus delta x is f of x plus delta x times the derivative f prime x. So the prime indicates differentiation with respect to x delta x squared by 2 f double prime of x plus an infinite number of terms. And I am assuming that f of x plus delta x is f of x and in making this assumption I have thrown away all these terms in Taylor series, okay. All of these terms infinite number of terms I have thrown them away. I have an infinite series which I have truncated, right. The error that you create by taking an infinite series and truncating it is called a truncation error, right. If you have an infinite series representation for say a function, the error that you make by throwing away a whole bunch of these terms is called a truncation error. And we will represent the order of the error by the leading term which is delta x. So the error, truncation error here is the order of delta x f prime of x, is that fine, right. So we tend to call this a first order error because the exponent over delta x is 1, right. Okay. So we will come back to this maybe on Monday I will try to do a demo of some time then. I would suggest that you try using hat functions and representing various and sundry functions as many different types of functions as you can, okay. And I will come back in the next class and maybe try to do a demo so that you can see. There are some issues still with respect to representing function, fine. I will see you in the next class.