You have data at 2010 and 2020. Asking what happened in 2015 is one kind of question. Asking what happens in 2035 is a completely different kind, even though you would use the same arithmetic for both.
The quick answer
Interpolation means estimating a value between two points you actually have. Extrapolation means estimating one beyond your last point.
Interpolation is usually reliable, because the real answer is trapped between two things you measured. Extrapolation has nothing holding it down, so its error can be any size at all.
Same arithmetic, different odds
A city recorded two population figures:
| Year | Population (millions) |
|---|---|
| 2010 | 3.20 |
| 2020 | 4.80 |
Growth over the decade was 4.80 − 3.20 = 1.60 million, so 0.16 million per year.
Estimating 2015. That is five years past 2010:
3.20 + 5 × 0.16 = 3.20 + 0.80 = 4.00 millionYou will not be exactly right. But you know the answer has to be somewhere between 3.20 and 4.80, because the city was measured at both ends. The population could not have jumped to 8 million in 2015 and come back down to 4.8 by 2020. Your only error is whatever curve the growth had inside that window, which for something changing this steadily is a few percent.
Estimating 2035. That is fifteen years past 2020:
4.80 + 15 × 0.16 = 4.80 + 2.40 = 7.20 millionNow nothing is holding the number down. You have assumed the 2010s growth rate keeps running for another fifteen years, through whatever happens to birth rates, migration rules, housing supply and the local economy. The arithmetic is identical to the line above it. How much you should trust the result is not.
Why error grows so fast once you leave the data
Think about the distances involved. When you are inside your data, you are close to points on both sides of you, and the errors they push in tend to partly cancel out. When you are outside, every data point is behind you, and they all push the same way. The further you go, the more they push.
With a straight line, that error grows in proportion to how far past the edge you go. With a curve fitted to several points, it grows much faster. Fit a cubic and go twice as far past the last point, and the error term grows by roughly sixteen times. Fit something higher order and you can be wrong by more than the entire range of your original data within one step past the edge.
That is the same effect behind Runge's phenomenon, where a polynomial swings wildly near the ends of the data.
Three questions before you trust an estimate
- Is your target between the smallest and largest x you have? If not, you are extrapolating, whatever you are calling it.
- Are the two points either side of you real measurements, or were they themselves estimated? Interpolating between interpolated values stacks error on top of error.
- Is the gap between those two points small compared to how fast the quantity changes? Filling a huge gap is technically interpolation and barely more trustworthy than a guess.
Your software will not warn you
Most tools handle out-of-range input silently, and each one does something different. NumPy's
np.interp returns the last known value and keeps returning it forever, so a chart of the output
shows a flat line that looks like a genuine plateau in the data. SciPy's interp1d raises an error
unless you explicitly ask for extrapolation, which is the better behaviour. Excel formulas built on MATCH
return #N/A below the table and #REF! above it, which is at least loud enough to notice.
None of these is wrong exactly, but you need to know which one you are using. The Excel guide covers how to trap the errors, and the Python guide covers how to make NumPy return a NaN instead of a plausible-looking flat line.
When extrapolating is fine
It is not automatically wrong. It is defensible when you have a reason that comes from outside the data.
- A physical law tells you the shape. If theory says pressure and volume are inversely related, extrapolating a bit past your measurements is fine, because the shape is not coming from your data points.
- You are going a short distance. Five percent past your last point with a straight line is usually safe. Twice as far as your entire data range is not.
- You only need a rough bound. Saying "at least 5 million by 2035" is a much weaker claim than "7.20 million" and much more likely to survive contact with reality.
What makes it indefensible is quoting an extrapolated number with the same confidence as an interpolated one. If you have to extrapolate, say so, and say what assumption the number depends on.
The mistake that keeps happening
Someone fits a high-order polynomial because it passes through every data point beautifully, then uses it one step past the last observation. Out there the polynomial owes your data nothing, and it typically shoots off toward plus or minus infinity within a short distance. The fit looked perfect right up until the moment it was used for the thing it was built for.
Forecasting almost never uses interpolating polynomials for this reason. It uses models with structure you can argue about: a trend plus a seasonal pattern, a growth curve that levels off, or something built from the underlying mechanism.
A workable habit: use interpolation to fill gaps, use a model to go past the end, and never let one formula quietly do both jobs. If you want to see how a fitted curve behaves near the edges of your own data, put the points into the interpolation calculator and look at what happens at the ends.