 So, we have looked at representing that we can represent functions on the computer okay. So today we will look at specifically some mechanisms by which we do this. What we saw that was that we can represent functions but we want to be able to organize functions the way we organized vectors which we have seen in the last class. Today I am going to talk about box functions. It is a special class of functions. I am going to define two functions to start with. One is a function f. It is defined on the interval 01. The value of f on the interval 0.5 is 1 and outside that it is 0. I define another function g. So, also on the interval 01, its value on the interval 0 to 0.5 is 0 and between 0.5 and 1 it is 1. So, this value is 1. Function value there is 1. If you consider a linear combination of these functions, if you look at af plus bg, you will see that just like in the vectors, in the case of vectors, if I took another linear combination cf plus dg, an addition of these two and I can add them up. They are defined on the same domain. An addition of these two will in fact give me a plus c times f plus b plus d times g. Is that fine? So, we see that just as we did the other usual vectors that you are used to that we have something that looks like a summation and we are able to do the vector algebra and set it up in a systematic fashion once we define the dot product. So, what we need to do is for functions, we want to be able to define a dot product. I will define the dot product as follows. I will define it on for these two specific functions 0 to 1 as f times g times dx. I will use the notation f, g because the dot is already used in the case of functions. The dot is already used for composition of functions. We do not want any confusion. If you say mathematics, if you say fg, it is possible that you confuse it for f of g of x. So, that we do not confuse it, we introduce some new notation for the dot product. So, what is f dot g? f dot g is this integral and as it turns out, because these regions are non-overlapping, this dot product in fact turns out to be 0. You can work out that integral and check that the dot products in fact turn out to be 0. We will come back to this point later. Right now what I am interested is in getting as we did earlier, defining a magnitude, something like a magnitude. In the case of a function, it is called a norm. We define a norm that comes from this dot product just like we did with vectors. So, I could define the square of the norm as f dot f which turns out to be the integral 0 to 1 f squared dx. Is that fine? Now in a similar fashion, we can define norm g squared is g dot g integral 0 to 1 g squared dx. It is the area under the curve. It is clear that they should both be the same. What does this work out to? So, what is the norm of f? So, it is the integral 0 to 1 f squared dx which is actually the integral 0 to 0.5 1 times dx which is 1 half. Is that fine? So, norm of f in fact 1 over square root 2 and again I am just duplicating whatever work we did with the usual vectors that you have seen. I can define a unit vector as f divided by norm of f and as you would expect its magnitude so to speak would be 1. Is that fine? Any questions? Fine. What do we have? We have now managed to actually repeat the process that we did for vectors. We can actually get, we can actually define a general dot product of two functions f and g. Repeat the process but in this case the functions could be defined between any two intervals a and b and you could actually define it as f g dx. f and g are functions that go from take some real number and return a real number. Is that fine? So, in general it need not be 0 to 1. I will do everything here as from 0 to 1 but in general the definition is not restricted to 0 to 1. Is that fine? Okay. So, why do not we try something with three coordinates? So, what if I define three functions f, g and h? I try something f, g and h. f is defined in a similar fashion now. The only difference is because I have got three functions I am going to break up the interval 0 to 1, 1 third, 2 third and that is my function f and I define my function g between 1 third, 2 third that is 1, 0 that is my function g and in a similar fashion I will define my function h and that is my function h. The value of h is 0 on the interval 0 to 2 thirds is 1 on the interval 2 thirds to 1. In a similar fashion g is 0 on the two intervals 0, 1 third, 2 thirds, 1 third and it is 1 on the interval 1 third to 2 third. Whether it is 1 on the interval 0 to 1 third and it is 0 on the rest of it. Now, we go back to the example that I used in the earlier class. So, I ask the question what is 3 f plus 2 g plus h? It looks very similar to 3 i plus 2 j plus k where i, j, k are our standard unit vectors. So, it is almost as though I have defined these, previously when you first learnt it you may wonder what they are i, j and k. It is almost as though I have actually told you what are i, j and k, define them in terms of functions. So, and you can if you have 5 f plus g plus 2 k, 2 I am sorry h, you can actually add up these two quantities. You can perform the arithmetic just like you would do normally and get 8 f plus 3 g plus 3 h. Fair enough? Is that fine? All very nice. So, it looks like we can use combinations of these coefficients and represent functions. How well does this work? That is the question that we have. How well does this work? So, what do we have so far? We have defined functions in this form because it looks like somewhat like a box. It is called a box function. We have defined box functions and it is clear that on any interval I can define any number of box functions that I want. We will get to that in a little while and it looks like I can represent functions on the interval 0, 1 using these box functions. So, we will try to use it and see what happens. We will pick a simple function. Consider the function. We will pick a very simple function, p of x equals x. Consider the function p of x equals x. So, I would like to represent this function as p of f, the f component p f times f plus p g times g plus p h times h. You understand? This is the f component, the g component, the h component of p. And all I have to do now is take the dot product. So, I ask the question what is p of x, f? What is this dot product? This is the integral p of x f dx, integral 0 to 1. Maybe we will just evaluate that. So, you get x times f, the integral 0 to 1 dx, which is, well, we know f is nonzero only between 0 and 1 third. So, it is 0 to 1 third x times 1 in that domain dx, which is x squared by 2, which gives me 1 by 18. Is that fine? That is actually performing the integration. What is the dot product p of x f without performing the integration from here? So, what would we like it to be? Let me not say what is it? What would we like it to be? What is this quantity dotted with? What is this quantity dotted with f, p f f plus p g g plus p h, sorry, h dotted with? What is this quantity? So, it is just p f, f dot f. Is that fine? Because f dot g is 0, f dot h is 0. And what is f dot f? We have to be careful now. I changed the definition of my f. What is f dot f? Well, we have to calculate f dot f. For this case, f dot f is the integral 0 to 2 and I will write it only till 1 third, 0 to 1 third dx, which gives me 1 by 3. So, presumably if I have n of them, it will give me 1 over n. So, p f, p f in fact is, I am going to get it from here p of x dotted with f divided by f dot f, which gives me 1 by 6. Any questions? So, what we are doing now in a similar fashion, p g will be p f f plus p g g plus p h, h dotted with g, which will give me p g times g dot g. And you can check that g dot g is going to be 1 third, g dot g is going to be 1 third. And therefore, what is p g? So, if you take p of x multiplied by g, integrate from 1 third to 2 thirds because that is where g is non-zero. Of course, do not forget that you have to divide by g dot g. What does this give me? 1 half. This should give me 1 half. This will give me 1 half. And p h in a similar fashion, p h you will have to integrate it between 2 thirds and 1, 2 thirds and 1 p of x h of x dx divided by h h, which will be, you can verify that it is 5, 6. If you are wondering how I know the answer, it just basically comes from the symmetry. So, this is about a sixth away from 1. That is basically how that comes. So, what is the function? What is the function that we want to plot? Let us plot this function. So, this is x. This is p of x. And the function itself is a 45 degree line. Is that fine? This itself is a 45 degree line. We have a representation of the function on those 3 intervals represented by, I will use 3 different colors here, represented by values which are, so this is 1 third, 2 third, 1. It is a 45 degree line. 1 third, 2 third, 1. So, where is 1 sixth? 1 sixth is somewhere in between. What is that? That is p f times f, to which I want to add that is plus p g times g. And the last one, oops, not that different in color but it does not matter. The last one is p h times h. Is that fine? So, look at the 2 functions. I have the 45 degree line that I am trying to approximate. And I have this other thing made up of blue and red lines, which are nothing but our representation on the computer. If you were to use box functions to represent the functions on the computer, this is what we would get. So, clearly just like we have errors in representing numbers, we had round off error. We have a similar error here. If you try to represent the function, right, if you try to represent the function using box function, you do not get the original function. Actually that should be obvious. We are using constant functions to represent something that is linear, right. But the fact of the matter is that though I projected it, I went through the formal process. I projected the functions on to the box function. I went through the formal process. And what do I have? I basically have a function here. I have a function here, which supposedly represents, right, supposedly represents this property. Take a closer look. In some integral sense, if you look at this, you will notice the area under this curve. The area under this curve is indeed the area under that little triangle there, right. We have managed somehow we have captured that integral being defined as the dot product has come through, right. And it is the same thing here. So, we are somehow capturing that area properly. But the function value itself is not right, right. So, I no longer want to call this, I do not want to call this p of x. I want to call our representation, give our representation a name. Right now I will call it p tilde, okay. Right now I will call it p tilde. We will introduce more formal notation later. Right now I call it p tilde. So, p tilde of x equals p f f plus p g, p g g plus p h h, okay. So, what do we got so far? If you give me a function, it is possible for me to define box functions, right. It is possible for me to use box functions on the same interval and represent, get components, right. Project those, project the function onto the box function, right. And get components. I am aware that the resulting function that I have will not be identical, unlikely to be identical to the original function. There is an error. In the case of numbers, we called it round off error. In this case I will just call it representation error for now. So, this is a representation error. And the representation error, we have to now figure out how to quantify the representation error, right. Okay. So, having found a way by which we can find a representation and having discovered that there is an error in the representation, we want to now quantify how we get that representation error, okay. How can we do this? Suggestions? So, we have the dot product. We will use the dot product to do it. So, normally what we do is, so we will reuse. So, that is the reason why this dot product is extremely powerful, right. That is the reason why we have used the dot product. We will use the dot product here to define something called a metric. So, from the dot product, from the norm, we will get a metric. It is basically distance. We will get a distance now, right. Now, we only have magnitude. So, think about it. Normally, you can have magnitudes of vectors, which is what we normally, we have defined so far. But you can also get the distance between two position vectors, points, the end points of two position vectors. So, we will do the same thing. So, we can use the dot product. So, if I have two functions, capital F and capital G and I want to know what is the distance between those two functions, right. Then I can ask, I can look at F-G and take the dot product with itself and that should give me a measure of the distance, okay. So, this should be some distance between F and G squared, right. In Cartesian coordinates, if your magnitude is, if your magnitude of a vector is x squared plus y squared plus z squared, right. And then the distance function between, right, the magnitude squared is x squared plus y squared plus z squared. Then you would say x1 minus x2 squared plus y1 minus y2 squared and so on. So, I am just basically mimicking that plus z1 minus z2 squared, right. And the distance itself would be the square root of that. I am just basically mimicking this, okay. I am just repeating whatever we have done in the standard vectors. I am just repeating that. It worked there, it should work here. So, what is the difference? So, now I can ask the question, representation error, I can define it as the square root of the dot product of p of x minus p tilde, right, p minus p tilde. Is that fine? p minus p tilde. Let us get back to this, p minus p tilde. So, p minus p tilde is here. This is p minus p tilde. That distance is p minus p tilde. In fact, if you look at it, these 3 intervals, p minus p tilde is actually the same. For this, in this particular case, p minus p tilde happens to be the same. p minus p tilde happens to be the same. So, if I find p minus p tilde for the first one, then I do not have to really repeat it for all 3 of them. I will just do it for the first one, okay. Find out what is the representation error? Representation error is p minus p tilde dot product which equals dx between 0 to 1, fine. And I will find only the first component. So, I am going to find p minus p f f squared dx integral 0 to 1 third. Is that fine? Everyone, these 3, the differences between the representation and the function in this particular problem, they happen to be the same. I am just making use of that factor. So, what is this? x minus 1 by 6 squared integral 0 to 1 third dx, so many ways by which we could do this, okay. So, this is x minus 1 by 6 cube 1 third between the limits 0 and 1 third. What does this give me? So, 1 is going to be 1 third minus 1 sixth which is 1 sixth cube and the other is going to be plus 1 sixth cube. Is that fine? Okay. And there are 3 of them. So, to get this, to get p minus, to get the representation error, I have 3 of these. So, in fact, it turns out to be 2 times 1 sixth cubed, okay. Everyone, so this would be the representation error. So, as I said, please remember this is the equivalent for our functions like similar to round off error. Are there any questions? Now, we are going to do, can we do better? This function, right, on the interval 0, 1, on the interval 0, 1, if we define 2 functions f and g, then we define 3 different functions f, g and h. Why not see if we can define n functions, right? So, we will define whole host of functions. So, we will define a whole host of functions and I will use the subscript f i to indicate the ith function, right. And what is the ith function going to look like? The ith function, so if I have i, n intervals, if I have n intervals and number these x 0, x 1, x 2, x 3 and so on, all the x's are equally spaced, right. And this goes till 1. My ith function, so the second function, for instance, will go from, will be non-zero from x 1 to x 2. The ith function that would be f 2. The ith function will be non-zero, will be 1 for x belonging to x i – 1 x i, okay. Is that fine? So, I have to maybe be a little more precise about the way I do it. So, what I will do is, I will say f 0 equals 1 in closed interval x 0, x 1, f 1 and it is 0 otherwise, 0 otherwise. f 1 equals 1 on open interval, it is open on one side, x 2 closed on the right side. So, we will keep everything open from there, there on, open on the left, closed on the right, okay. Dot, dot, dot, f i equals 1 on x i – 1 x i, fine. So, let me make a mistake. So, x, f 2 would go from 1 to 2 and f 3 would go from 2 to 3. It will be defined, f 1 will be go, will go from 0 to 1. Oh, I started at f naught. I am sorry, I am sorry, I am sorry. Yeah, f i, f i. Yeah, that is the programming. When we program, when we program, we start the count at 0. Actually, you can see I have started the count there at 0. You will have to keep your eyes open for that. Are there any questions? The intervals are equally spaced, okay. The intervals are equally spaced in all these discussions, right. But you have to now see why, why these functions are orthogonal, why does this work, why are we able to do this, right. That is where we are going to end this class. But right now, let me see if I can use this f i and then we will summarize what we have got. So, what do I have? If I have f i, if I take f i dot f i, the length of any interval is 1 over n. f i dot f i is 1 over n, right. Please check to make sure that that works. f i dot f i is in fact 1 over n. f i dot f j, if i is not equal to j is 0, fine. So, any function, in our case right now, the function that we are using can be represented as approximately some p tilde, can be represented as summation over i going from 1 through n, some a i f i, okay. Everyone, right. Let us get back. We will try to draw a figure for this and see what happens. And again, we will try to find the representation error. Draw a figure for it. I am not going to draw an exact figure. No, this is a little more difficult, right, because there are n of them. So, little more difficult. That is the 45 degree line. So, what you would expect and as I said you can, you can check this out. What you will get is a bunch of steps in this fashion over each interval, over each interval. It is going to be a constant. You cannot represent the linear, right. It might be a constant. However, looking at this, I would guess that the representation error is quite small, okay. Looking at this, I would guess that the representation error is quite small. And just as I did earlier, I am going to find the representation error only in the first interval and just multiply it by n, okay. So, what is the representation error in the first interval? So, for P of x-A1 F1 is what we want. What is this representation error? In order to do this, we need to find A1. What is A1? A1 equals the dot product of P of x, dotted with F1 divided by F1 dot F1. This equals x dx integral 0 to 1 over n divided by 1 over n, x squared by 2, 0 to 1 by n times n, gives me 1 by 2n, okay. So, we have a general expression. 1 by 6, everything works out. We have a general expression, 1 by 2n. So, my A1 therefore is P of x, I am sorry, my error therefore, representation error, P of x-A1 F1, and you guys are letting me get away with a mistake here, okay. P of x-A1 F1 gives me x-1 by 2n squared, the integral between 0 through 1 over n, is that fine? Okay. Earlier we had 0 to 1 third, x-1 sixth. Just verify that it is okay. And this in fact will be x-1 by 2n cubed, 1 third, between the limits 0 and 1 by n and that should turn out to be fine. So, over the whole interval, I will have n of these. The total representation error, just say representation error is, do I take the square root first or do I, so there are n of these, what do I get? n of these, n by 3 into 1 by 2, 1 by 8n cubed plus 1 by 8n cubed. That gives me 1 by 4, I am deliberately leaving the 4 root because I plan to take a square root 3n squared. This is the representation error squared. And therefore, the square of the representation error is that, our representation error is 1 by 2 cubed root 3 times n. Is that fine? Okay. Right. Now what we are going to do is, we are going to look at what we have, what we have managed to do so far and define a few terms. I have just gone through and done all the relevant derivation, just a repetition of what we did earlier. Of course, in the case of vectors, we did not really have a representation error. We had representation error in the form of round off error only in numbers. Now the first thing to note is it gets better as n gets larger. That is what our instinct tells us that we get closer and closer to the straight line as n gets larger. Okay. So that part is good. As n gets larger, it gets better. But there is a bad part to it. What is the bad part? The number of jumps that you have in your representation is also increasing, which I am not comfortable with. Right. So we may be able to live with it. There are by the way, ways by which you can live with it. There are things that you can do to get around it. But it is not, we ask the question, can we do better? Right. So now what have we managed with box function? What have we managed? We have managed to get some way by which we can represent function. Okay. We have managed to figure out some way by which we can estimate the error in that function. Okay. So the error in that function is of the order of 1 over n, which basically means that if I am dividing the interval 01 into n parts, then I have a delta x which is of the order of 1 over n. So the representation error is of the order of delta x. And if I make my delta x smaller and smaller, the representation error also gets smaller and smaller in a linear fashion. Okay. So the error is of first order. The exponent is 1. The error is of first order and rather casually introducing language here. The error is of first order. The error is of first order. The convergence, convergence meaning as I increase n, how close do I get to the solution or to the function that I want? How close does the representation get to the original function? So it converges to the original function because the error goes to 0 and the rate at which it does it is linear. So the convergence is linear. Okay. The error is of order 1. The convergence is linear. The representation, how well, what is the polynomial that you are able to represent exactly? What polynomial can you represent exactly? Constant. So the representation itself is 0th order. Okay. The error is first order. The representation itself, so we represent with box functions, we can get a 0th order representation. The 0th order representation, first order error, linear convergence. Three different things. Fine. Okay. Let us look at this orthogonality business. We need to, we need to from this in order to talk, to converse about these functions, we also need to define some terms. Where did this orthogonality come from? Why, why, where did we get this? F i, F j equals 0, F i not equal to j. Why did that work? How did that happen? Why does that work? So that works simply because if you have one function which is non-zero on the ith interval and you have another function which is non-zero on the jth interval, then if you were to multiply the two, right, this is non-zero where this is 0, this is non-zero where that is 0. So this business of where is it 0, where is it not 0, we need, we need some language for this. Okay. So the interval or the region where the function is non-zero is called the support of the function. So the support of the function is that part of the domain where, that part of the domain of definition where the function is non-zero called the support of the function of F j, right, is the support of the function. So what we have done is we have got orthogonality F i dot F j as being 0 when i not equal to j from the fact that the supports of the two functions are non-overlapping. In a sense the supports are sort of orthogonal. Supports are non-overlapping, you understand. This contrast with if you have seen Fourier series before, right, sin x and cosine x on the interval 0 to 2 pi are orthogonal to each other but they define they are both non-zero, right, almost everywhere, they are both non-zero almost everywhere on the interval 0 to 2 pi, is that clear? Right, whereas here we have achieved orthogonality, we have achieved orthogonality by basically saying that the support of this function is different from the support of that function. They are non-overlapping, that is important, they are non-overlapping and therefore we have orthogonality. That is one thing that we have to notice from there, okay. The second thing is though the function gets closer, it gets jumpier. So we have to ask ourselves the question, is there a way by which can we come up with something that will give us smoother functions. We have constructed these functions, box functions now but is there a mechanism by which we can get smoother functions, okay. So non-overlapping, non-overlapping will give us orthogonality in some sense and if you go for smoother functions, how do I get smoother? The representation here is 0th order. I would like to represent at least the first order which means that I should use some kind of linear interpolate, that is a possibility, some kind of linear interpolate. The other question that you could ask is why not, why bother with all these little bits and pieces f1, f2, f3, f4 and so on? Why not just use polynomials directly? Wouldn't it be just smoother to use just polynomials directly? So there are 2 possible things that we can, 2 possible paths that we can take. Having mentioned Fourier series, why get the orthogonality, why get the orthogonality from non-overlapping domain, right, non-overlapping supports, right, the domain is overlapped but non-overlapping supports, right. Why get orthogonality from that? Why not just get orthogonality from somehow to construct it, right, using the Gram-Schmidt process or something of that sort, why not just get orthogonality directly from the function, right. So there are 2 possible ways by which we can go. What we will do is, we will try to follow this linear process right now, right. We have the box function, we will now try to get, go to a linear mechanism. We will try to use this non-overlapping, we will try to use these non-overlapping functions, supports for the functions and see if it is possible for us to generate linear interpolant. Is that fine? Are there any questions? Okay. So in tomorrow's class, we are basically going to look at, we are basically going to look at, we will start with hat functions, what are called hat functions, where we will use linear interpolants as the basic mechanism, okay, fine.