Numerical Mathematics & Computing, 7 Ed. 4.1 Interpolation Ward Cheney/David Kincaid c UT Austin Engage Learning: Thomson-Brooks/Cole www.engage.com www.ma.utexas.edu/cna/nmc6 November 7, 2011 2011 1 / 24
4.1 Interpolation The viscosity of water has been experimentally determined at different temperatures, as indicated in this table: Temperature 0 5 10 15 Viscosity 1.792 1.519 1.308 1.140 How can we estimate a reasonable value for the viscosity at temperature 8? The method of polynomial interpolation can be used to create a polynomial of degree 3 that assumes the values in the table. This polynomial should provide acceptable intermediate values for temperatures not tabulated. The value of that polynomial at the point 8 turns out to be 1.386. 2011 2 / 24
Polynomial Interpolation We pose three problems concerning the representation of functions to give an indication of the subject matter related to polynomial interpolation, on splines, and on least squares. First Problem: Suppose that we have a table of numerical values of a function: x x 0 x 1 x n y y 0 y 1 y n Is it possible to find a simple and convenient formula that reproduces the given points exactly? 2011 3 / 24
Second Problem: It is assumed that the given table of numerical values is contaminated by errors, as might occur if the values came from a physical experiment. How can we find a formula that represents the data (approximately) and, if possible, filters out the errors? 2011 4 / 24
Third Problem: A function f is given, perhaps in the form of a computer procedure, but it is an expensive function to evaluate. In this case, we ask for another function g that is simpler to evaluate and produces a reasonable approximation to f. Sometimes in this problem, we want g to approximate f with full machine precision. 2011 5 / 24
In all of these problems, a simple function p can be obtained that represents or approximates the given table or function f. The representation p can always be taken to be a polynomial, although many other types of simple functions can also be used. Once a simple function p has been obtained, it can be used in place of f in many situations. For example, the integral of f could be estimated by the integral of p, and the latter should generally be easier to evaluate. 2011 6 / 24
In many situations, a polynomial solution to the problems outlined above will be unsatisfactory from a practical point of view, and other classes of functions must be considered. Later one other class of versatile functions is discussed: the spline functions. Presently, we are concerned with polynomials exclusively, and later we will discuss general linear families of functions, of which splines and polynomials are important examples. The obvious way in which a polynomial can fail as a practical solution to one of the preceding problems is that its degree may be unreasonably high. 2011 7 / 24
For instance, if the table considered contains 1,000 entries, a polynomial of degree 999 may be required to represent it. Polynomials also may have the surprising defect of being highly oscillatory. If the table is precisely represented by a polynomial p, then p(x i ) = y i for 0 i n. For points other than the given x i, however, p(x) may be a very poor representation of the function from which the table arose. Later an example involving the Runge function illustrates this phenomenon. 2011 8 / 24
Polynomial Interpolation We begin again with a table of values and assume that the x i s form a set of n + 1 distinct points. x x 0 x 1 x n y y 0 y 1 y n The table represents n + 1 points in the Cartesian plane, and we want to find a polynomial curve that passes through all points. 2011 9 / 24
Thus, we seek to determine a polynomial that is defined for all x, and takes on the corresponding values of y i for each of the n + 1 distinct x i s in this table. A polynomial p for which is said to interpolate the table. The points x i are called nodes. p(x i ) = y i (0 i n) 2011 10 / 24
Consider the first and simplest case, n = 0. Here, a constant function solves the problem. In other words, the polynomial p of degree 0 defined by the equation p(x) = y 0 reproduces the one-node table. 2011 11 / 24
The next simplest case occurs when n = 1. Since a straight line can be passed through two points, a linear function is capable of solving the problem. Explicitly, the polynomial p defined by ( x x1 ) p(x) = x 0 x 1 = y 0 + ( x x0 ) y 0 + x 1 x 0 ( y1 y ) 0 (x x 0 ) x 1 x 0 is of first degree (at most) and reproduces the table. That means (in this case) that p(x 0 ) = y 0 and p(x 1 ) = y 1, as is easily verified. This p is used for linear interpolation. y 1 2011 12 / 24
Example Find the polynomial of least degree that interpolates this table: x 1.4 1.25 y 3.7 3.9 2011 13 / 24
By the equation above, the polynomial that is sought is p(x) = ( x 1.25 1.4 1.25 = 3.7 + ) ( x 1.4 3.7 + 1.25 1.4 ( 3.9 3.7 1.25 1.4 = 3.7 4 (x 1.4) 3 ) (x 1.4) ) 3.9 2011 14 / 24
As we can see, an interpolating polynomial can be written in a variety of forms; among these are those known as the Newton form and the Lagrange form. The Newton form is probably the most convenient and efficient; however, conceptually, the Lagrange form has several advantages. 2011 15 / 24
Recursive Property of Divided Differences At the heart of the new method is the following remarkable theorem: Theorem The divided differences obey the formula f [x 0, x 1,..., x k ] = f [x 1, x 2,..., x k ] f [x 0, x 1,..., x k 1 ] x k x 0 (1) 2011 16 / 24
Notice that f [x 0, x 1,..., x k ] is not changed if the nodes x 0, x 1,..., x k are permuted: Thus, for example, f [x 0, x 1, x 2 ] = f [x 1, x 2, x 0 ] The reason is that f [x 0, x 1, x 2 ] is the coefficient of x 2 in the quadratic polynomial interpolating f at x 0, x 1, x 2, Whereas f [x 1, x 2, x 0 ] is the coefficient of x 2 in the quadratic polynomial interpolating f at x 1, x 2, x 0 These two polynomials are, of course, the same. 2011 17 / 24
Invariance Theorem A formal statement in mathematical language is as follows: Theorem The divided difference f [x 0, x 1,..., x k ] is invariant under all permutations of the arguments x 0, x 1,..., x k. 2011 18 / 24
Since the variables x 0, x 1,..., x k and k are arbitrary, the recursive Formula (1) can also be written as f [x i, x i+1,..., x j 1, x j ] = f [x i+1, x i+2,..., x j ] f [x i, x i+1,..., x j 1 ] x j x i (2) The first three divided differences are thus f [x i ] = f (x i ) f [x i, x i+1 ] = f [x i+1] f [x i ] x i+1 x i f [x i, x i+1, x i+2 ] = f [x i+1, x i+2 ] f [x i, x i+1 ] x i+2 x i 2011 19 / 24
Using Formula (3), we can construct a divided-difference table for a function f. It is customary to arrange it as follows (here n = 3): x f [ ] f [, ] f [,, ] f [,,, ] x 0 f [x 0 ] f [x 0, x 1 ] x 1 f [x 1 ] f [x 0, x 1, x 2 ] f [x 1, x 2 ] f [x 0, x 1, x 2, x 3 ] x 2 f [x 2 ] f [x 1, x 2, x 3 ] f [x 2, x 3 ] x 3 f [x 3 ] In the table, the coefficients along the top diagonal are the ones needed to form the Newton form of the interpolating polynomial. 2011 20 / 24
Example Construct a divided-difference diagram for the function f given in the following table, and write out the Newton form of the interpolating polynomial. x 1 3 2 0 2 13 5 f (x) 3 4 3 3 2011 21 / 24
The first entry is f [x 0, x 1 ] = ( 13 4 3) / ( 3 2 1) = 1 2 After completion of column 3, the first entry in column 4 is f [x 0, x 1, x 2 ] = f [x 1, x 2 ] f [x 0, x 1 ] x 2 x 0 = The complete diagram follows. 1 6 1 2 0 1 = 1 3 2011 22 / 24
x f [ ] f [, ] f [,, ] f [,,, ] 1 3 3 2 13 4 1 2 1 1 3 6 2 0 3 5 3 2 3 2 5 3 2011 23 / 24
Thus, we obtain p 3 (x) = 3 + 1 2 (x 1) + 1 3 (x 1)( x 3 2) 2(x 1) ( x 3 2) x 2011 24 / 24