Skip to content
Math

Linear Interpolation Calculator

Enter two known data points and the x-value you want to estimate. The calculator applies the linear interpolation formula to find the corresponding y-value, then shows you the slope, y-intercept, and the full line equation. A "show your work" panel traces every step, and a live chart plots the line so you can see exactly where your result falls. You can also reverse-solve: enter a known y to find the matching x.

Your details

The x-coordinate of the first known data point.
The y-coordinate of the first known data point.
The x-coordinate of the second known data point.
The y-coordinate of the second known data point.
Standard mode finds y for a given x. Reverse mode finds x for a given y.
The x-value for which you want the interpolated y.
Interpolated y
10

The estimated y-value at your chosen x

Solved x-
Slope (m)2
y-intercept (b)0
Line equationy = 2x + 0
Interpolation typeInterpolation (inside range)
Slope (m)2
y-intercept (b)0
-0.81020.80510
x
  • Line y = mx + b
  • Known points

Interpolation (inside range)

  • At x = 5, the estimated y-value is 10.
  • This is interpolation: your x falls between the two known data points, so the estimate is reliable as long as the relationship is roughly linear in that range.
  • The slope is positive (2), so y increases as x increases.

Next stepIf you have more than two data points, consider using a least-squares regression or spline interpolation for a more accurate fit.

Formula

y3=(x3x1)(y2y1)x2x1+y1m=y2y1x2x1b=y1mx1y_3 = \frac{(x_3 - x_1)(y_2 - y_1)}{x_2 - x_1} + y_1 \qquad m = \frac{y_2 - y_1}{x_2 - x_1} \qquad b = y_1 - m x_1

Worked example

Two known points: (2, 4) and (8, 16). Slope m = (16 - 4) / (8 - 2) = 12 / 6 = 2. Intercept b = 4 - 2 x 2 = 0. Line: y = 2x. At x = 5: y = 2 x 5 = 10. Since 2 <= 5 <= 8, this is interpolation.

What is linear interpolation?

Linear interpolation estimates an unknown value that falls between two known data points by assuming the relationship between them is a straight line. If you know that a variable equals y1 at x1 and y2 at x2, you can proportionally position any x between those endpoints to read off the matching y. The technique is used everywhere from engineering lookup tables to financial modelling, computer graphics, and everyday cooking: if 200 g of flour makes 15 cookies and 300 g makes 20, you can estimate the yield for 250 g without measuring it directly.

The formula and how to use it

The linear interpolation formula is y = (x - x1) x (y2 - y1) / (x2 - x1) + y1. This is identical to writing the slope m = (y2 - y1) / (x2 - x1), the intercept b = y1 - m x x1, and evaluating y = mx + b at the target x. Enter x1, y1, x2, y2, and the x you want. The calculator returns y, plus the slope, intercept, and the full equation. Switch to reverse mode to solve for x given a known y: x = (y - b) / m.

Interpolation vs. extrapolation

If the target x lies between x1 and x2, the estimate is called interpolation and is well-supported by the data. If the target lies outside that range, it is extrapolation: the calculation is mathematically identical, but the accuracy depends on whether the linear trend holds beyond the measured range. A short extrapolation near the boundary is often reasonable; a long one can accumulate large errors if the true relationship curves or changes slope. The calculator flags which case applies to your inputs.

Common real-world applications

Linear interpolation appears throughout science and engineering. Thermodynamics tables list fluid properties at discrete temperatures, and engineers interpolate to get values at intermediate temperatures. Surveyors interpolate elevations between measured ground points. Financial analysts interpolate yield curves between quoted maturities. Animators blend object positions between keyframes. In data science it fills gaps in time-series when sensors miss readings. Whenever a table has gaps, linear interpolation is the first tool to reach for.

Interpolation vs. extrapolation at a glance

ScenarioTarget locationTypical accuracyNotes
InterpolationInside [x1, x2]High (if linear)Supported by data; errors are small when the relationship is linear
Near-boundary extrapolationJust outside [x1, x2]ModerateSmall extrapolation; reasonable if the trend holds nearby
Far extrapolationFar outside [x1, x2]LowLarge uncertainty; nonlinear effects compound with distance

Accuracy of linear estimation depends on where the target falls relative to the known data range.

Frequently asked questions

What is the linear interpolation formula?

The formula is y = (x - x1) x (y2 - y1) / (x2 - x1) + y1. You take the fractional position of x between x1 and x2, then scale that fraction by the total y-range (y2 - y1) and add y1. Equivalently, find the slope m = (y2 - y1) / (x2 - x1) and intercept b = y1 - m x x1, then evaluate y = mx + b at your target x.

What is the difference between interpolation and extrapolation?

Interpolation estimates a value whose x lies between the two known points (inside the data range). Extrapolation estimates a value whose x lies outside that range. The formula is the same, but extrapolation is riskier because you are assuming the linear trend continues beyond the measured data.

Can I solve for x instead of y?

Yes. Switch to "reverse solve" mode and enter a known y. The calculator rearranges the equation to x = (y - b) / m and returns the corresponding x. This works as long as the slope is not zero (a horizontal line has no unique x for a given y).

What if my two x-values are the same?

If x1 = x2, the slope is undefined (division by zero) and linear interpolation cannot be performed. You need two distinct x-values to define a line.

How accurate is linear interpolation?

Accuracy depends on how close the true relationship is to a straight line between your two points. For smoothly varying functions over a small interval the error is proportional to the second derivative and the square of the interval width. For interpolation between closely spaced points the error is usually small; for extrapolation or widely spaced points, or when the function curves significantly, you should use higher-order methods such as polynomial or spline interpolation.

Sources

Written by Dr. Rajiv Menon, PhD Applied Mathematician · Bengaluru, India

Applied mathematician bridging algebraic theory and computational tools for students, engineers, and everyday problem-solvers.

Search 3,500+ calculators

Loading search…