# What is the linear interpolation at x?

Finds y at x on the straight line through two points, y = y₁ + (x − x₁)(y₂ − y₁) ÷ (x₂ − x₁), with the slope and every step.

- Page: https://www.acalculator.org/math/linear-interpolation-calculator
- JSON spec: https://www.acalculator.org/math/linear-interpolation-calculator.json
- Version: db7712478701

## Default answer

Example with the default inputs (x₁ 2, y₁ 4, x₂ 3, y₂ 9, x 2.5): The line through (2, 4) and (3, 9) gives y = 6.5 at x = 2.5.

## Inputs

| Key | Label | Description |
| --- | --- | --- |
| x1 | x₁ | The x value of the first known point. |
| y1 | y₁ | The y value of the first known point. |
| x2 | x₂ | The x value of the second known point. It must differ from x₁. |
| y2 | y₂ | The y value of the second known point. |
| x | x | The x value to read the line at. |

## Outputs

| Key | Label | Description |
| --- | --- | --- |
| y | y at x | The value on the line at x: the interpolated value. |
| slope | Slope m | The rise per unit of x: (y₂ − y₁) ÷ (x₂ − x₁). |
| share | Position t | How far x is from x₁ toward x₂: (x − x₁) ÷ (x₂ − x₁). 0 at x₁, 1 at x₂. |
| kind | Interpolation or extrapolation | Interpolation when x is from x₁ to x₂; extrapolation when it is outside. |
| steps | Steps | The slope, then y read from the first point. |

## Method

m = (y₂ − y₁) ÷ (x₂ − x₁); y = y₁ + m (x − x₁). Worked in exact fractions of the typed decimals, rounded once.

## Assumptions

- The value changes along a straight line between the two known points.
- An x outside x₁ to x₂ gives an extrapolated value along the same line.
- Each number is from −10¹² to 10¹². x₁ and x₂ must differ.

## Worked examples

1. x1 = 2, y1 = 4, x2 = 3, y2 = 9, x = 2.5 gives y = 6.5, slope = 5, share = 0.5, kind = Interpolation: x is between x₁ and x₂. Source: OpenStax, College Algebra 2e, §4.1 Linear Functions (slope m = (y₂ − y₁) ÷ (x₂ − x₁) and point-slope form y − y₁ = m(x − x₁)), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions.
2. x1 = 2, y1 = 4, x2 = 3, y2 = 9, x = 4 gives y = 14, share = 2, kind = Extrapolation: x is outside x₁ to x₂. Source: OpenStax, College Algebra 2e, §4.1 Linear Functions (slope m = (y₂ − y₁) ÷ (x₂ − x₁) and point-slope form y − y₁ = m(x − x₁)), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions.
3. x1 = 0.1, y1 = 0.2, x2 = 0.3, y2 = 0.4, x = 0.2 gives y = 0.3, slope = 1, share = 0.5. Source: OpenStax, College Algebra 2e, §4.1 Linear Functions (slope m = (y₂ − y₁) ÷ (x₂ − x₁) and point-slope form y − y₁ = m(x − x₁)), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions.
4. x1 = 20, y1 = 2.339, x2 = 25, y2 = 3.169, x = 22 gives y = 2.671, slope = 0.166, share = 0.4. Source: OpenStax, College Algebra 2e, §4.1 Linear Functions (slope m = (y₂ − y₁) ÷ (x₂ − x₁) and point-slope form y − y₁ = m(x − x₁)), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions.
5. x1 = -1, y1 = 5, x2 = 4, y2 = -5, x = 0 gives y = 3, slope = -2. Source: OpenStax, College Algebra 2e, §4.1 Linear Functions (slope m = (y₂ − y₁) ÷ (x₂ − x₁) and point-slope form y − y₁ = m(x − x₁)), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions.

## FAQ

### What is linear interpolation?

It estimates a value between two known points by joining them with a straight line. If a table gives 4 at x = 2 and 9 at x = 3, the value at x = 2.5 is halfway between: 6.5.

### What is the linear interpolation formula?

y = y₁ + (x − x₁)(y₂ − y₁) ÷ (x₂ − x₁). It is the point-slope form of a line, y − y₁ = m(x − x₁), with slope m = (y₂ − y₁) ÷ (x₂ − x₁).

### How do I interpolate between two rows of a table?

Take the two rows around your value as (x₁, y₁) and (x₂, y₂). For a table with 2.339 at 20 and 3.169 at 25, the value at 22 is 2.339 + (22 − 20) × (3.169 − 2.339) ÷ 5 = 2.671.

### What is the position t?

t = (x − x₁) ÷ (x₂ − x₁) says how far x is along the way from x₁ to x₂: 0 at x₁, 0.5 halfway, 1 at x₂. Then y = y₁ + t (y₂ − y₁). Graphics code calls this a lerp.

### What is extrapolation?

Reading the same line outside x₁ to x₂ (t below 0 or above 1). The formula is the same, but the result is less reliable, because the data may stop following a straight line.

### Why is there no answer when x₁ equals x₂?

Two points with the same x lie on a vertical line, which has no single y. The formula would divide by x₂ − x₁ = 0.

### How do I find x for a given y, or a missing point?

Use the interpolation calculator, which solves for any one of the six numbers from the other five.

## Sources

- OpenStax, College Algebra 2e, §4.1 Linear Functions (slope m = (y₂ − y₁) ÷ (x₂ − x₁); point-slope form y − y₁ = m(x − x₁)). https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions (retrieved 2026-10-01)
- NIST Digital Library of Mathematical Functions, §3.3(i) Lagrange Interpolation, equation 3.3.1 (the two-point case is the straight line through the two points). https://dlmf.nist.gov/3.3 (retrieved 2026-10-01)
