Linear Interpolation Calculator
Enter two known data points and the x-value you want to estimate. The calculator applies the linear interpolation formula to find the corresponding y-value, then shows you the slope, y-intercept, and the full line equation. A "show your work" panel traces every step, and a live chart plots the line so you can see exactly where your result falls. You can also reverse-solve: enter a known y to find the matching x.
Formula
Worked example
Two known points: (2, 4) and (8, 16). Slope m = (16 - 4) / (8 - 2) = 12 / 6 = 2. Intercept b = 4 - 2 x 2 = 0. Line: y = 2x. At x = 5: y = 2 x 5 = 10. Since 2 <= 5 <= 8, this is interpolation.
What is linear interpolation?
Linear interpolation estimates an unknown value that falls between two known data points by assuming the relationship between them is a straight line. If you know that a variable equals y1 at x1 and y2 at x2, you can proportionally position any x between those endpoints to read off the matching y. The technique is used everywhere from engineering lookup tables to financial modelling, computer graphics, and everyday cooking: if 200 g of flour makes 15 cookies and 300 g makes 20, you can estimate the yield for 250 g without measuring it directly.
The formula and how to use it
The linear interpolation formula is y = (x - x1) x (y2 - y1) / (x2 - x1) + y1. This is identical to writing the slope m = (y2 - y1) / (x2 - x1), the intercept b = y1 - m x x1, and evaluating y = mx + b at the target x. Enter x1, y1, x2, y2, and the x you want. The calculator returns y, plus the slope, intercept, and the full equation. Switch to reverse mode to solve for x given a known y: x = (y - b) / m.
Interpolation vs. extrapolation
If the target x lies between x1 and x2, the estimate is called interpolation and is well-supported by the data. If the target lies outside that range, it is extrapolation: the calculation is mathematically identical, but the accuracy depends on whether the linear trend holds beyond the measured range. A short extrapolation near the boundary is often reasonable; a long one can accumulate large errors if the true relationship curves or changes slope. The calculator flags which case applies to your inputs.
Common real-world applications
Linear interpolation appears throughout science and engineering. Thermodynamics tables list fluid properties at discrete temperatures, and engineers interpolate to get values at intermediate temperatures. Surveyors interpolate elevations between measured ground points. Financial analysts interpolate yield curves between quoted maturities. Animators blend object positions between keyframes. In data science it fills gaps in time-series when sensors miss readings. Whenever a table has gaps, linear interpolation is the first tool to reach for.
Interpolation vs. extrapolation at a glance
| Scenario | Target location | Typical accuracy | Notes |
|---|---|---|---|
| Interpolation | Inside [x1, x2] | High (if linear) | Supported by data; errors are small when the relationship is linear |
| Near-boundary extrapolation | Just outside [x1, x2] | Moderate | Small extrapolation; reasonable if the trend holds nearby |
| Far extrapolation | Far outside [x1, x2] | Low | Large uncertainty; nonlinear effects compound with distance |
Accuracy of linear estimation depends on where the target falls relative to the known data range.
Frequently asked questions
What is the linear interpolation formula?
The formula is y = (x - x1) x (y2 - y1) / (x2 - x1) + y1. You take the fractional position of x between x1 and x2, then scale that fraction by the total y-range (y2 - y1) and add y1. Equivalently, find the slope m = (y2 - y1) / (x2 - x1) and intercept b = y1 - m x x1, then evaluate y = mx + b at your target x.
What is the difference between interpolation and extrapolation?
Interpolation estimates a value whose x lies between the two known points (inside the data range). Extrapolation estimates a value whose x lies outside that range. The formula is the same, but extrapolation is riskier because you are assuming the linear trend continues beyond the measured data.
Can I solve for x instead of y?
Yes. Switch to "reverse solve" mode and enter a known y. The calculator rearranges the equation to x = (y - b) / m and returns the corresponding x. This works as long as the slope is not zero (a horizontal line has no unique x for a given y).
What if my two x-values are the same?
If x1 = x2, the slope is undefined (division by zero) and linear interpolation cannot be performed. You need two distinct x-values to define a line.
How accurate is linear interpolation?
Accuracy depends on how close the true relationship is to a straight line between your two points. For smoothly varying functions over a small interval the error is proportional to the second derivative and the square of the interval width. For interpolation between closely spaced points the error is usually small; for extrapolation or widely spaced points, or when the function curves significantly, you should use higher-order methods such as polynomial or spline interpolation.