The problem
Tables list values at fixed steps, and charts show a finite number of points or a drawn curve. The value you want often falls between two of them. Linear interpolation gives an estimate by assuming the quantity changes along a straight line between the two nearest known points.
The idea: a fraction of the way
Suppose you know two points, (x₀, y₀) and (x₁, y₁), and want y at an x between them. First work out how far x is along the gap, as a fraction:
fraction = (x − x₀) / (x₁ − x₀)
Then move that same fraction of the way from y₀ to y₁:
y = y₀ + fraction × (y₁ − y₀)
That is the whole method. If x is halfway between x₀ and x₁, y is halfway between y₀ and y₁.
Worked example
These numbers are made up to keep the arithmetic clear. A table lists a quantity at two temperatures:
| Temperature (°C) | Value |
|---|---|
| 20 | 50 |
| 30 | 80 |
You want the value at 24 °C.
- Fraction along the gap = (24 − 20) / (30 − 20) = 4 / 10 = 0.4.
- Change in value over the gap = 80 − 50 = 30.
- Value at 24 °C = 50 + 0.4 × 30 = 50 + 12 = 62.
Check: the table rises by 30 over 10 degrees, which is 3 per degree. Four degrees above 20 gives 50 + 4 × 3 = 62. Both routes agree.
A second example with decimals
Another invented table gives 2.5 at x = 100 and 4.0 at x = 200. Find the value at x = 130.
- Fraction = (130 − 100) / (200 − 100) = 30 / 100 = 0.3.
- Change over the gap = 4.0 − 2.5 = 1.5.
- Value = 2.5 + 0.3 × 1.5 = 2.5 + 0.45 = 2.95.
Sense check: 130 is closer to 100 than to 200, so the answer should be closer to 2.5 than to 4.0. It is. Quick checks like this are good sanity checks.
Working backwards
You can also interpolate in reverse, to find x for a given y. Using the second table, find x where the value is 3.4.
- Fraction = (3.4 − 2.5) / (4.0 − 2.5) = 0.9 / 1.5 = 0.6.
- x = 100 + 0.6 × (200 − 100) = 160.
Check by going forward: at x = 160 the fraction is 0.6, giving 2.5 + 0.6 × 1.5 = 3.4. It matches.
Reverse lookups work cleanly only if the values are steadily rising or falling in that range. If the table goes up and then down, one y value can belong to two x values.
Interpolation on a chart
On a printed chart, the same idea applies. Read the two nearest labelled points, or the two grid lines either side, then estimate the position proportionally. When reading a graph by eye, your accuracy is limited by how well you can read the scale, so quote only as many digits as the chart justifies. Datasheet graphs are a common case, where a curve shows behaviour at a few temperatures and you need a value at another.
When a straight line is a poor model
Linear interpolation assumes a straight line, and many real relationships curve. The estimate is then slightly off, and the error grows with the size of the gap and with the amount of curvature.
A simple demonstration: take y = x² with known points at x = 2 (y = 4) and x = 4 (y = 16). Interpolating at x = 3 gives the halfway value, (4 + 16) / 2 = 10. The true value is 3² = 9. The estimate is 1 too high, about 11% of the true value.
For a curve that bends upward like this one, straight-line estimates will sit above the curve between the points. For a curve that bends downward, they sit below. Closer table entries reduce the error. If the entries are far apart or the curve is steep, consider fitting a better model, using more points, or asking the source for finer data.
Cautions
- Stay between the points. Using the same formula outside the range is extrapolation, which is much less reliable.
- Never interpolate across a jump. Some quantities change abruptly, such as a switching threshold or a material phase change. A straight line through a step gives nonsense.
- Check the scale. If the table is logarithmic in one axis, as with the decibel scale or some frequency tables, interpolate on the logarithm of the variable instead, or accept a larger error.
- Mind the precision. The result cannot be more accurate than the table values, so keep sensible significant figures.
- Treat worst-case data carefully. Interpolating between typical and maximum columns blends different kinds of numbers. See typical versus worst-case values before mixing them.
Spreadsheet functions and software lookups can interpolate for you, and engineering spreadsheets often include it, but doing it once by hand shows what they are doing. These examples use illustrative numbers. For safety-critical or regulated work, use the methods and data that your standards and a qualified engineer require.