Understanding the linear interpolation calculator — concept and principle
This calculator estimates a value between two known points by assuming a straight line between them. It gives the interpolated y, the slope, the position between the points and whether you are interpolating or extrapolating. Use it to read between the rows of tables, fill a gap in measurements or estimate values on a scale.
How it is calculated
y = y₁ + (x − x₁) × (y₂ − y₁) ÷ (x₂ − x₁)
Equivalently, with t = (x − x₁) ÷ (x₂ − x₁): y = (1 − t)·y₁ + t·y₂
- t between 0 and 1 means interpolation; outside that range it is extrapolation.
- Slope = (y₂ − y₁) ÷ (x₂ − x₁).
The principle
Over a short interval, many smooth quantities change almost in a straight line. Linear interpolation uses that line: the fraction of the way you are from x₁ to x₂ is the same fraction of the way from y₁ to y₂. Its error grows with the curvature of the true function and with the square of the interval width, which is why finely spaced tables interpolate accurately.
Worked example
Default inputs: (10, 50) and (20, 80); look up x = 14.
- Slope = (80 − 50) ÷ (20 − 10) = 3.
- Position t = (14 − 10) ÷ (20 − 10) = 0.4, inside the two points — interpolation.
- y = 50 + (14 − 10) × (80 − 50) ÷ (20 − 10) = 50 + 4 × 3 = 62.
| x to look up | Interpolated y |
|---|---|
| 3.5 | 30.5 |
| 7 | 41 |
| 10.5 | 51.5 |
| 14 | 62 |
| 17.5 | 72.5 |
| 21 | 83 |
| 28 | 104 |
How to read the result
x = 14 is 40 % of the way from 10 to 20, so y is 40 % of the way from 50 to 80. If the data curve between the points, the true value can be above or below 62; for strongly curved data, use more points or a higher-order method. Extrapolated values beyond the points are much less reliable.
Common mistakes
- Swapping x and y values in the formula.
- Using points that are far apart for a curved relationship.
- Extrapolating far outside the known range.
- Interpolating in a table across a jump, such as a tax bracket or phase change.
Frequently asked questions
What is the linear interpolation formula?
y = y₁ + (x − x₁)(y₂ − y₁) ÷ (x₂ − x₁).
What is the difference between interpolation and extrapolation?
Interpolation estimates inside the known range; extrapolation goes beyond it.
How accurate is linear interpolation?
Exact for straight lines; for curves the error grows with curvature and interval width.
Sources: NIST Digital Library of Mathematical Functions (DLMF), §3.3(ii) Linear Interpolation