ArticleslgStudy

science

Linear interpolation

Linear interpolation is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Linear interpolation rather than just read about it. In short: In mathematics, linear interpolation is a method of function approximation using linear polynomials to construct new data points within the range of a discrete set of known data points. In computer graphics it is common to linearly interpolate between an initial value ⁠v0⁠ and an ending value ⁠v1⁠ for a parameter ⁠t⁠ ranging from ⁠0⁠ to ⁠1⁠; this version is commonly abbreviated lerp: lerp⁡(v0,v1,t)=v0⋅(1−t)+v1⋅t Lin…

Linear interpolation — main illustration
Linear interpolation — illustration

Key takeaways

  • Linear interpolation belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Linear interpolation to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Linear interpolation from memory before moving on to harder problems.

Reference excerpt

In mathematics, linear interpolation is a method of function approximation using linear polynomials to construct new data points within the range of a discrete set of known data points. In computer graphics it is common to linearly interpolate between an initial value ⁠v0⁠ and an ending value ⁠v1⁠ for a parameter ⁠t⁠ ranging from ⁠0⁠ to ⁠1⁠; this version is commonly abbreviated lerp: lerp⁡(v0,v1,t)=v0⋅(1−t)+v1⋅t

Linear interpolation between two known points

If the two known points are given by the coordinates (x0,y0) and (x1,y1), the linear interpolant is the straight line between these points. For a value x in the interval (x0,x1), the value y along the straight line is given from the equation of slopes y−y0x−x0=y1−y0x1−x0, 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 y=y0+(x−x0)y1−y0x1−x0=y0(x1−x0)x1−x0+y1(x−x0)−y0(x−x0)x1−x0=y1x−y1x0−y0x+y0x0+y0x1−y0x0x1−x0=y0(x1−x)+y1(x−x0)x1−x0, which is the formula for linear interpolation in the interval (x0,x1). 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 1−(x−x0)/(x1−x0) and 1−(x1−x)/(x1−x0), which are normalized distances between the unknown point and each of the end points. Because these sum to 1, y=y0(1−x−x0x1−x0)+y1(1−x1−xx1−x0)=y0(1−x−x0x1−x0)+y1(x−x0x1−x0)=y0(x1−xx1−x0)+y1(x−x0x1−x0) yielding the formula for linear interpolation given above.

Interpolation of a data set Linear interpolation on a set of data points (x0, y0), (x1, y1), ..., (xn, yn) is defined as piecewise linear, resulting from the concatenation of linear segment interpolants between each pair of data points. This results in a continuous curve, with a discontinuous derivative (in general), thus of differentiability class C0.

Linear interpolation as an 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 RT=f(x)−p(x), where p denotes the linear interpolation polynomial defined above: p(x)=f(x0)+f(x1)−f(x0)x1−x0(x−x0). It can be proven using Rolle's theorem that if f has a continuous second derivative, then the error is bounded by |RT|≤(x1−x0)28maxx0≤x≤x1|f″(x)|. 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 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. 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 ancient Chinese mathematical text called The Nine Chapters on the Mathematical Art (九章算術), dated from 200 BC to AD 100 and 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 (from linear interpolation). 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

Accuracy 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 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 functions (see second figure below).

Programming language support Many libraries and shading languages have a "lerp" helper-function (in GLSL known instead as mix), 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 Bilinear interpolation Spline interpolation Polynomial interpolation de Casteljau's algorithm First-order hold Bézier curve

References

External links Equations of the Straight Line at cut-the-knot Well-behaved interpolation for numbers and pointers "Linear interpolation", Encyclopedia of Mathematics, EMS Press, 2001 [1994] "Finite-increments formula", Encyclopedia of Mathematics, EMS Press, 2001 [1994] Lerp smoothing is broken - a journey of decay and delta time

Illustrations

Linear interpolation: Given the two red points, the blue line is the linear interpolant between the points, and the value .mw-parser-output .texhtml{font-family:"Nimbus Roman No9 L","Times New Roman",Times,serif;font-size:118%;line-height:1;font-variant-numeric:lining-nums tabular-nums;font-kerning:none}.mw-parser-output .texhtml .texhtml{font-size:100%}.mw-parser-output .texhtml-big{font-size:165%}.mw-parser-output .mvar{font-style:italic}@media(min-width:420px){.mw-parser-output .texhtml{white-space:nowrap}}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 .mw-parser-output .texhtml{font-family:"Nimbus Roman No9 L","Times New Roman",Times,serif;font-size:118%;line-height:1;font-variant-numeric:lining-nums tabular-nums;font-kerning:none}.mw-parser-output .texhtml .texhtml{font-size:100%}.mw-parser-output .texhtml-big{font-size:165%}.mw-parser-output .mvar{font-style:italic}@media(min-width:420px){.mw-parser-output .texhtml{white-space:nowrap}}y at x may be found by linear interpolation.
Linear interpolation: In this geometric visualisation, the value at the green circle multiplied by the horizontal distance between the red and blue circles is equal to the sum of the value at the red circle multiplied by the horizontal distance between the green and blue circles, and the value at the blue circle multiplied by the horizontal distance between the green and red circles.
In this geometric visualisation, the value at the green circle multiplied by the horizontal distance between the red and blue circles is equal to the sum of the value at the red circle multiplied by the horizontal distance between the green and blue circles, and the value at the blue circle multiplied by the horizontal distance between the green and red circles.
Linear interpolation: 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: 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.
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.
Linear interpolation: Example of bilinear interpolation on the unit square with the z values 0, 1, 1, and 0.5 as indicated. Interpolated values in between are represented by colour.
Example of bilinear interpolation on the unit square with the z values 0, 1, 1, and 0.5 as indicated. Interpolated values in between are represented by colour.

Worked examples

Example 1 — a first encounter with Linear interpolation

Start with the simplest possible case. Write down what Linear interpolation claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Linear interpolation before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Linear interpolation ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Linear interpolation

In research
Linear interpolation appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Linear interpolation in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Linear interpolation is common in secondary-school and first-year university syllabi. It links to neighbouring topics Interpolation, so understanding it makes those chapters shorter.
In everyday life
Look for Linear interpolation outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Linear interpolation” →

How to study Linear interpolation in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Linear interpolation means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Linear interpolation out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Linear interpolation in simple terms?

In mathematics, linear interpolation is a method of function approximation using linear polynomials to construct new data points within the range of a discrete set of known data points. In computer graphics it is common to linearly interpolate between an initial value ⁠v0⁠ and an ending value ⁠v1⁠…

Why does Linear interpolation matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Linear interpolation?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Linear interpolation.

Tags

  • Interpolation

Keep exploring