CHAPTER 05.04: LAGRANGE METHOD: Linear Interpolation: Example

 

In this segment, we're going to take an example for Lagrangian interpolation. So the example which we are taking is the simplest example of linear interpolation. So let's suppose somebody is giving you the data like this one. They're giving you velocity versus time for a rocket, time is given in seconds, velocity is given in meters per second, and these are the numbers which they give you, that at time, t equal to 0, velocity is 0, at 10 it is 227.04, at 15 it is 362.78, at 20 it is 517.35, at 22.5 it is 602.97, and at 30 it is 901.67. So the question which is being asked is that you are given this data here, so given this data here, you're asked to find the value of the velocity at 16.  So we know that, since we are given six data points, but we are only conducting linear interpolation, so that's the part of the example statement, that you need to conduct a linear interpolation, you're going to choose the two closest points which are to 16, which seem to be 15 and 20, but at the same time, they also have to bracket the number 16. So the two numbers which you're going to select for linear interpolation not only have to be closest to the point where you are interested in finding the intermediate value, but also they have to bracket the two points . . . the point itself.  So what that means is that we have chosen two data points for our linear interpolation, and we want to conduct this linear interpolation based on . . . based on the two data points which you have chosen. So I'm going to write those down, I've got 15, 20 are the times, the values are 362.78, and the value here is 517.35.  Based on this, we already know that the velocity now should look like, so far as the Lagrangian polynomial interpolation is concerned, will be summation, i equal to 0 to n, Li t, vi t . . . sorry, v of ti. So it is the weighting function multiplied by the value of the velocities at the different points which you have chosen, and since n is equal to 1 in this case, because we are choosing a linear interpolant, so it's an order of polynomial 1, we have Li t, v of ti, and if I expand this, I'm going to get L0 of t times v at t0, plus L1 of t times v of t1.  So basically you have two values of the velocity at t0 and t1, and you're giving them a weight of L0 of t here and L1 of t right there.  And what is t0 and t1? This is t0, and this is t1, it won't matter if you switch them, that's something which you do need to understand, and this one here is the value of the velocity at t0, and this one is the value of the velocity at t1. So we have everything which we need, and all we have to do is to calculate what these individual . . . individual numbers are for L0 of t and L1 of t. So what I'm going to do is I'm going to write down here L0 of t times the value of the velocity at 15, plus L1 of t times the value of the velocity at 20, because those are the values of t0 and t1. So this gives you L0 of t, v of 15 is 362.78, plus L1 of t times the value of the velocity at t1 is 517.35. So let's go ahead and find out what these two Lagrangian weight functions are, so that we can complete this particular interpolant here. So the first one is L0 of t. So L0 of t will be equal to the product going from j equal to 0, j not equal to i, all the way up to n, which is 1 in this case, okay, times t minus tj, divided by ti, which is i is 0, minus tj.  So, if you look at the original formula which I have, this comes from Pi, j equal to 0, j not equal to i, going to n, n is 1, t minus tj, divided by ti minus tj, that's where all of this is coming from, and since i is equal to 0, that's why I have a 0 here, since n is equal to 1, linear interpolant, we have a 1 here. So what this means is that we're going to get t minus, when I take j equal to 0, I'm going to get t minus t0, divided by t0 minus t1 . . . sorry, this will be t1 right here, because when j is equal to 0, j is not equal to i, so I cannot choose j equal to 0.  I cannot choose j equal to 0, because i is equal to 0, so that's why this term is not going to be taken. So when I was saying I'm taking j equal to 0, I cannot take j equal to 0 because I have i equal to 0 there, so the next term will be j equal to 1, so that's why I have t minus t1, and t0 minus t1. Now, L1 of t, which is the other weighting function, will be going from, again, j equal to 0 to 1, j not equal to i, t minus tj, divided by t1 minus tj.  So the only difference with the previous expression is that now you have instead of 1 . . . instead of 0, you have 1 now, you're going to have 1 here. Now, what you're going to do is you're going to start from j equal to 0, which is not equal to i, because i is 1, so that means that I've got to put j equal to 0 here, I get t minus t0, divided by t1 minus t0. Now I cannot, the next term which is j equal to 1 is the same as i equal to 1, so that term will not be written there, so we only have a single term there.  So that gives us the weight of L1 t, and that gives us the weight of L0 of t.  So I'm going to substitute it back into the formula which I had previously.  So I had v of t equal to L0 of t times . . . times v of t0, which was 362.78 . . . 362.78, plus L1 of t, times the value of the velocity at 20, which was 517.35, and now I'm going to substitute these weights. So I get t minus t1, divided by t0 minus t1, times 362.78, then plus t minus t0, divided by t1 minus t0, times 517.35. And you very well see that now I can substitute these values, I get t minus t1, is 20, divided by t0, which is 15, t1 is 20, times 362.78, plus t minus t0, which is 15, divided by t1, which is 20, t0, which is 15, times 517.35. So that's going to be my . . . that will be my Lagrangian interpolant, if you want to write it in that particular form, and maybe give it a . . . maybe try to simplify it if you want to, and it will be valid between 15 and 20, because those are the two endpoints which we have chosen for this linear interpolant, but we are interested in finding the value of the velocity at 16, so we don't need to necessarily . . . necessarily simply this expression to find the value of velocity at 16, because then we substitute 16 into the expression, and we get 16 here. And the number which I get for the interpolant at t equal to 16 will be equal to  0.8 times 362.78, plus 0.2 times 517.35, and this number here turns out to be 393.69 meters per second, and that's what it turns out to be the velocity at 16 by using Lagrangian interpolation. And that's the end of this segment.