Interpolation Calculator
A value between the points you measured, by straight line and by the polynomial through all of them.
Results
What this tool does
A table of measurements only ever tells you about the points you measured, and the value you actually want is almost always between two of them. Linear interpolation draws a straight line between the neighbouring pair and reads off the answer — simple, stable, and what almost every engineering table expects you to do. Lagrange interpolation fits one polynomial through every point at once, which is exact for polynomial data and dangerously wobbly for anything else. This page gives both, and says plainly when your point is outside the range and the answer is really an extrapolation.
Formula
y = y₀ + (y₁ − y₀)(x − x₀) ÷ (x₁ − x₀) · L(x) = Σᵢ yᵢ Πⱼ≠ᵢ (x − xⱼ) ÷ (xᵢ − xⱼ)
Variables
| Symbol | Meaning | Unit |
|---|---|---|
x_values | The x values, one per line or separated by commas | — |
y_values | The y values, in the same order | — |
at | Value wanted at x = | — |
LN | By straight line between neighbours | — |
LG | By the polynomial through every point | — |
GP | Difference between the two | — |
IS | Is the point inside the data? | — |
TB | The points, sorted by x | — |
NP | Points | — |
DG | Degree of the polynomial | — |
LO | Smallest x in the data | — |
HI | Largest x in the data | — |
Worked example
- The x values, one per line or separated by commas0, 10, 20, 30
- The y values, in the same order0, 21, 44, 69
- Value wanted at x =15
- By straight line between neighbours32.5000000000
- By the polynomial through every point32.2500000000
- Difference between the two-0.2500000000
- Is the point inside the data?Yes
- The points, sorted by x 0 0 10 21 20 44 30 69
- Points4
- Degree of the polynomial3
- Smallest x in the data0.00000000
- Largest x in the data30.00000000
Limitations
- The result is an estimate based only on the values you type. Real situations often include factors this calculator does not know about.
Frequently asked questions
Which of the two answers should I use?
Almost always the linear one. It uses only the two points either side of where you are asking, so a bad point somewhere else in the table cannot affect it, and it can never produce a value outside the range of its two neighbours. Lagrange forces a single polynomial through every point at once, which is exact if your data really follows a polynomial and wildly unstable if it does not — with many points it develops large oscillations between them, which is known as Runge's phenomenon. Use Lagrange when you have few points and know the underlying shape; use linear for reading a table.
What if my point is outside the data?
The page says so, and still gives you a number by continuing the straight line from the nearest pair — but treat it with much more caution. That is extrapolation, not interpolation, and the two are different activities with different risks. Interpolating between measurements you trust is usually safe; continuing a line past the last measurement assumes the pattern holds where you have never looked, which is exactly the assumption that goes wrong.