Skip to content

Linear Interpolation Calculator

Estimate a y value on the straight line between two known points.

Result

Enter two points and an x value

How to Use

  1. 1 Enter the first known point as x0 and y0.
  2. 2 Enter the second known point as x1 and y1.
  3. 3 Enter the x value you want to estimate.

Example Output

  • Points (0, 0) and (10, 100) give y = 40 at x = 4.
  • Equal x values cannot define a line.

About This Tool

Linear interpolation assumes the change between two known points is a straight line. It does not fit a curve, and a result outside the interval is an extrapolation.

Using the Linear Interpolation Calculator

Linear interpolation estimates a value on the straight line between two known points. You enter the first point, the second point, and the x value you care about. The calculator returns the y on that line and says whether x sits inside the interval or beyond it.

Inside the interval, the result is interpolation. Outside it, the same line is an extrapolation, and the page labels it that way. The line is an assumption. The calculator does not test whether the real relationship is straight.

What Is Linear Interpolation?

Two points determine a straight line, as long as they do not share the same x value. The line has a constant slope: the change in y divided by the change in x. Interpolation uses that slope to estimate y at an x that lies between the two known x values. The estimate agrees with the two points you entered. At x0 it returns y0. At x1 it returns y1.

The method is useful when you have measurements at two settings and need a value at a setting between them, and when you are willing to treat the change as steady. A temperature taken at minute 0 and minute 10 can be estimated at minute 4 only if a straight line is a fair picture of those ten minutes. If the temperature jumped and settled, the line is the wrong model. The calculator will still draw the line, because it cannot see the process.

Extrapolation uses the same slope past the interval. It can be a reasonable short step or a poor long one. The label on the result tells you which side of the interval you are on. It does not tell you whether the step is wise. That judgment needs the subject you are measuring.

A vertical pair, two points with the same x and different y values, does not have a slope. The calculator rejects it. A pair with the same x and the same y is a single point repeated, and it is rejected for the same reason: there is no change in x to divide by.

How the Calculator Works

Each box must hold one finite number. A blank box, a word, and a thousands comma are rejected. A minus sign is allowed. Decimals are allowed. The five values are x0, y0, x1, y1, and x.

The slope is (y1 − y0) / (x1 − x0). The estimate is y0 + (x − x0) × slope. The arithmetic is rounded to 12 decimal places. An exact case such as a slope of 10 and a step of 4 stays exact. A repeating division is shown at the 12-decimal precision rather than as a fraction.

The headline label is “Interpolated y” when x is between the two known x values, including the endpoints. It is “Extrapolated y” when x is smaller than both or larger than both. The detail line repeats that position in words. The slope is shown so you can see the rate the estimate used.

Order of the two points does not matter. Entering (0, 0) and (10, 100) is the same line as (10, 100) and (0, 0). The slope changes sign when the points are swapped, and the algebra lands on the same y. If you wanted a different model than a single straight line, this is the wrong tool. The Interpolation Calculator is a separate inventory entry. This page is specifically the straight line between two points, not a higher-order fit and not a curve through many points.

The Line Formula

Write the known points as (x0, y0) and (x1, y1). The slope m is (y1 − y0) / (x1 − x0). For a chosen x, y = y0 + (x − x0) × m. That is the point-slope idea with the first point as the anchor. Using the second point as the anchor, y = y1 + (x − x1) × m, gives the same y when the arithmetic is exact.

At x = x0, the added term is zero, so y = y0. At x = x1, x − x0 equals x1 − x0, so the added term is y1 − y0 and y = y1. Those two checks are the fastest way to see that the line passes through the points you typed.

The formula does not require x to lie between x0 and x1. The algebra is the same outside the interval. The meaning changes, which is why the label changes. A long extrapolation multiplies a slope by a large step. A small error in the slope becomes a large error in y. The page still reports the line. Shorten the step, or collect another measured point, when that sensitivity matters.

Equal x values make the denominator zero. There is no line of finite slope through a vertical pair. The calculator stops instead of returning an infinity token.

Worked Examples

Points (0, 0) and (10, 100) have slope 10. At x = 4, y = 0 + (4 − 0) × 10 = 40. The label is interpolated, because 4 lies between 0 and 10. At x = 12, y = 120. The label is extrapolated, because 12 lies beyond 10. At x = 0, y = 0. At x = 10, y = 100. The endpoints echo the inputs.

Points (2, 5) and (6, 5) have slope 0. Every x on the line has y = 5, inside or outside the interval. A flat line is a valid line. The position label still tells you whether x is between 2 and 6. The y value does not change.

Points (−5, 0) and (5, 10) have slope 1. At x = 0, y = 5. Negative coordinates are ordinary numbers. The interval from −5 to 5 includes 0, so the label is interpolated. Swapping the points to (5, 10) and (−5, 0) produces the same y at x = 0.

A percentage gap between two single results is not this formula. The Percentage Difference Calculator compares two numbers symmetrically. It does not build a y for a new x. Use it when the question is how far apart two peers are, not what the line predicts at a third x.

The line through (0, 0) and (10, 100)
x y Label
0 0 Interpolated y, at the first point
4 40 Interpolated y
10 100 Interpolated y, at the second point
12 120 Extrapolated y

How to Enter the Points

Type x0 and y0 from the first measurement, x1 and y1 from the second, and the x you want. Keep the units consistent. If x is minutes, both known x values must be minutes. If y is degrees, both known y values must be degrees. The calculator will not convert hours to minutes or Celsius to Fahrenheit.

Common Mistakes to Avoid

The main mistake is treating an extrapolated value as if it had been measured. The line is a rule you assumed. Past the last measurement, the process may bend. The label is the reminder. Write it down with the number.

Hand arithmetic helps on a short line. The 4 Function Calculator can subtract and divide the slope, then multiply by the step. Compare that product with this page at the same number of decimals. A mismatch of many units is a typing error. A mismatch at the last decimal is rounding.

Tips for a Trustworthy Estimate

Prefer a short span. Two points close to the x you need give the assumption less room to be wrong. Two points far apart, with the desired x in a gap where the process is known to curve, are a weak use of a straight line. Collect a third measurement when you can, and treat the line as a stopgap.

Spread around a set of points is a different summary. The Mean Absolute Deviation Calculator averages distances from a mean. It does not return a y on a line. Use it when the question is how scattered the measurements are, not what the line says at a new x.

Limitations

The calculator fits one straight segment through exactly two points. It does not fit a curve, a polynomial, or a least-squares line through a cloud. Extra points cannot be entered. If you have a cloud, choosing two of them and ignoring the rest is a decision the page will not announce. You should announce it.

Writing the Estimate Down

A number without its interval is easy to misuse later. When you copy y, also copy x0, y0, x1, y1, and the word from the label. Those six facts reconstruct the line. The headline alone does not. Someone who sees 40 and not the points cannot tell whether 40 was measured or estimated, or whether 4 was inside 0 and 10. The sentence from Copy result has y and x. Your note should add the points and the label.

Checking a Result

Confirm the endpoints. Then confirm a known middle if you have one. For the line through (0, 0) and (10, 100), x = 5 must return 50. If it does not, a digit in a box is wrong. The slope of that example is 10. The detail line should show 10.

A weighted center of several values is not a point on this line. The Weighted Average Calculator combines values by weights. Use it when you have weights. Use this page when you have two points and a straight-line assumption between them.

Frequently Asked Questions

What is linear interpolation?

It estimates y on the straight line between two known points. The slope is the change in y divided by the change in x, and y follows that slope from the first point to the x you enter.

What is the result for (0, 0), (10, 100), at x = 4?

The slope is 10. y = 40. The label is interpolated, because 4 lies between 0 and 10.

What happens at x = 12 for that same line?

y = 120, and the label is extrapolated, because 12 is outside the interval from 0 to 10. The algebra is the same. The meaning is a projection past the measurements.

Does the order of the two points matter?

No. Swapping the points changes the sign of the slope and the anchor, and the y for a given x stays the same.

What if both x values are equal?

The calculation stops. A vertical pair has no finite slope, so it does not define the line this tool draws.

Are the endpoints exact?

Yes. Asking for x0 returns y0, and asking for x1 returns y1, aside from the ordinary rounding of values you typed with long decimals.

Can the line be flat?

Yes. If both y values are equal, the slope is 0 and every estimate has that y. The label still says whether x is inside the interval.

Do negative numbers work?

Yes. Coordinates may be negative. The interval runs from the smaller x to the larger x, regardless of sign.

Will the tool tell me if a straight line is a bad model?

No. It always uses a straight line. You decide whether the process between the measurements is fair to treat as steady. The extrapolated label only tells you that x is outside the interval.

Can I enter more than two points?

No. Extra measurements have to be handled by choosing two points or by a different method. This page will not fit a curve.

Does it convert units?

No. Both x values must already share a unit, and both y values must already share a unit. Convert before you type.

What does Copy result copy?

A sentence with y and x. Add the word interpolated or extrapolated from the label when you write the number down.