Skip to the calculator
Rule Calculator

Interpolation Calculator

With first x 10, y at that x 25, second x 20, y at that x 45 and 1 more field, interpolation comes to 33.000000 — interpolated y. It is reached in 6 steps, the last of which is 25 + 0.4 * 20, and each one is printed on the page with its numbers filled in. The formula is the one published by NIST Digital Library of Mathematical Functions, not an approximation fitted to it.

The value between two known points on a straight line, with the slope it assumes and a warning when the target sits outside them.

Formula and sources checked · How we check

First x 10, y at that x 25, Second x 20, y at that x 45

33.000000

Interpolated y for the example below. Editing a field recomputes the calculator below; this figure holds the answer the page was loaded with.

It is written into the HTML rather than drawn by a script, so a search engine reading this page without running JavaScript still finds an answer.

Interpolated y
33.000000
Distance between the known x values
20 - 1010
Distance between the known y values
45 - 2520
Slope of the line through them
20 / 102
How far along x sits
(14 - 10) / 100.4
Interpolated y
25 + 0.4 * 2033
How far past the endpoints, as a share of the gap
(0)0

Ask about this in the chat

Worked example

Between (10, 25) and (20, 45) the slope is 2 per unit. x = 14 is four tenths of the way across, so y is 25 + 0.4 × 20 = 33. The "how far along" figure is the one to watch: below 0 or above 1 and this is extrapolation, which the arithmetic performs happily and the data does not support.

How to work it out yourself

  1. 1.Take the two points that bracket the value you want.
  2. 2.Slope is the rise over the run between them.
  3. 3.Work out how far along the gap your x sits, as a fraction from 0 to 1.
  4. 4.Add that fraction of the rise to the first y. Outside 0 to 1 the same sum is extrapolation, and stops being supported by the two points.

The formula

  1. Distance between the known x values20 - 10
  2. Distance between the known y values45 - 25
  3. Slope of the line through them20 / 10
  4. How far along x sits(14 - 10) / 10
  5. Interpolated y25 + 0.4 * 20
  6. How far past the endpoints, as a share of the gap(0)

Source: NIST Digital Library of Mathematical Functions — interpolation, NIST/SEMATECH e-Handbook of Statistical Methods

Questions people actually ask

What is linear interpolation?
Reading a value between two known points by assuming a straight line joins them. y = y₁ + (x − x₁)(y₂ − y₁)/(x₂ − x₁). It is what you do by eye on a printed table, written down.
When is interpolating between table rows safe?
When the underlying relationship is close to straight over that interval, and the rows are close enough together that the curvature between them is small. A steam table or a t table interpolates well; a compound-interest table interpolates badly, because the curve bends most where the rows are widest.
What is the difference between interpolation and extrapolation?
Whether the target sits between the two known points or outside them. Between, you are constrained by data on both sides. Outside, the only thing holding the answer up is the assumption that the line continues — and nothing in the two points supports that. The figure above tells you which one you just did.
How wrong can linear interpolation be?
For a smooth curve the error is roughly one eighth of the second derivative times the square of the gap. In practice: halving the spacing between rows quarters the error. That is why a table with a fine step interpolates far better than a coarse one, not merely a bit better.

Related

Put this calculator on your site

Free, no attribution required beyond the link.

<iframe src="https://rulecalculators.com/embed/linear-interpolation" width="100%" height="420" style="border:1px solid #e7e4de;border-radius:12px" title="Interpolation Calculator"></iframe>
Did this answer your question?