Linear interpolation calculator

Type (x₁, y₁), (x₂, y₂) and x. Linear interpolation places y on the segment between those points. 0, 0, 10, 10 and 5 give 5. 1, 2, 3, 6 and 2 give 4.

When x₁ = x₂ the calculator returns y₁; it does not divide by zero. This is not y from a separately typed ax + b.

Input data

Results

Enter data and click Calculate.

How it works

Linear interpolation looks for y on the segment between (x₁, y₁) and (x₂, y₂). The formula is y₁ + (x − x₁) · (y₂ − y₁)/(x₂ − x₁). With 0, 0, 10, 10 and x = 5 you sit at the midpoint and y = 5.

The fields are x1, y1, x2, y2 and x. 1, 2, 3, 6 and 2: from (1, 2) to (3, 6), x = 2 is halfway, y = 4. 0, 0, 2, 10 and 1 give 5, because half of the rise of 10.

When x1 = x2 the denominator is zero. The implementation returns y1. 5, 7, 5, 9 and 3 give 7, not Infinity. A vertical segment has no slope in this code.

Linear function value is on the neighbouring page when you know a and b, not two points. Here you build the line from the nodes.

The header units switch does not multiply anything. 0, 0, 10, 10 and 5 stay 5 whatever the label says.

0, 0, 10, 10 and 5 give 5. 1, 2, 3, 6 and 2 give 4. 0, 0, 2, 10 and 1 give 5. When x1 = x2 you keep y1.

Formula

y = y₁ + (x − x₁) · (y₂ − y₁)/(x₂ − x₁), when x₂ ≠ x₁; otherwise y₁

How to use

  1. Type x1, y1, x2, y2 and x, for example 0, 0, 10, 10 and 5.
  2. Click Calculate. y comes out 5.
  3. 1, 2, 3, 6 and 2 give 4. 0, 0, 2, 10 and 1 give 5.
  4. When x1 = x2, the calculator returns y1, not Infinity.
  5. y = ax + b from a slope lives on linear function value.

0, 0, 10, 10 and 5 give 5

Linear interpolation places y on the segment. 0, 0, 10, 10 and 5 give 5. 1, 2, 3, 6 and 2 give 4. When x1 = x2 you keep y1.

interpolation
y between two points. 0, 0, 10, 10 and 5 give 5.
Linear
A segment, not a curve. 1, 2, 3, 6 and 2 give 4. The rise is constant.
segment
From (x1, y1) to (x2, y2). When x1 = x2 the calculator returns y1 instead of dividing.

Examples

Example 1

  • x1 = 0
  • y1 = 0
  • x2 = 10
  • y2 = 10
  • x = 5

5

What is y between (0, 0) and (10, 10) at x = 5? 5. Midpoint of the segment.

Example 2

  • x1 = 1
  • y1 = 2
  • x2 = 3
  • y2 = 6
  • x = 2

4

What is y between (1, 2) and (3, 6) at x = 2? 4. Half of the rise of 4.

Example 3

  • x1 = 0
  • y1 = 0
  • x2 = 2
  • y2 = 10
  • x = 1

5

What is y between (0, 0) and (2, 10) at x = 1? 5. Half of the rise of 10.

Related calculators

Common questions

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

5. Midpoint of the segment, half of the rise.

What does linear interpolation mean?

y on the segment between two points. Formula y₁ + (x − x₁)(y₂ − y₁)/(x₂ − x₁).

What about (1, 2) and (3, 6) at x = 2?

4. x is halfway, y rises by 2 from 2 to 6.

What about (0, 0) and (2, 10) at x = 1?

5. Half of the rise of 10.

What if x1 = x2?

The calculator returns y1. It does not divide by zero. 5, 7, 5, 9 and 3 give 7.

Does an x outside the segment pass?

Yes. The algebra does not stop extrapolation. 0, 0, 10, 10 and 15 give 15.

How is this different from y = ax + b?

Here two points. There slope and intercept. Neighbouring cards.

Which field is the unknown x?

The fifth. The first four are the nodes (x1, y1) and (x2, y2).

Does node order change the result?

Not at the same x. (0, 0) and (10, 10) or the swap both give 5 at the midpoint.

Does a comma in 2.5 work?

Yes. 0, 0, 10, 10 and 2.5 give 2.5.

Knowledge sources

The calculator computes the same formula as the definition below.

Page updated in 2026.