How this linear interpolation calculator works
Linear interpolation estimates an unknown value between two known data points by assuming the relationship between them is a straight line. Given two points (x₁, y₁) and (x₂, y₂), the value at any target x is y = y₁ + (x − x₁)·(y₂ − y₁) / (x₂ − x₁). The term (x − x₁)/(x₂ − x₁) is the interpolation fraction: it equals 0 at the first point, 1 at the second point, and slides smoothly in between.
This calculator works both ways. Enter a target x and it finds the matching y. Enter a target y instead and it performs inverse interpolation, rearranging to x = x₁ + (y − y₁)·(x₂ − x₁) / (y₂ − y₁). If your target lies outside the interval between the two known points, the result is an extrapolation — still computed with the same line, but flagged because the trend may not hold beyond your data.
Reference note: when x₁ = x₂ the slope is undefined (a vertical line) and y cannot be interpolated; when y₁ = y₂ the line is flat and you cannot solve for a single x from a target y. Extrapolation reuses the same formula but is less reliable the further the target sits beyond the known range.
Interpolation fraction reference
| Target position | Fraction (x − x₁)/(x₂ − x₁) | Interpretation |
|---|---|---|
| At x₁ | 0 | Returns y₁ exactly |
| Midway between | 0.5 | Average of y₁ and y₂ |
| At x₂ | 1 | Returns y₂ exactly |
| Before x₁ or after x₂ | < 0 or > 1 | Extrapolation (flagged) |
Frequently asked questions
- What is linear interpolation?
- Linear interpolation estimates an unknown value between two known data points by assuming the change between them follows a straight line. You read off the value at the position you care about, giving an estimate that lies proportionally between the two known values.
- What is the linear interpolation formula?
- The formula is y = y₁ + (x − x₁)·(y₂ − y₁)/(x₂ − x₁), where (x₁, y₁) and (x₂, y₂) are the known points and x is the target. The fraction (x − x₁)/(x₂ − x₁) measures how far x sits between x₁ and x₂, from 0 to 1.
- What is the difference between interpolation and extrapolation?
- Interpolation estimates a value inside the range of your known points, when the target lies between x₁ and x₂. Extrapolation estimates a value outside that range. Both use the same straight-line formula, but extrapolation is less reliable because it assumes the trend continues beyond your data.
- How do I interpolate between two values?
- Find the fraction of the way your target x is between the points: (x − x₁)/(x₂ − x₁). Multiply it by the change in y (y₂ − y₁) and add to y₁. For (10, 100) and (20, 200) at x = 15, the fraction is 0.5, so y = 100 + 0.5·100 = 150.
- When is linear interpolation accurate?
- It is accurate when the underlying relationship is close to a straight line over the interval and the two known points are reasonably close together. It is less accurate for curved data, wide gaps, or when extrapolating beyond the known points.
- Can I solve for x instead of y?
- Yes. To find the x for a target y, rearrange to x = x₁ + (y − y₁)·(x₂ − x₁)/(y₂ − y₁). This inverse interpolation needs y₁ and y₂ to differ; if y₁ = y₂ the line is flat and no single x matches. This calculator solves whichever target you fill in.