Linear interpolation

From Wikipedia, the free encyclopedia

(Redirected from Lerp (computing))
Jump to: navigation, search

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).

Contents

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.
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 \scriptstyle(x_0,y_0) and \scriptstyle(x_1,y_1), the linear interpolant is the straight line between these points. For a value x in the interval \scriptstyle(x_0, x_1), the value y along the straight line is given from the equation

\frac{y - y_0}{y_1 - y_0} = \frac{x - x_0}{x_1 - x_0}

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

Solving this equation for y, which is the unknown value at x, gives

y = y_0 + (x-x_0)\frac{y_1 - y_0}{x_1-x_0}

which is the formula for linear interpolation in the interval \scriptstyle(x_0,x_1). Outside this interval, the formula is identical to linear extrapolation.

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

Linear interpolation on a set of data points \scriptstyle(x_0, y_0),\, (x_1, y_1),\,\dots,\,(x_n, y_n) 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 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

R_T = f(x) - p(x) \,\!

where p denotes the linear interpolation polynomial defined above

p(x) = f(x_0) + \frac{f(x_1)-f(x_0)}{x_1-x_0}(x-x_0). \,\!

It can be proven using Rolle's theorem that if f has two continuous derivatives, the error is bounded by

|R_T| \leq \frac{(x_1-x_0)^2}{8} \max_{x_0 \leq x \leq x_1} |f''(x)|. \,\!

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.

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.

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.

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.

Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.