AJ Designer

Linear Interpolation Calculator

y equals y1 plus the quantity x minus x1 times y2 minus y1 divided by x2 minus x1
Linear interpolation diagramA Cartesian plot with two known red points connected by a straight line. A green point on the line marks the interpolated value at x.x₁xx₂y₁yy₂

Red = known valuesBlue = interpolation pointGreen = result

Solution

Show Your Work

y = y₁ + (x − x₁)(y₂ − y₁) / (x₂ − x₁)
y = 20 + (1810)(2820) / (3010)
y = 20 + (8)(8) / (20)
y = 20 + 64 / 20
y = 20 + 3.2

Interpolation Plot

Two known points (red) connected by a straight line; the green point marks the interpolated value at x.

Share:

How It Works

Linear interpolation estimates an unknown value between two known data points by assuming the data changes at a constant rate between them. You enter the two known points (x1, y1) and (x2, y2), then provide the interior x-value where you want the estimated result y.

Example Problem

A steam table shows temperature 20°C at depth 10 m and 28°C at depth 30 m. Estimate the temperature at 18 m.

  1. Identify the known data points from the steam table: at depth 10 m the temperature is 20°C, and at depth 30 m it is 28°C. Assign x₁ = 10, y₁ = 20, x₂ = 30, y₂ = 28.
  2. Identify the interpolation point: we want the temperature at 18 m, so x = 18. Since 10 ≤ 18 ≤ 30, this is an interior point and interpolation is appropriate.
  3. Write the linear interpolation formula: y = y₁ + (x − x₁)(y₂ − y₁) / (x₂ − x₁).
  4. Substitute the known values into the formula: y = 20 + (18 − 10)(28 − 20) / (30 − 10).
  5. Simplify the numerator and denominator: y = 20 + (8)(8) / 20 = 20 + 64/20 = 20 + 3.2.
  6. Compute the final result: y = 23.2°C. The estimated temperature at a depth of 18 m is 23.2°C.

Key Concepts

Linear interpolation treats the segment between two known points as a straight line. The estimate is proportional to how far x lies between x1 and x2, so the result is most reliable when the underlying data changes smoothly and almost linearly over that interval.

Applications

  • Engineering tables: reading between entries in steam tables, pipe friction charts, and material property data
  • Geographic information systems: estimating elevation or temperature along a profile between measured points
  • Computer graphics: blending values between keyframes or sample points along one dimension
  • Signal processing: resampling discrete data to a different time or frequency resolution

Common Mistakes

  • Extrapolating beyond the data range — interpolation assumes the value lies between known points; extrapolation outside that range is less reliable
  • Using linear interpolation on highly nonlinear data — exponential or strongly curved relationships can produce large errors between widely spaced points

Frequently Asked Questions

How do you calculate linear interpolation?

Use the formula y = y₁ + (x − x₁)(y₂ − y₁) / (x₂ − x₁). You need two known points (x₁, y₁) and (x₂, y₂), then plug in your target x value. The result y is the estimated value at that point assuming a straight line between the two knowns.

What is the formula for linear interpolation?

The linear interpolation formula is y = y₁ + (x − x₁)(y₂ − y₁) / (x₂ − x₁). It calculates the y-value at any x between two known data points (x₁, y₁) and (x₂, y₂) by assuming the values change at a constant rate along a straight line connecting them.

What is the difference between interpolation and extrapolation?

Interpolation estimates a value between known data points. Extrapolation estimates beyond the known range and is generally less reliable because it assumes the same trend continues outside the measured data. Linear interpolation is safest when the target value lies inside the known range.

Is lerp the same as linear interpolation?

Yes — lerp is just a common shorthand used in computer graphics and game programming for linear interpolation. Both compute the same value on a straight line between two points. Programmers often write lerp(a, b, t) = a + t × (b − a), where t is the normalized position from 0 to 1 between the two endpoints.

Can linear interpolation be used for extrapolation?

The same formula works when x is outside the range [x₁, x₂], but you are extrapolating rather than interpolating. This is mathematically valid but less reliable because it assumes the linear trend continues unchanged beyond the data you measured. Use with caution and cross-check with additional data when possible.

How accurate is linear interpolation?

Linear interpolation is exact when the underlying relationship is truly linear, and very accurate for data that changes at a nearly constant rate over small intervals. It becomes less accurate for strongly curved or exponential data, especially over wide intervals. For nonlinear data, polynomial, spline, or cubic interpolation methods give better results.

Is linear interpolation accurate for nonlinear data?

It provides only an approximation. Linear interpolation works best when the data changes at a nearly constant rate over the interval. For strongly curved data — exponential, logarithmic, or oscillating — polynomial, spline, or cubic methods give noticeably better results, especially when data points are widely spaced.

Linear Interpolation Formula

The linear interpolation formula estimates the value of y at any point x between two known data points (x₁, y₁) and (x₂, y₂):

y = y₁ + (x − x₁)(y₂ − y₁) / (x₂ − x₁)

Where:

  • x₁, y₁ — the first known data point
  • x₂, y₂ — the second known data point
  • x — the x-value at which you want to estimate y
  • y — the interpolated result (the estimated y at x)

The formula assumes the value changes at a constant rate between the two known points. It works for any x value, but is most accurate when x lies between x₁ and x₂ and the data is approximately linear over that range.

Worked Examples

Engineering

How do you interpolate aluminum's thermal expansion coefficient?

The thermal expansion coefficient of aluminum is 23.1 × 10⁻⁶/°C at 25°C and 24.9 × 10⁻⁶/°C at 100°C. Estimate the coefficient at 60°C for a heat-exchanger design calculation.

  • Knowns: x₁ = 25, y₁ = 23.1, x₂ = 100, y₂ = 24.9; interpolation point x = 60
  • y = 23.1 + (60 − 25)(24.9 − 23.1) / (100 − 25)
  • y = 23.1 + (35)(1.8) / 75 = 23.1 + 0.84
  • y ≈ 23.94 × 10⁻⁶/°C

Thermal expansion varies nearly linearly with temperature over this range, so linear interpolation gives a reliable estimate to three significant figures.

Finance

How do you interpolate a bond yield between two Treasury tenors?

A bank's yield curve shows a 3-year Treasury yield of 4.25% and a 5-year Treasury yield of 4.80%. What is the estimated 4-year yield for use in a bond valuation model?

  • Knowns: x₁ = 3, y₁ = 4.25, x₂ = 5, y₂ = 4.80; interpolation point x = 4
  • y = 4.25 + (4 − 3)(4.80 − 4.25) / (5 − 3)
  • y = 4.25 + (1)(0.55) / 2 = 4.25 + 0.275
  • y ≈ 4.525%

Yield curves are usually smooth and nearly linear between adjacent tenors, making linear interpolation a standard technique in fixed-income analysis for missing tenors.

Data Science

How do you fill a missing value in a time series with linear interpolation?

A daily sensor reading shows 15.2°C on Monday and 17.4°C on Wednesday, but Tuesday is missing due to sensor downtime. Estimate the Tuesday reading using linear interpolation between the two known days.

  • Knowns: x₁ = 0 (Monday), y₁ = 15.2; x₂ = 2 (Wednesday), y₂ = 17.4; interpolation point x = 1 (Tuesday)
  • y = 15.2 + (1 − 0)(17.4 − 15.2) / (2 − 0)
  • y = 15.2 + (1)(2.2) / 2 = 15.2 + 1.1
  • y ≈ 16.3°C

Linear interpolation is a common imputation technique in data cleaning when gaps are short and the underlying variable changes smoothly. For longer gaps or strongly nonlinear data, spline interpolation or a model-based approach gives better results.

Related Calculators

Related Sites