Piecewise linear interpolation

Have a table with a missing value between observations? Enter its X–Y pairs. Add up to 25 points; the calculator will choose the relevant segment and explain the result.

First, what do X and Y mean?

X is the known or controlled quantity (such as temperature) and Y is the quantity measured at that X (such as a physical property). Each row is one complete observation: an X value and its corresponding Y.

What do you want to calculate?

Your known points (X–Y table)

If you forgot a point, you do not have to re-enter the table. Add it at the end, insert it before any row, or sort rows by X without losing values. Calculations always use points ordered by X. Duplicate X values are not allowed.

Examples to understand special cases

Try a Y reached in two different places, or a flat line that gives infinitely many answers.

Paste data from Excel or another table (optional)

One row per line and two columns, separated by tab or a semicolon (;). Decimal commas are supported. Example: 10;200. This replaces the current table.

What value do you need?

Use a target inside the known range for interpolation. Outside the X interval you are extrapolating; in inverse mode, non-monotonic tables can have several answers.

X and Y units (optional)

Results and the chart update as you edit. Negative numbers and decimal commas or periods are accepted.

How to interpolate data from a table step by step

Enter a table of 2 to 25 pairs of X and Y values for piecewise linear interpolation. The calculator automatically selects the two points around your requested X, explains the calculation and plots the full data series. You can also solve for X given a Y and see multiple solutions when the data are not monotonic. Extrapolation is clearly flagged and flat segments are handled without pretending there is a unique inverse solution.

Example: (10, 200), (20, 260), (30, 290). At X = 14, use the first segment: t = (14 − 10)/(20 − 10) = 0.4; Y = 200 + 0.4 × (260 − 200) = 224.

Results are estimates and depend on the supplied values.

Learn linear interpolation from scratch

1. What is interpolation for?

Imagine a table with a measurement at 10 °C and 20 °C, but you need an estimate at 14 °C. You did not actually measure 14 °C. Linear interpolation estimates the missing value by assuming a straight-line change between nearby observations.

10 → 200 · 20 → 260 · 14 → ?

2. Learn to read two reference points

Each (X,Y) pair contains related numbers. If X is temperature and Y is a measurement, (10,200) means the measurement is 200 at 10 °C. Find the row below and above your target X. Here they are (10,200) and (20,260). Other rows are not used for this one segment.

A = (x₁,y₁) and B = (x₂,y₂)

3. How far along the segment are you?

Calculate the fraction of the X interval reached by the target. From 10 to 20, a target of 14 is 4 units along a 10-unit interval: 40% of the way.

t = (14 − 10) ÷ (20 − 10) = 0.4

4. Apply the same fraction to the Y change

Y changes by 60 between the known points. Because you travelled 40% of the X interval, add 40% of 60 to the starting Y of 200. This gives 224.

Y = 200 + 0.4 × (260 − 200) = 224

5. What if you have many points?

With three, five or more rows, the calculator sorts the points by X. To estimate Y at X=25, it uses the two points surrounding 25, for example X=20 and X=30. This creates a piecewise-linear function: each segment can have a different slope, so the line may change direction.

y = yᵢ + [(x − xᵢ)/(xᵢ₊₁ − xᵢ)] × (yᵢ₊₁ − yᵢ)

6. Reverse mode: given Y, find X

You can also start from a known Y. The calculator checks every segment for matching X values. A line that rises and then falls can have two answers. If a flat segment is at the requested Y, every X in that interval is a solution.

x = xᵢ + [(y − yᵢ)/(yᵢ₊₁ − yᵢ)] × (xᵢ₊₁ − xᵢ), when yᵢ₊₁ ≠ yᵢ

7. Interpolation versus extrapolation

Interpolation estimates between known observations. Extrapolation extends a straight line beyond them. The calculator extrapolates Y outside the X range using the nearest end segment. In reverse mode it avoids extrapolating multi-point tables, where the answer can be ambiguous.

Interpolation: X between smallest and largest known X. Extrapolation: X outside that range.

8. When is this method not a good fit?

If data are noisy, have abrupt jumps or clearly follow a curved pattern, straight segments may not represent the underlying process. Interpolation is not regression: interpolation passes through the input points, while regression fits an approximate trend to variable observations.

Do not confuse piecewise linear interpolation with linear regression, polynomials or splines.
Mathematical scope and limits

Use 2 to 25 points, with no duplicate X coordinates. Points are sorted by X and joined by a straight segment between each pair of neighbours. This does not measure uncertainty or perform regression. It may be unsuitable for jumps, discontinuities or noisy experimental data. Calculations use floating-point arithmetic; rounding is applied for display only.

Mathematical basis and sources

The formula follows from the straight line through two points, applied independently on each interval. NumPy and SciPy document piecewise-linear interpolation as distinct from smooth interpolating curves and statistical regression.

NumPy — 1-D linear interpolation · SciPy — Interpolation tutorial

Frequently asked questions

What is linear interpolation in simple words?

It is a way to estimate a missing value between two observations by assuming a uniform change between them.

How do I interpolate data in a table with many values?

Enter each X–Y pair as a row. The calculator sorts the table, finds the two points around your target X and uses only that segment.

What happens if my points are not ordered?

They are sorted automatically by X. The X values must be distinct.

Why can reverse mode give several X values?

Because the same Y level may be reached while the graph rises and falls. Every crossing within the known segments is shown.

What happens with a flat segment when finding X?

If both ends share the target Y, every X in that segment matches. The solution is a whole interval rather than a unique number.

Can I extrapolate?

Yes, when you seek Y for an X outside the table, or when using only two non-flat points in inverse mode. For multi-point tables, inverse extrapolation is not automatic.

Is this the same as the rule of three?

With two points and a linear relationship, the arithmetic is related, but interpolation can handle nonzero intercepts and multiple segments in a table.

Is interpolation the same as linear regression?

No. Interpolation connects the known data; regression estimates an overall trend that need not pass through every observation.

Can I paste data from Excel?

Yes. Copy two columns with no header, one row per line, separated by tabs or semicolons. Decimal commas work too.

Related calculators

Rule of three · Compound proportion