The simplest method of interpolation is to draw straight lines between the known data points and consider the function as the combination of those straight lines. This method, called linear interpolation, usually introduces considerable error. A more precise approach uses a polynomial function to connect the points. A is a mathematical expression comprising a sum of terms, each term including a variable or variables raised to a power and multiplied by a.
The simplest polynomials have one variable. Polynomials can exist in factored form or written out in full. For example: ( x - 4) ( x + 2) ( x + 10) x 2 + 2 x + 1 3 y 3 - 8 y 2 + 4 y - 2 The value of the largest exponent is called the degree of the polynomial. If a set of data contains n known points, then there exists exactly one polynomial of degree n-1 or smaller that passes through all of those points. The polynomial's graph can be thought of as 'filling in the curve' to account for data between the known points.
This methodology, known as polynomial interpolation, often (but not always) provides more accurate results than linear interpolation. The main problem with polynomial interpolation arises from the fact that even when a certain polynomial function passes through all known data points, the resulting graph might not reflect the actual state of affairs. It is possible that a polynomial function, although accurate at specific points, will differ wildly from the true values at some regions between those points. This problem most often arises when 'spikes' or 'dips' occur in a graph, reflecting unusual or unexpected events in a real-world situation. Such anomalies are not reflected in the simple polynomial function which, even though it might make perfect mathematical sense, cannot take into account the chaotic nature of events in the physical universe.
Comparison of linear and bilinear interpolation some 1- and 2-dimensional interpolations. Black and red/yellow/green/blue dots correspond to the interpolated point and neighbouring samples, respectively. Their heights above the ground correspond to their values. Accuracy If a function is insufficient, for example if the process that has produced the data points is known be smoother than C 0, it is common to replace linear interpolation with or, in some cases,.
Multivariate Linear interpolation as described here is for data points in one spatial dimension. For two spatial dimensions, the extension of linear interpolation is called, and in three dimensions,. Notice, though, that these interpolants are no longer of the spatial coordinates, rather products of linear functions; this is illustrated by the clearly non-linear example of in the figure below. Other extensions of linear interpolation can be applied to other kinds of such as triangular and tetrahedral meshes, including.
These may be defined as indeed higher-dimensional (see second figure below). A piecewise linear function in two dimensions (top) and the convex polytopes on which it is linear (bottom) History Linear interpolation has been used since antiquity for filling the gaps in tables, often with data. It is believed that it was used by and in (last three centuries BC), and by the and, (2nd century BC).
A description of linear interpolation can be found in the (2nd century AD). Programming language support Many libraries and have a 'lerp' helper-function, returning an interpolation between two inputs (v0, v1) for a parameter (t) in the closed unit interval 0, 1.