Report

Help us improve this tool

Linear Interpolation Calculator

Calculate interpolated and extrapolated values between two coordinates with slope, equation of the line, step-by-step formula, and live interactive graph.

O M T

What is Linear Interpolation (Lerp)?

Linear interpolation, often abbreviated as lerp, is a fundamental mathematical method of curve fitting using linear polynomials to construct new data points within the range of a discrete set of known data points.

If two known coordinates are given by \((x_1, y_1)\) and \((x_2, y_2)\), the linear interpolant is the straight line connecting these two endpoints. For any intermediate value \(x\) in the interval \([x_1, x_2]\), the corresponding estimated value \(y\) along the straight line is determined by:

$$y = y_1 + \frac{(x - x_1)(y_2 - y_1)}{x_2 - x_1}$$

Understanding the Interpolation Parameter \(t\)

In computer graphics, physics simulations, and game development, linear interpolation is frequently expressed in normalized parametric form:

$$\text{lerp}(y_1, y_2, t) = (1 - t)y_1 + t y_2 = y_1 + t(y_2 - y_1)$$

where \(t = \frac{x - x_1}{x_2 - x_1}\) represents the fractional distance from \(x_1\) to \(x_2\).

  • When \(t = 0\), \(y = y_1\) (at the starting point).
  • When \(t = 0.5\), \(y\) is the exact midpoint between \(y_1\) and \(y_2\).
  • When \(t = 1\), \(y = y_2\) (at the end point).
  • When \(0 \le t \le 1\), the process is interpolation.
  • When \(t < 0\) or \(t > 1\), the estimation lies outside the original data range and is known as linear extrapolation.

Inverse Linear Interpolation

If you know the target value \(y\) and need to determine the corresponding parameter \(x\), you can rearrange the linear equation to solve for \(x\):

$$x = x_1 + \frac{(y - y_1)(x_2 - x_1)}{y_2 - y_1}$$

This inverse interpolation is particularly helpful when reading tabular calibration charts, engineering psychrometric data, and steam tables.

Frequently Asked Questions

What is the difference between interpolation and extrapolation?

Interpolation estimates unknown values within the range of known data points (\(x_1 \le x \le x_2\)). Extrapolation estimates values outside the range (\(x < x_1\) or \(x > x_2\)). Extrapolation assumes that the linear trend continues beyond the observed data, which carries higher uncertainty.

How accurate is linear interpolation for non-linear data?

Linear interpolation approximates non-linear functions by straight line segments. The error is proportional to the square of the interval width \((x_2 - x_1)^2\) and the second derivative of the underlying function. When points are close together, linear interpolation provides an excellent approximation.

Can I use this tool for 2D grid surfaces?

For 2D surfaces and image scaling across a rectangular grid, you can use our Bilinear Interpolation Calculator.

What happens if x₁ equals x₂?

If \(x_1 = x_2\), the denominator \(x_2 - x_1\) equals zero, resulting in a vertical line with undefined slope. A vertical line has infinitely many \(y\) values for that single \(x\), so linear interpolation requires two distinct \(x\) coordinates.