What Is Linear Interpolation?
Linear interpolation is a method of estimating an unknown value that falls between two known data points. It assumes the relationship between the points is a straight line, so the unknown value lies proportionally along that line. It is one of the most widely used techniques in engineering, statistics, finance, computer graphics, and science whenever you have a table of values and need a reading "in between."
How to Use This Calculator
Enter the coordinates of your two known points: \((x_1, y_1)\) and \((x_2, y_2)\). Then enter the x value at which you want to estimate y. The calculator returns the interpolated y value along with the slope of the line connecting your two points. The x value can lie between your points (interpolation) or outside them (extrapolation) — the same straight-line formula applies either way.
The Formula Explained
The equation is $$y = y_1 + \left(x - x_1\right) \cdot \frac{y_2 - y_1}{x_2 - x_1}$$ The fraction \(\frac{y_2 - y_1}{x_2 - x_1}\) is the slope — the change in y per unit change in x. Multiplying the slope by the horizontal distance \((x - x_1)\) gives the rise from \(y_1\) to the target point. Adding it to \(y_1\) gives the interpolated value. Note that \(x_1\) and \(x_2\) must differ, otherwise the slope is undefined (division by zero).
Worked Example
Suppose you know that at \(x_1 = 10\) the value is \(y_1 = 20\), and at \(x_2 = 20\) the value is \(y_2 = 40\). What is y when \(x = 15\)? The slope is $$\frac{40 - 20}{20 - 10} = 2$$ Then $$y = 20 + (15 - 10) \times 2 = 20 + 10 = 30$$ The interpolated value is 30.
FAQ
Can I extrapolate beyond my points? Yes. If x is smaller than \(x_1\) or larger than \(x_2\), the formula extends the straight line outward. Be cautious — extrapolation assumes the linear trend continues.
Does the order of the points matter? No. You can swap \((x_1, y_1)\) and \((x_2, y_2)\) and get the same result, as long as each x is paired with its correct y.
What if x₁ equals x₂? The slope becomes undefined (you cannot divide by zero), so a vertical line cannot be interpolated. The calculator returns 0 in that case — adjust your inputs so \(x_1 \neq x_2\).