What Is Linear Interpolation?
Linear interpolation is the process of determining a value that lies on a straight line between two established points. Suppose you measure a physical quantity at two distinct locations or times and want to estimate what happens in between. If the relationship follows a linear pattern, interpolation gives you that estimate.
Consider a practical example: a thermometer reads 15°C at 9 am and 21°C at 3 pm. Assuming steady temperature change, you can calculate the temperature at noon. This is interpolation—finding values within a tested range.
When you extend the line beyond the known range (predicting temperature at 8 pm, for instance), that operation is called extrapolation. Extrapolation carries greater uncertainty because you're assuming the linear trend continues unchanged outside your observed data.
The Linear Interpolation Equation
The core formula estimates an unknown y-coordinate given two reference points and an x-coordinate. Rearranging the slope formula yields:
y = (x − x₁) × (y₂ − y₁) / (x₂ − x₁) + y₁
slope (m) = (y₂ − y₁) / (x₂ − x₁)
intercept (b) = y₁ − m × x₁
x₁, y₁— Coordinates of the first known pointx₂, y₂— Coordinates of the second known pointx, y— Coordinates of the point you wish to findm— Slope of the line (rise over run)b— Y-intercept (where the line crosses the y-axis)
How to Apply the Interpolation Formula
To find a missing value, follow these steps:
- Identify your two known points. Record them as (x₁, y₁) and (x₂, y₂). Ensure x₁ ≠ x₂ to avoid division by zero.
- Choose the x-coordinate of your target point. Call it x. Verify it lies between x₁ and x₂ for true interpolation.
- Substitute into the formula. Calculate the difference quotients and apply the formula step-by-step.
- Interpret the result. Check whether the answer is reasonable—it should fall between y₁ and y₂.
Worked example: Given points (200, 15) and (300, 20), find y when x = 250.
y = (250 − 200) × (20 − 15) / (300 − 200) + 15
y = 50 × 5 / 100 + 15
y = 17.5
Common Pitfalls and Best Practices
Avoid these frequent mistakes when using linear interpolation:
- Verify the linearity assumption — Linear interpolation only works if the relationship between variables is truly linear. If your data follows a curved trend or has non-linear behaviour, the interpolated value will be inaccurate. Always plot your points mentally or visually to check.
- Watch your boundaries — Confirm that your target x-value falls strictly between x₁ and x₂. Going beyond this range switches from interpolation to extrapolation, which is less reliable. Extrapolated values should only be trusted if you have strong confidence the trend continues.
- Ensure x₁ ≠ x₂ — The formula requires division by (x₂ − x₁). If both points share the same x-coordinate, the slope is undefined and the calculation fails. Always use two distinct points on different positions along the x-axis.
- Round appropriately for context — Consider the precision of your original data when rounding results. Reporting 17.5 cookies makes sense; reporting 17.53847 cookies does not. Match significant figures to your measurement accuracy.
Interpolation vs. Extrapolation
Interpolation estimates values within the range of your data. It is generally reliable because you're working between observed points where the linear assumption is least likely to fail.
Extrapolation extends the line beyond your data range. It assumes the trend continues indefinitely, which often breaks down in real-world systems. Temperature might follow a linear pattern from 9 am to 3 pm, but that doesn't mean it continues rising at the same rate at midnight.
Whenever possible, gather actual data instead of extrapolating far from your measurements. If you must extrapolate, use it for short-range predictions only and acknowledge the increased uncertainty in your findings.