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.
- Printed Table of Interpolated Values
- Chart Compare of Interpolated Values with Given Points.
- 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
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 set of data points (x0, y0), (x1, y1), …, (xn, yn) 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.
 Meijering, Erik (2002), ‘A chronology of interpolation: from ancient astronomy to modern signal and image processing’, Proceedings of the IEEE, 90 (3): 319–342, doi:10.1109/5.993400.