Linear interpolation calculator
m = (y2 − y1) / (x2 − x1)
Given two points (x1, y1) and (x2, y2), calculate the y value corresponding to a given x, or conversely the x value corresponding to a given y, assuming a linear relationship between the two quantities. The tool displays the slope, y-intercept and complete line equation, and explicitly flags when the sought value falls outside the interval of the two provided points (extrapolation rather than interpolation).
Scientific dossier
What the tool computes, what it assumes, where it stops being valid, and where its data comes from.
Method & formulasm = (y2 − y1) / (x2 − x1)
m = (y2 − y1) / (x2 − x1)
b = y1 − m × x1
y = m × x + b
x = x1 + (y − y1) × (x2 − x1) / (y2 − y1)
Two points (x1, y1) and (x2. Y2) define a unique line. Its slope m measures how much y changes for a one-unit change in x; its y-intercept b is the value of y when x equals zero. Once m and b are known, the equation y = m×x + b gives y for any x, and its inverted form gives x for any y.
- Interpolation
- · estimation of y (or x) for a value between x1 and x2 (or between y1 and y2), within the observed interval.
- Extrapolation
- · estimation outside this interval: the linear relationship is then assumed to extend, with no guarantee that this holds beyond the measured points.
- Slope (m)
- · change in y for a one-unit change in x; negative if y decreases when x increases.
- Y-intercept (b)
- · value of y when x = 0, as extended by the line. Not necessarily an observed value.
Validity domainThe calculation assumes that the relationship between x and y is truly linear over the entire interval considered: nothing guarantees that an extrapolation far from the two points remains valid.
The calculation assumes that the relationship between x and y is truly linear over the entire interval considered: nothing guarantees that an extrapolation far from the two points remains valid. The calculation is undefined when the two x-values are identical (no slope can be determined to calculate y), and when the two y-values are identical in the inverse sense (a horizontal line determines no x from y).