You know the value at one point and the value at another, and you need something in between. The whole job comes down to one question: how far across the gap are you? Work that out as a fraction, then apply the same fraction to the other pair of numbers.
The quick answer
Two steps.
1. t = (your x − first x) ÷ (second x − first x). This is how far across you are, as a decimal between 0 and 1.
2. answer = first y + t × (second y − first y). Move that same fraction up or down the y values.
Going from 45 to 78, 30 percent of the way: 45 + 0.3 × 33 = 54.9. Or use the calculator.
Doing it in two steps rather than one is worth the extra line, because t tells you immediately if something is wrong. It should always land between 0 and 1. If it comes out at 1.4, your target is past your second point, and you are guessing beyond your data rather than filling a gap. That is extrapolation, which is a different and riskier thing.
Example 1: a percentage of the way
What number is 30 percent of the way from 45 to 78?
You already have the fraction, so skip step 1. The distance from 45 to 78 is 33. Thirty percent of 33 is 9.9.
45 + 9.9 = 54.9Above 45, below 78, and much nearer 45. That fits 30 percent.
Example 2: reading between two table rows
A courier charges $18.40 for 5 kg and $26.00 for 10 kg. What does 7 kg cost?
How far across the weight range is 7 kg?
t = (7 − 5) ÷ (10 − 5) = 2 ÷ 5 = 0.4Now apply 0.4 to the price range. The price goes up by 26.00 − 18.40 = 7.60 across the gap:
18.40 + 0.4 × 7.60 = 18.40 + 3.04 = $21.44One warning about price tables specifically. Many rate cards are stepped rather than sliding, meaning anything from 5 kg up to 10 kg costs the same $18.40. If that is how the card works, 7 kg costs $18.40 and interpolating between the rows invents a price nobody charges. Check whether the number really slides before you smooth it.
Example 3: numbers that do not divide nicely
A sensor logged 21.4 °C at 10:07 and 23.0 °C at 10:52. What was it reading at 10:30?
First convert the times into plain numbers, otherwise the arithmetic gets confusing. Minutes past 10:00 gives you 7, 30 and 52.
t = (30 − 7) ÷ (52 − 7) = 23 ÷ 45 = 0.5111Temperature rose 1.6 degrees over the whole gap, so take 51.11 percent of that:
21.4 + 0.5111 × 1.6 = 21.4 + 0.8178 = 22.22 °CWorth noticing: 10:30 is a hair past the midpoint of that window, and the answer came out at 22.22 against a plain midpoint of 22.20. Slightly past halfway, slightly above the middle value. That sort of check catches a flipped sign before it costs you anything. Working in clock time instead of elapsed minutes is the usual way people get this one wrong.
Example 4: going the other way
Same sensor. When did it hit 22.5 °C?
Now you know the temperature and want the time, so work out the fraction from the temperature side:
t = (22.5 − 21.4) ÷ (23.0 − 21.4) = 1.1 ÷ 1.6 = 0.6875You are 68.75 percent of the way up the temperature range, so go 68.75 percent along the time range:
7 + 0.6875 × 45 = 7 + 30.94 = 37.94 minutes past 10:00So about 10:38. Check it by going forwards:
t = (37.94 − 7) ÷ 45 = 0.6876, and 21.4 + 0.6876 × 1.6 = 22.50 °CRound trip agrees, so the answer is right.
The blend version, if you prefer it
Once you have t, some people find this form quicker to do in their head:
answer = (1 − t) × first y + t × second yExample 1 becomes 0.7 × 45 + 0.3 × 78 = 31.5 + 23.4 = 54.9. Same answer. The two percentages always add up to 100, which is another built-in check.
This also explains the halfway case. At t = 0.5 you get half of each number, which is the plain average. Anyone who has averaged two numbers has already interpolated without calling it that.
Checks worth doing every time
- t between 0 and 1. If not, your target is outside the two points you picked.
- The answer sits between the two y values. With two points it always has to.
- The answer is on the correct side of the midpoint. If t is under 0.5, your answer should be nearer the first value. This catches swapped inputs.
When two points are not enough
Drawing a straight line between two points is exact only if the real relationship is straight. When the data curves, your error grows with the square of the gap, so halving the spacing between known points cuts the error to roughly a quarter.
If your table is coarse and the numbers clearly bend, bring in more points and use a cubic spline instead. For a whole table rather than a single pair, the Excel methods find the right two rows for you automatically. The full version of the two-point method, including the mistakes that produce wrong answers, is in the linear interpolation tutorial.