Linear Interpolation Calculator

Enter two nodes (x₀, y₀), (x₁, y₁) and the query x. The calculator computes y on the line: y = y₀ + (x − x₀)/(x₁ − x₀)·(y₁ − y₀). With (0, 0), (10, 10) and x = 5 the result is y = 5. When x leaves the segment, the result is extrapolation along the same line. This is not a spline, not a regression, and not an inverse solve for x from y.

Inputs

Result

Enter x₀, y₀, x₁, y₁ and x.

Requires x₁ ≠ x₀. When the nodes share the same x, the calculator reports an error.

How it works

How y is computed for (0,0), (10,10) and x = 5
t0.5
y₀ + t·Δy0 + 0.5·10
y5

Linear interpolation (lerp) estimates a value y on the straight line between two known nodes (x₀, y₀) and (x₁, y₁). The classical numerical-analysis formula is y = y₀ + (x − x₀)/(x₁ − x₀) · (y₁ − y₀), with domain condition x₁ ≠ x₀. That is a textbook standard (e.g. Burden & Faires, Numerical Analysis; Wikipedia — Linear interpolation), not an invented index.

The calculator uses the numbers you enter: x₀, y₀, x₁, y₁ and the query x (field IDs a–e unchanged). With (0, 0), (10, 10) and x = 5 you get t = 0.5 and y = 5. With (1, 2), (3, 6) and x = 2 the result is 4. With (0, 0), (2, 10) and x = 1 the result is 5.

Parameter t and the weighted form. Let t = (x − x₀)/(x₁ − x₀). Then y = y₀ + t·(y₁ − y₀) and equivalently y = (1 − t)y₀ + t y₁. For x in the closed interval between x₀ and x₁, usually t ∈ [0, 1] and the point lies on the segment. When x leaves [x₀, x₁], |t| leaves [0, 1] — the algebra of the same line still runs, and the panel labels the result as extrapolation.

Derivation from similar triangles. On segment P₀P₁ the rises are Δx = x₁ − x₀ and Δy = y₁ − y₀. Similar triangles give (x − x₀)/Δx = (y − y₀)/Δy, so y − y₀ = t·Δy. The parametric form P(t) = (1 − t)P₀ + t P₁ yields the same point. Geometrically the result sits on the chord of a function — the line joining two nodes, not on an unknown curve f between them.

Error versus a true f. If the data come from a nonlinear curve, the chord is only an approximation. This calculator does not invent error bounds: without an assumption on f″ there is no trustworthy “error” number. Textbooks (Burden/Faires) discuss the interpolation remainder under extra hypotheses — here the result is only the value on the line through two points.

Domain. When x₀ = x₁ the denominator vanishes. The calculator reports an error instead of inventing a y (the old path that returned y₀ is gone). The neighbouring linear-function-value calculator computes y = ax + b from slope and intercept, not from two nodes.

The live diagram draws segment P₀P₁ and point P(x, y). That is the same geometry the formula computes — with no separate “visual” scale.

Formula

y = y₀ + (x − x₀)/(x₁ − x₀) · (y₁ − y₀), with x₁ ≠ x₀.

Parameter: t = (x − x₀)/(x₁ − x₀), so y = y₀ + t·(y₁ − y₀) = (1 − t)y₀ + t y₁. Slope: m = (y₁ − y₀)/(x₁ − x₀).

Mathematical model: linear interpolation / lerp. The calculator divides (x − x₀) by (x₁ − x₀) and scales the y rise in the browser.

Theory, derivation, and domain

Definition

Linear interpolation (lerp) evaluates y on the line through two nodes (x₀, y₀) and (x₁, y₁) at a given x. The formula is y = y₀ + ((x − x₀)/(x₁ − x₀)) · (y₁ − y₀), provided x₁ ≠ x₀. The parameter t = (x − x₀)/(x₁ − x₀) is the barycentric coordinate on the x-axis: y = (1 − t)·y₀ + t·y₁. When t ∈ [0, 1] the point lies on the segment; outside that interval one speaks of linear extrapolation.

It is a numerical standard in graphics (GLSL mix), in metrology for two-point calibration, and in numerical analysis (degree-1 Lagrange polynomial). NIST-oriented notes and approximation textbooks (Burden/Faires; Press et al., Numerical Recipes) treat linear interpolation as the simplest polynomial case.

In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.

Historical and conceptual context

Joining points by a straight line is ancient (Euclidean geometry); modern tabular interpolation (Newton, Lagrange) generalizes it to higher degrees. Lerp remains the default tool when data are sparse and local linearity is an acceptable model.

Conceptually the calculator does not smooth curves or compute splines. It also does not run least-squares regression through many points — only exactly two nodes and one query x. When x₀ = x₁ the chord is vertical and no finite slope exists in this model.

In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.

Formal properties

Input: five reals x₀, y₀, x₁, y₁, x with x₁ ≠ x₀. Output: y ∈ ℝ. The map x ↦ y is affine: y = y₀ + m(x − x₀) with m = (y₁ − y₀)/(x₁ − x₀).

Identities: at x = x₀ one has y = y₀; at x = x₁, y = y₁; y = (1 − t)y₀ + t y₁. The error relative to an unknown g ∈ C² on the interval is O((x₁ − x₀)²) in the classical Lagrange remainder estimate of degree 1.

Extrapolation (|t| > 1 or t < 0) uses the same formula; uncertainty grows outside the nodes.

In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.

Full derivation

Step 1. Seek a line y − y₀ = m(x − x₀). Passing through (x₁, y₁) forces m = (y₁ − y₀)/(x₁ − x₀).

Step 2. Substitution yields y = y₀ + ((x − x₀)/(x₁ − x₀))(y₁ − y₀).

Step 3 (weighted form). t = (x − x₀)/(x₁ − x₀) ⇒ y = (1 − t)y₀ + t y₁ — a convex combination when t ∈ [0, 1].

Step 4 (Lagrange). The polynomial l(x) = y₀·(x − x₁)/(x₀ − x₁) + y₁·(x − x₀)/(x₁ − x₀) is identically the same formula.

In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.

Special cases

Example: (0, 0), (10, 5), x = 4 → t = 0.4 → y = 2. Midpoint: x = (x₀ + x₁)/2 ⇒ y = (y₀ + y₁)/2. When y₀ = y₁ the result is the constant y₀ for every x.

When x₁ = x₀ the calculator reports an error (division by zero). When x lies outside [min(x₀,x₁), max(x₀,x₁)], the panel marks extrapolation.

In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.

Numerical and computational notes

In floating-point arithmetic, subtractions x − x₀ with nearly equal nodes lose digits; for typical inputs the formula is stable. Comma and period are equivalent. The calculator reports t, m, dx, dy and the weighted check (1 − t)y₀ + t y₁.

The calculator does not sort nodes — the order (x₀,y₀), (x₁,y₁) is as entered.

In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.

Related concepts and authorities

Related: percentage change (a different growth model), min–max range, square of a sum (algebraic geometry, not interpolation). Higher-degree polynomials need other tools.

Authorities: Numerical Recipes (Press et al.); Burden & Faires; MathWorld — Linear Interpolation; NIST interpolation notes. Educational tool.

In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.

How to use

  1. Enter x₀, y₀, x₁, y₁ and x, for example 0, 0, 10, 10 and 5.
  2. Click Calculate or wait for the live result. 0, 0, 10, 10 and 5 give y = 5.
  3. Check the panel: y, t, slope m, Δx, Δy, interpolation/extrapolation mode, and the diagram.
  4. 1, 2, 3, 6 and 2 give 4. 0, 0, 2, 10 and 1 give 5. 0, 0, 10, 10 and 15 give 15 (extrapolation).
  5. When x₀ = x₁, the calculator reports an error. y = ax + b lives on the neighbouring page.

Symbol glossary

y is the value on the line through two nodes. With (0,0), (10,10) and x = 5 you get y = 5. Parameter t and slope m appear in the result panel.

(x₀, y₀)
First node — fields a, b.
(x₁, y₁)
Second node — fields c, d; requires x₁ ≠ x₀.
x
Query abscissa — field e.
t
(x − x₀)/(x₁ − x₀). In [0, 1] on the segment; outside — extrapolation.
y
y₀ + t·(y₁ − y₀). Primary result on this calculator.
m
(y₁ − y₀)/(x₁ − x₀) — chord slope.

Examples

Example 1

  • (0, 0) and (10, 10)
  • x = 5

5

What is y at (0,0), (10,10) and x = 5? 5.

Example 2

  • (1, 2) and (3, 6)
  • x = 2

4

What is y at (1,2), (3,6) and x = 2? 4.

Example 3

  • (0, 0) and (2, 10)
  • x = 1

5

What is y at (0,0), (2,10) and x = 1? 5.

Example 4

  • (0, 0) and (10, 10)
  • x = 15

15

What is y at (0,0), (10,10) and x = 15? 15 (extrapolation).

Example 5

  • (0, 0) and (10, 10)
  • x = 2.5

2.5

What is y at (0,0), (10,10) and x = 2.5? 2.5.

Example 6

  • x₀ = x₁ = 5
  • y₀ = 7, y₁ = 9, x = 3

error

What if x₀ = x₁? Error — zero denominator.

Related calculators

Common questions

What is linear interpolation?

It is estimating y on the straight chord between two known nodes (x₀, y₀) and (x₁, y₁). The classical formula is y = y₀ + (x − x₀)/(x₁ − x₀)·(y₁ − y₀), provided x₁ ≠ x₀.

What is the lerp formula and what does t mean?

The parameter is t = (x − x₀)/(x₁ − x₀). Then y = y₀ + t·(y₁ − y₀), or equivalently y = (1 − t)y₀ + t y₁. For x in [x₀, x₁] usually t ∈ [0, 1]; outside that interval |t| leaves [0, 1] and the result is extrapolation.

What is y for (0,0) and (10,10) at x = 5?

The result is 5, because t = 5/10 = 0.5 and y = 0 + 0.5·10 = 5. That is the first example on this page and the same result after “Fill this example”.

What is y for (1,2) and (3,6) at x = 2?

The result is 4, because t = (2 − 1)/(3 − 1) = 0.5 and y = 2 + 0.5·4 = 4.

What is y for (0,0) and (2,10) at x = 1?

The result is 5, because t = 1/2 = 0.5 and y = 0 + 0.5·10 = 5.

What if x₀ = x₁?

The denominator (x₁ − x₀) is zero and the formula has no finite slope. The calculator reports an error and does not invent a y. Example: 5, 7, 5, 9 and x = 3 does not pass.

Is an x outside the segment [x₀, x₁] allowed?

Yes. The algebra of the same line does not stop the computation. With (0,0), (10,10) and x = 15 you get y = 15 and t = 1.5. The panel labels that as extrapolation — without a fake error bound versus an unknown curve f.

How is this different from y = ax + b?

Here you build the line from two nodes. The neighbouring linear-function-value calculator takes slope a and intercept b. Both models describe a line, but the input fields differ.

Where does the formula come from (similar triangles)?

On segment P₀P₁ the rises are Δx = x₁ − x₀ and Δy = y₁ − y₀. Similar triangles give (x − x₀)/Δx = (y − y₀)/Δy, so y − y₀ = t·Δy. The parametric form P(t) = (1 − t)P₀ + t P₁ yields the same y.

Does node order change the result at the same x?

No. Swapping (0,0) with (10,10) at x = 5 still gives y = 5, because t and the slope flip sign together.

Does a decimal comma or period work?

Yes. Enter 2.5 (US). With (0,0), (10,10) and x = 2.5 the result is 2.5. A comma decimal is also accepted by the parser.

Do the currency and unit settings in the page header affect the result?

No. The result depends only on the five coordinates. The currency and unit settings in the page header do not affect this result.

How do I calculate linear interpolation?

Enter two nodes and the query x. Compute t = (x − x₀)/(x₁ − x₀), then y = y₀ + t·(y₁ − y₀). With (0,0), (10,10) and x = 5: t = 0.5 and y = 5.

How does interpolation differ from extrapolation?

Interpolation means x lies between x₀ and x₁ (usually t ∈ [0, 1]). Extrapolation means x is outside the segment — same formula, but the panel flags the result as extrapolation because the line continues past the known nodes.

Does the calculator compute a spline or a polynomial through many points?

No. Only two nodes and one straight line (lerp). Multi-point fits, cubic splines, and regression are not on this page.

Can I find x for a known y?

Not as a built-in mode. This page solves for y from x. You can swap roles by hand (put the known axis in the x fields), but there is no inverse mode.

What is y at (0,0), (10,10) and x = 2.5?

2.5. t = 2.5/10 = 0.25 and y = 0 + 0.25·10 = 2.5. That is example 5 on this page.

The result is y = y₀ + (x − x₀)/(x₁ − x₀)·(y₁ − y₀): for (0,0), (10,10) and x = 5 it equals 5. Parameter t and interpolation/extrapolation mode are in the panel. The value from slope a and intercept b lives on the linear function value page.

Knowledge sources

The formula, domain, and derivation below come from recognized numerical-analysis sources.

  • Wikipedia — Linear interpolation
  • Wikipedia PL — Interpolacja
  • Burden, R. L.; Faires, J. D., Numerical Analysis — introduction to polynomial interpolation and the linear case.
  • Kincaid, D.; Cheney, W., Numerical Analysis: Mathematics of Scientific Computing — interpolation and remainder under assumptions on f.

Page Updated November 2, 2026.