Math 128A Spring 2002 Handout # 17 Sergey Fomel March 14, 2002 Answers to Homework 6: Interpolation: Spline Interpolation 1. In class, we interpolated the function f (x) =1 x at the points x =2,4,5 with the cubic spline that satisfied the natural boundary conditions.
In mathematics, linear interpolation is a method of curve fitting using linear polynomials to construct new data points within the range of a discrete set of known data points.
- 5Extensions
Linear interpolation between two known points[edit]
Quadratic Polynomial Interpolation
If the two known points are given by the coordinates and , the linear interpolant is the straight line between these points. For a value x in the interval , the value y along the straight line is given from the equation of slopes
which can be derived geometrically from the figure on the right. It is a special case of polynomial interpolation with n = 1.
Solving this equation for y, which is the unknown value at x, gives
which is the formula for linear interpolation in the interval . Outside this interval, the formula is identical to linear extrapolation.
This formula can also be understood as a weighted average. The weights are inversely related to the distance from the end points to the unknown point; the closer point has more influence than the farther point. Thus, the weights are and , which are normalized distances between the unknown point and each of the end points. Because these sum to 1,
which yields the formula for linear interpolation given above.
Interpolation of a data set[edit]
Linear interpolation on a set of data points (x0, y0), (x1, y1), ..., (xn, yn) is defined as the concatenation of linear interpolants between each pair of data points. This results in a continuous curve, with a discontinuous derivative (in general), thus of differentiability class.
Linear interpolation as approximation[edit]
Linear interpolation is often used to approximate a value of some functionf using two known values of that function at other points. The error of this approximation is defined as
where p denotes the linear interpolation polynomial defined above:
It can be proven using Rolle's theorem that if f has a continuous second derivative, then the error is bounded by
Linear Program Polynomial Interpolation Examples
That is, the approximation between two points on a given function gets worse with the second derivative of the function that is approximated. This is intuitively correct as well: the 'curvier' the function is, the worse the approximations made with simple linear interpolation become.
History and applications[edit]
Linear interpolation has been used since antiquity for filling the gaps in tables. Suppose that one has a table listing the population of some country in 1970, 1980, 1990 and 2000, and that one wanted to estimate the population in 1994. Linear interpolation is an easy way to do this. The technique of using linear interpolation for tabulation was believed to be used by Babylonian astronomers and mathematicians in SeleucidMesopotamia (last three centuries BC), and by the Greek astronomer and mathematician, Hipparchus (2nd century BC). A description of linear interpolation can be found in the Almagest (2nd century AD) by Ptolemy.
The basic operation of linear interpolation between two values is commonly used in computer graphics. In that field's jargon it is sometimes called a lerp. The term can be used as a verb or noun for the operation. e.g. 'Bresenham's algorithm lerps incrementally between the two endpoints of the line.'
Lerp operations are built into the hardware of all modern computer graphics processors. They are often used as building blocks for more complex operations: for example, a bilinear interpolation can be accomplished in three lerps. Because this operation is cheap, it's also a good way to implement accurate lookup tables with quick lookup for smooth functions without having too many table entries.
Extensions[edit]
Accuracy[edit]
If a C0 function is insufficient, for example if the process that has produced the data points is known to be smoother than C0, it is common to replace linear interpolation with spline interpolation or, in some cases, polynomial interpolation.
Multivariate[edit]
Linear interpolation as described here is for data points in one spatial dimension. For two spatial dimensions, the extension of linear interpolation is called bilinear interpolation, and in three dimensions, trilinear interpolation. Notice, though, that these interpolants are no longer linear functions of the spatial coordinates, rather products of linear functions; this is illustrated by the clearly non-linear example of bilinear interpolation in the figure below. Other extensions of linear interpolation can be applied to other kinds of mesh such as triangular and tetrahedral meshes, including Bézier surfaces. These may be defined as indeed higher-dimensional piecewise linear function (see second figure below).
Programming language support[edit]
Many libraries and shading languages (in GLSL known instead as mix) have a 'lerp' helper-function, returning an interpolation between two inputs (v0, v1) for a parameter (t) in the closed unit interval [0, 1]. Signatures between lerp functions are variously implemented in both the forms (v0, v1, t) and (t, v0, v1).
This lerp function is commonly used for alpha blending (the parameter 't' is the 'alpha value'), and the formula may be extended to blend multiple components of a vector (such as spatial x, y, z axes or r, g, b colour components) in parallel.
See also[edit]
References[edit]
- Meijering, Erik (2002), 'A chronology of interpolation: from ancient astronomy to modern signal and image processing', Proceedings of the IEEE, 90 (3): 319–342, doi:10.1109/5.993400.
External links[edit]
- Equations of the Straight Line at cut-the-knot
- Hazewinkel, Michiel, ed. (2001) [1994], 'Linear interpolation', Encyclopedia of Mathematics, Springer Science+Business Media B.V. / Kluwer Academic Publishers, ISBN978-1-55608-010-4
- Hazewinkel, Michiel, ed. (2001) [1994], 'Finite-increments formula', Encyclopedia of Mathematics, Springer Science+Business Media B.V. / Kluwer Academic Publishers, ISBN978-1-55608-010-4
In numerical analysis, polynomial interpolation is the interpolation of a given data set by the polynomial of lowest possible degree that passes through the points of the dataset.[1]
- 4Uniqueness of the interpolating polynomial
- 7Interpolation error
Applications[edit]
Polynomials can be used to approximate complicated curves, for example, the shapes of letters in typography,[citation needed] given a few points. A relevant application is the evaluation of the natural logarithm and trigonometric functions: pick a few known data points, create a lookup table, and interpolate between those data points. This results in significantly faster computations.[specify] Polynomial interpolation also forms the basis for algorithms in numerical quadrature and numerical ordinary differential equations and Secure Multi Party Computation, Secret Sharing schemes.
Polynomial interpolation is also essential to perform sub-quadratic multiplication and squaring such as Karatsuba multiplication and Toom–Cook multiplication, where an interpolation through points on a polynomial which defines the product yields the product itself. For example, given a = f(x) = a0x0 + a1x1 + ... and b = g(x) = b0x0 + b1x1 + ..., the product ab is equivalent to W(x) = f(x)g(x). Finding points along W(x) by substituting x for small values in f(x) and g(x) yields points on the curve. Interpolation based on those points will yield the terms of W(x) and subsequently the product ab. In the case of Karatsuba multiplication this technique is substantially faster than quadratic multiplication, even for modest-sized inputs. This is especially true when implemented in parallel hardware.
Definition[edit]
Given a set of n + 1 data points (xi, yi) where no two xi are the same, one is looking for a polynomial p of degree at most n with the property
The unisolvence theorem states that such a polynomial p exists and is unique, and can be proved by the Vandermonde matrix, as described below.
The theorem states that for n + 1 interpolation nodes (xi), polynomial interpolation defines a linear bijection
where Πn is the vector space of polynomials (defined on any interval containing the nodes) of degree at most n.
Constructing the interpolation polynomial[edit]
Suppose that the interpolation polynomial is in the form
The statement that p interpolates the data points means that
If we substitute equation (1) in here, we get a system of linear equations in the coefficients ak. The system in matrix-vector form reads the following multiplication:
We have to solve this system for ak to construct the interpolant p(x). The matrix on the left is commonly referred to as a Vandermonde matrix.
The condition number of the Vandermonde matrix may be large,[2] causing large errors when computing the coefficients ai if the system of equations is solved using Gaussian elimination.
Several authors have therefore proposed algorithms which exploit the structure of the Vandermonde matrix to compute numerically stable solutions in O(n2) operations instead of the O(n3) required by Gaussian elimination.[3][4][5] These methods rely on constructing first a Newton interpolation of the polynomial and then converting it to the monomial form above.
Alternatively, we may write down the polynomial immediately in terms of Lagrange polynomials:
For matrix arguments, this formula is called Sylvester's formula and the matrix-valued Lagrange polynomials are the Frobenius covariants.
Uniqueness of the interpolating polynomial[edit]
Proof 1[edit]
Suppose we interpolate through n + 1 data points with an at-most n degree polynomial p(x) (we need at least n + 1 datapoints or else the polynomial cannot be fully solved for). Suppose also another polynomial exists also of degree at most n that also interpolates the n + 1 points; call it q(x).
Consider . We know,
- r(x) is a polynomial
- r(x) has degree at most n, since p(x) and q(x) are no higher than this and we are just subtracting them.
- At the n + 1 data points, . Therefore, r(x) has n + 1 roots.
But r(x) is a polynomial of degree ≤ n. It has one root too many. Formally, if r(x) is any non-zero polynomial, it must be writable as , for some constant A. By distributivity, the n + 1x's multiply together to give leading term , i.e. one degree higher than the maximum we set. So the only way r(x) can exist is if A = 0, or equivalently, r(x) = 0.
So q(x) (which could be any polynomial, so long as it interpolates the points) is identical with p(x), and q(x) is unique.
Proof 2[edit]
Given the Vandermonde matrix used above to construct the interpolant, we can set up the system
To prove that V is nonsingular we use the Vandermonde determinant formula:
since the n + 1 points are distinct, the determinant can't be zero as is never zero, therefore V is nonsingular and the system has a unique solution.
Either way this means that no matter what method we use to do our interpolation: direct, Lagrange etc., (assuming we can do all our calculations perfectly) we will always get the same polynomial.
Non-Vandermonde solutions[edit]
We are trying to construct our unique interpolation polynomial in the vector space Πn of polynomials of degree n. When using a monomial basis for Πn we have to solve the Vandermonde matrix to construct the coefficients ak for the interpolation polynomial. This can be a very costly operation (as counted in clock cycles of a computer trying to do the job). By choosing another basis for Πn we can simplify the calculation of the coefficients but then we have to do additional calculations when we want to express the interpolation polynomial in terms of a monomial basis.
One method is to write the interpolation polynomial in the Newton form and use the method of divided differences to construct the coefficients, e.g. Neville's algorithm. The cost is O(n2) operations, while Gaussian elimination costs O(n3) operations. Furthermore, you only need to do O(n) extra work if an extra point is added to the data set, while for the other methods, you have to redo the whole computation.
Another method is to use the Lagrange form of the interpolation polynomial. The resulting formula immediately shows that the interpolation polynomial exists under the conditions stated in the above theorem. Lagrange formula is to be preferred to Vandermonde formula when we are not interested in computing the coefficients of the polynomial, but in computing the value of p(x) in a given x not in the original data set. In this case, we can reduce complexity to O(n2).[6]
The Bernstein form was used in a constructive proof of the Weierstrass approximation theorem by Bernstein and has gained great importance in computer graphics in the form of Bézier curves.
Linear combination of the given values[edit]
The Lagrange form of the interpolating polynomial is a linear combination of the given values. In many scenarios, an efficient and convenient polynomial interpolation is a linear combination of the given values, using previously known coefficients. Given a set of data points where each data point is a (position, value) pair and where no two positions are the same, the interpolation polynomial in the Lagrange form is a linear combination
of the given values with each coefficient given by evaluating the corresponding Lagrange basis polynomial using the given positions .
Linear Interpolation
Each coefficient in the linear combination depends on the given positions and the desired position , but not on the given values . For each coefficient, inserting the values of the given positions and simplifying yields an expression , which depends only on . Thus the same coefficient expressions can be used in a polynomial interpolation of a given second set of data points at the same given positions , where the second given values differ from the first given values . Using the same coefficient expressions as for the first set of data points, the interpolation polynomial of the second set of data points is the linear combination
For each coefficient in the linear combination, the expression resulting from the Lagrange basis polynomial only depends on the relative spaces between the given positions, not on the individual value of any position. Thus the same coefficient expressions can be used in a polynomial interpolation of a given third set of data points
Linear Interpolation Example Problem
where each position is related to the corresponding position in the first set by and the desired positions are related by , for a constant scaling factor a and a constant shift b for all positions. Using the same coefficient expressions as for the first set of data points, the interpolation polynomial of the third set of data points is the linear combination
In many applications of polynomial interpolation, the given set of data points is at equally spaced positions. In this case, it can be convenient to define the x-axis of the positions such that . For example, a given set of 3 equally-spaced data points is then .
The interpolation polynomial in the Lagrange form is the linear combination
This quadratic interpolation is valid for any position x, near or far from the given positions. So, given 3 equally-spaced data points at defining a quadratic polynomial, at an example desired position , the interpolated value after simplification is given by
This is a quadratic interpolation typically used in the Multigrid method. Again given 3 equally-spaced data points at defining a quadratic polynomial, at the next equally spaced position , the interpolated value after simplification is given by
In the above polynomial interpolations using a linear combination of the given values, the coefficients were determined using the Lagrange method. In some scenarios, the coefficients can be more easily determined using other methods. Examples follow.
According to the method of finite differences, for any polynomial of degree d or less, any sequence of values at equally spaced positions has a th difference exactly equal to 0. The element sd+1 of the Binomial transform is such a th difference. This area is surveyed here[7]. The binomial transform, T, of a sequence of values {vn}, is the sequence {sn} defined by
Ignoring the sign term , the coefficients of the element sn are the respective elements of the row n of Pascal's Triangle. The triangle of binomial transform coefficients is like Pascal's triangle. The entry in the nth row and kth column of the BTC triangle is for any non-negative integer n and any integer k between 0 and n. This results in the following example rows n = 0 through n = 7, top to bottom, for the BTC triangle:
For convenience, each row n of the above example BTC triangle also has a label . Thus for any polynomial of degree d or less, any sequence of values at equally spaced positions has a linear combination result of 0, when using the elements of row d as the corresponding linear coefficients.
For example, 4 equally spaced data points of a quadratic polynomial obey the linear equation given by row of the BTC triangle. This is the same linear equation as obtained above using the Lagrange method.
The BTC triangle can also be used to derive other polynomial interpolations. For example, the above quadratic interpolation
can be derived in 3 simple steps as follows. The equally spaced points of a quadratic polynomial obey the rows of the BTC triangle with or higher. First, the row spans the given and desired data points with the linear equation
Second, the unwanted data point is replaced by an expression in terms of wanted data points. The row provides a linear equation with a term , which results in a term by multiplying the linear equation by 4. Third, the above two linear equations are added to yield a linear equation equivalent to the above quadratic interpolation for .
Similar to other uses of linear equations, the above derivation scales and adds vectors of coefficients. In polynomial interpolation as a linear combination of values, the elements of a vector correspond to a contiguous sequence of regularly spaced positions. The p non-zero elements of a vector are the p coefficients in a linear equation obeyed by any sequence of p data points from any degree d polynomial on any regularly spaced grid, where d is noted by the subscript of the vector. For any vector of coefficients, the subscript obeys . When adding vectors with various subscript values, the lowest subscript applies for the resulting vector. So, starting with the vector of row and the vector of row of the BTC triangle, the above quadratic interpolation for is derived by the vector calculation
Similarly, the cubic interpolation typical in the Multigrid method,
can be derived by a vector calculation starting with the vector of row and the vector of row of the BTC triangle.
Interpolation error[edit]
When interpolating a given function f by a polynomial of degree n at the nodes x0,...,xn we get the error
where
is the notation for divided differences.
If f is n + 1 times continuously differentiable on a closed interval I and is a polynomial of degree at most n that interpolates f at n + 1 distinct points {xi} (i=0,1,...,n) in that interval, then for each x in the interval there exists ξ in that interval such that
The above error bound suggests choosing the interpolation points xi such that the product is as small as possible. The Chebyshev nodes achieve this.
Proof[edit]
Set the error term as
and set up an auxiliary function:
where
Since xi are roots of and , we have Y(x) = Y(xi) = 0, which means Y has at least n + 2 roots. From Rolle's theorem, has at least n + 1 roots, then has at least one root ξ, where ξ is in the interval I.
So we can get
Since is a polynomial of degree at most n, then
Thus
Since ξ is the root of , so
Therefore,
Linear Interpolation Equation
- .
Thus the remainder term in the Lagrange form of the Taylor theorem is a special case of interpolation error when all interpolation nodes xi are identical.[8] Note that the error will be zero when for any i. Thus, the maximum error will occur at some point in the interval between two successive nodes.
For equally spaced intervals[edit]
In the case of equally spaced interpolation nodes where , for and where the product term in the interpolation error formula can be bound as[9]
- .
Thus the error bound can be given as
However, this assumes that is dominated by , i.e. . In several cases, this is not true and the error actually increases as n → ∞ (see Runge's phenomenon). That question is treated in the section Convergence properties.
Lebesgue constants[edit]
- See the main article: Lebesgue constant.
We fix the interpolation nodes x0, ..., xn and an interval [a, b] containing all the interpolation nodes. The process of interpolation maps the function f to a polynomial p. This defines a mapping X from the space C([a, b]) of all continuous functions on [a, b] to itself. The map X is linear and it is a projection on the subspace Πn of polynomials of degree n or less.
The Lebesgue constant L is defined as the operator norm of X. One has (a special case of Lebesgue's lemma):
In other words, the interpolation polynomial is at most a factor (L + 1) worse than the best possible approximation. This suggests that we look for a set of interpolation nodes that makes L small. In particular, we have for Chebyshev nodes:
We conclude again that Chebyshev nodes are a very good choice for polynomial interpolation, as the growth in n is exponential for equidistant nodes. However, those nodes are not optimal.
Convergence properties[edit]
It is natural to ask, for which classes of functions and for which interpolation nodes the sequence of interpolating polynomials converges to the interpolated function as n → ∞? Convergence may be understood in different ways, e.g. pointwise, uniform or in some integral norm.
The situation is rather bad for equidistant nodes, in that uniform convergence is not even guaranteed for infinitely differentiable functions. One classical example, due to Carl Runge, is the function f(x) = 1 / (1 + x2) on the interval [−5, 5]. The interpolation error || f − pn||∞ grows without bound as n → ∞. Another example is the function f(x) = |x| on the interval [−1, 1], for which the interpolating polynomials do not even converge pointwise except at the three points x = ±1, 0.[10]
One might think that better convergence properties may be obtained by choosing different interpolation nodes. The following result seems to give a rather encouraging answer:
- Theorem. For any function f(x) continuous on an interval [a,b] there exists a table of nodes for which the sequence of interpolating polynomials converges to f(x) uniformly on [a,b].
Proof. It's clear that the sequence of polynomials of best approximation converges to f(x) uniformly (due to Weierstrass approximation theorem). Now we have only to show that each may be obtained by means of interpolation on certain nodes. But this is true due to a special property of polynomials of best approximation known from the equioscillation theorem. Specifically, we know that such polynomials should intersect f(x) at least n + 1 times. Choosing the points of intersection as interpolation nodes we obtain the interpolating polynomial coinciding with the best approximation polynomial.
The defect of this method, however, is that interpolation nodes should be calculated anew for each new function f(x), but the algorithm is hard to be implemented numerically. Does there exist a single table of nodes for which the sequence of interpolating polynomials converge to any continuous function f(x)? The answer is unfortunately negative:
- Theorem. For any table of nodes there is a continuous function f(x) on an interval [a, b] for which the sequence of interpolating polynomials diverges on [a,b].[11]
The proof essentially uses the lower bound estimation of the Lebesgue constant, which we defined above to be the operator norm of Xn (where Xn is the projection operator on Πn). Now we seek a table of nodes for which
Due to the Banach–Steinhaus theorem, this is only possible when norms of Xn are uniformly bounded, which cannot be true since we know that
For example, if equidistant points are chosen as interpolation nodes, the function from Runge's phenomenon demonstrates divergence of such interpolation. Note that this function is not only continuous but even infinitely differentiable on [−1, 1]. For better Chebyshev nodes, however, such an example is much harder to find due to the following result:
- Theorem. For every absolutely continuous function on [−1, 1] the sequence of interpolating polynomials constructed on Chebyshev nodes converges to f(x) uniformly.[12]
Related concepts[edit]
Runge's phenomenon shows that for high values of n, the interpolation polynomial may oscillate wildly between the data points. This problem is commonly resolved by the use of spline interpolation. Here, the interpolant is not a polynomial but a spline: a chain of several polynomials of a lower degree.
Interpolation of periodic functions by harmonic functions is accomplished by Fourier transform. This can be seen as a form of polynomial interpolation with harmonic base functions, see trigonometric interpolation and trigonometric polynomial.
Hermite interpolation problems are those where not only the values of the polynomial p at the nodes are given, but also all derivatives up to a given order. This turns out to be equivalent to a system of simultaneous polynomial congruences, and may be solved by means of the Chinese remainder theorem for polynomials. Birkhoff interpolation is a further generalization where only derivatives of some orders are prescribed, not necessarily all orders from 0 to a k.
Collocation methods for the solution of differential and integral equations are based on polynomial interpolation.
The technique of rational function modeling is a generalization that considers ratios of polynomial functions.
At last, multivariate interpolation for higher dimensions.
See also[edit]
Notes[edit]
- ^Tiemann, Jerome J. (May–June 1981). 'Polynomial Interpolation'. I/O News. 1 (5): 16. ISSN0274-9998. Retrieved 3 November 2017.
- ^Gautschi, Walter (1975). 'Norm Estimates for Inverses of Vandermonde Matrices'. Numerische Mathematik. 23 (4): 337–347. doi:10.1007/BF01438260.
- ^Higham, N. J. (1988). 'Fast Solution of Vandermonde-Like Systems Involving Orthogonal Polynomials'. IMA Journal of Numerical Analysis. 8 (4): 473–486. doi:10.1093/imanum/8.4.473.
- ^Björck, Å; V. Pereyra (1970). 'Solution of Vandermonde Systems of Equations'. Mathematics of Computation. American Mathematical Society. 24 (112): 893–903. doi:10.2307/2004623. JSTOR2004623.
- ^Calvetti, D & Reichel, L (1993). 'Fast Inversion of Vanderomnde-Like Matrices Involving Orthogonal Polynomials'. BIT. 33 (33): 473–484. doi:10.1007/BF01990529.
- ^R.Bevilaqua, D. Bini, M.Capovani and O. Menchi (2003). Appunti di Calcolo Numerico. Chapter 5, p. 89. Servizio Editoriale Universitario Pisa - Azienda Regionale Diritto allo Studio Universitario.
- ^Boyadzhiev, Boyad (2012). 'Close Encounters with the Stirling Numbers of the Second Kind'(PDF). Math. Mag. 85: 252–266.
- ^'Errors in Polynomial Interpolation'(PDF).
- ^'Notes on Polynomial Interpolation'(PDF).
- ^Watson (1980, p. 21) attributes the last example to Bernstein (1912).
- ^Watson (1980, p. 21) attributes this theorem to Faber (1914).
- ^Krylov, V. I. (1956). 'Сходимость алгебраического интерполирования покорням многочленов Чебышева для абсолютно непрерывных функций и функций с ограниченным изменением' [Convergence of algebraic interpolation with respect to the roots of Chebyshev's polynomial for absolutely continuous functions and functions of bounded variation]. Doklady Akademii Nauk SSSR (N.S.) (in Russian). 107: 362–365. MR 18-32.
Polynomial Interpolation Examples
References[edit]
- Atkinson, Kendell A. (1988), 'Chapter 3.', An Introduction to Numerical Analysis (2nd ed.), John Wiley and Sons, ISBN0-471-50023-2
- Bernstein, Sergei N. (1912), 'Sur l'ordre de la meilleure approximation des fonctions continues par les polynômes de degré donné' [On the order of the best approximation of continuous functions by polynomials of a given degree], Mem. Acad. Roy. Belg. (in French), 4: 1–104
- Brutman, L. (1997), 'Lebesgue functions for polynomial interpolation — a survey', Ann. Numer. Math., 4: 111–127
- Faber, Georg (1914), 'Über die interpolatorische Darstellung stetiger Funktionen' [On the Interpolation of Continuous Functions], Deutsche Math. Jahr. (in German), 23: 192–210
- Powell, M. J. D. (1981), 'Chapter 4', Approximation Theory and Methods, Cambridge University Press, ISBN0-521-29514-9
- Schatzman, Michelle (2002), 'Chapter 4', Numerical Analysis: A Mathematical Introduction, Oxford: Clarendon Press, ISBN0-19-850279-6
- Süli, Endre; Mayers, David (2003), 'Chapter 6', An Introduction to Numerical Analysis, Cambridge University Press, ISBN0-521-00794-1
- Watson, G. Alistair (1980), Approximation Theory and Numerical Methods, John Wiley, ISBN0-471-27706-1
External links[edit]
- Hazewinkel, Michiel, ed. (2001) [1994], 'Interpolation process', Encyclopedia of Mathematics, Springer Science+Business Media B.V. / Kluwer Academic Publishers, ISBN978-1-55608-010-4
- ALGLIB has an implementations in C++ / C#.
- GSL has a polynomial interpolation code in C
- Interpolating Polynomial by Stephen Wolfram, the Wolfram Demonstrations Project.