Linear Interpolation

by admin in , , , on April 27, 2019

This code conduct an Interpolation for a given set of points using Linear Interpolation method that uses linear polynomials, to construct new data points within the range of a discrete set of known data points.

Code Outputs:

  • Printed Table of Interpolated Values
  • Chart Compare of Interpolated Values with Given Points.

   Xi      F(Xi)
1           11
12         21
19         41
26        32
34        55

Input Requirements:

  • X Axis Points
  • Y Axis Points

About the Method:

linear interpolation is a method of curve fitting using linear polynomials to construct new data points within the range of a discrete set of known data points.

Linear Interpolation Between Two Known Points

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.

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, x0), the value y along the straight line is given from the equation of slopes

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

which is the formula for linear interpolation in the interval (x0, x0). 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 (x – x0) / (x1 – x0) and (x1 – x) / (x1 – x0), which are normalized distances between the unknown point and each of the end points. Because these sum to 1,

which yields the formula for linear interpolation given above.

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 (x0y0), (x1y1), …, (xnyn) is defined as the concatenation of linear 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 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 a continuous second derivative, then the error is bounded by

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.

 

References:

[1] Meijering, Erik (2002), ‘A chronology of interpolation: from ancient astronomy to modern signal and image processing’, Proceedings of the IEEE90 (3): 319–342, doi:10.1109/5.993400.

0 Sale

Share Now!

Release Information

  • Price
    :

    $2.99

  • Released
    :

    April 27, 2019

  • Last Updated
    :

    May 29, 2019

Share Your Valuable Opinions