Linear interpolation

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Jitse Niesen (talk | contribs) at 11:20, 22 November 2007 (Reverted edits by 210.185.87.146 (talk) to last version by 84.90.98.100). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Linear interpolation is a method of curve fitting using linear polynomials. It is heavily employed in mathematics (particularly numerical analysis), and numerous applications including computer graphics. It is a simple form of interpolation.

Lerp is a quasi-acronym for linear interpolation, which can also be used as a verb (Raymond 2003).

Linear interpolation between two known points

Given the two red points, the blue line is the linear interpolant between the points, and the value y at x may be found by linear 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

which can be derived geometrically from the figure on the right.

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.

Interpolation of a data set

Linear interpolation on a data set (red points) consists of pieces of linear interpolants (blue lines).

Linear interpolation on a set of data points is defined as the concatenation of linear interpolants between each pair of data points. This results in a continuous curve, with a discontinuous derivative.

Linear interpolation as approximation

Linear interpolation is often used to approximate a value of some function f 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 two continuous derivatives, the error is bounded by

As you see, 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 is the approximations made with simple linear interpolation.

Applications

Linear interpolation is often used to fill the gaps in a table. Suppose you have a table listing the population of some country in 1970, 1980, 1990 and 2000, and that you want to estimate the population in 1994. Linear interpolation gives you an easy way to do this.

The basic operation of linear interpolation between two values is so commonly used in computer graphics that it is sometimes called a lerp in that field's jargon. 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 two 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.

History

Linear interpolation has been used since antiquity for filling the gaps in tables, often with astronomical data. It is believed that it was used in the Seleucid Empire (last three centuries BC) and by the Greek astronomer and mathematician Hipparchus (second century BC). A description of linear interpolation can be found in the Almagest (second century AD) of Ptolemy.

Extensions

In demanding situations, linear interpolation is often not accurate enough. In that case, it can be replaced by polynomial interpolation or spline interpolation.

Linear interpolation can also be extended to bilinear interpolation for interpolating functions of two variables. Bilinear interpolation is often used as a crude anti-aliasing filter. Similarly, trilinear interpolation is used to interpolate functions of three variables. Other extensions of linear interpolation can be applied to other kinds of mesh such as triangular and tetrahedral meshes.

References

  • Raymond, Eric (2003), "LERP", Jargon File (version 4.4.7).
  • E. Meijering (2002). A Chronology of Interpolation. From Ancient Astronomy to Modern Signal and Image Processing. Proceedings of the IEEE 9 (3), 319–342.

See also

External links