How to do linear interpolation
You know the coordinates <math>(x_0,y_0)</math> and <math>(x_1, y_1)</math>. You want to pick points on this line by knowing either an x or y in the interval <math>(x_0...x_1, y_0...y_1)</math>. For example you want to increase x by a constant factor from <math>x_0</math> up to <math>x_1</math> and get the corresponding y values. By inspecting the figure we see that:
By manipulating this algebraically, and writing
you get:
or if you prefer:
The same formula can easily be derived for x when y is known.
Linear Interpolation as Approximation
In numerical analysis a linear interpolation of certain points that are in reality values of some function <math>f</math> is typically used to approximate the function <math>f</math>. In this case the <math>y</math> in the formulas above is substituted for the linear interpolation polynomial of degree one, <math>p(x)</math> over the two known function values <math>f(x_0)</math> and <math>f(x_1)</math> thusly:
The truncation error of this approximation is defined as
and this error can for a function with 2 continuous derivatives be proven to be:
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. The proof for this error can be performed using Rolle's theorem.
Other Uses of Linear Interpolation
The basic linear interpolation operation is so commonly used in computer graphics that it is known as a lerp[?]. Lerp operations are built into the hardware of all modern computer graphics processors.
In more demanding approximation you will typically use polynomial interpolation see:
Linear interpolatiom can also be extended to Bilinear interpolation[?], for example to interpolate a function z(x, y) where z can be written in terms of an α factor for the xdirection and a β factor for the ydirection. Bilinear interpolation is often used as a crude antialiasing filter.
Search Encyclopedia

Featured Article
