A Useful Application Of Lagrange Interpolation Is Called A Table

A useful application of Lagrange interpolation is called a table look-up. As the name implies, this involves “looking-up” an intermediate value from a table. To develop such an algorithm, the table of x and ƒ(x) values are first stored in a pair of one-dimensional arrays. These values are then passed to a function along with the x value you wish to evaluate. The function then performs two tasks. First, it loops down through the table unit it finds the interval within which the unknown lies. Then it applies a technique like Lagrange interpolation to determine the proper ƒ(x) value. Develop such a function using a cubic Lagrange polynomial to perform the interpolation. For intermediate intervals, this is a nice choice because the unknown will be located in the interval in the middle of the four points necessary to generate the cubic. For the first and last intervals, use a quadratic Lagrange polynomial. Also have your code detect when the user requests a value outside the range of x’s. For such cases, the function should display an error massage. Test your program for ƒ(x) = In x using data from x = 0, 1, 2,., 10.

Posted in Uncategorized