Linear Interpolation Calculator
Compute exact interpolated or extrapolated coordinates, slope, y-intercept, and affine blend ratio between two points with interactive line graphing.
Known Endpoint 1 (P1)
(x1, y1)Known Endpoint 2 (P2)
(x2, y2)Values between x1 and x2 perform interpolation; values outside perform linear extrapolation.
Interactive Line & Segment Graph
Solid segment shows interpolation domain [P1, P2]; dashed line extends for extrapolation
Step-by-Step Algebraic Derivation
How Linear Interpolation Works
Linear interpolation estimates an unknown coordinate on the straight line connecting two known data points P₁(x₁, y₁) and P₂(x₂, y₂). By computing the constant rate of change m = (y₂ − y₁)/(x₂ − x₁) or the normalized blend parameter t = (x − x₁)/(x₂ − x₁), any intermediate or extended point evaluates exactly as y = (1 − t)y₁ + ty₂.
Linear Interpolation Definition and Algebraic Formulas
In numerical analysis, experimental science, and engineering design, measurements are rarely available at every continuous input value. Laboratory instruments sample at discrete timestamps, thermodynamic handbooks publish property tables every five or ten degrees, and financial curves list benchmark yields only at standard maturities such as two, five, and ten years. Linear interpolation bridges the gap between two consecutive known observations and by modeling the relationship between them as a straight line segment.
Mathematically, replacing an unknown curve with a secant line relies on the fundamental property of similar right triangles. Along any straight line with , the ratio of vertical rise to horizontal run between and an intermediate point must equal the ratio across the entire span from to :
Isolating yields the classic point-slope interpolation formula used throughout physics, surveying, and calculus:
Notice that the fraction is simply the constant slope between two points, and rearranging terms immediately produces the slope-intercept equation of a line with intercept . If you already know the gradient rather than a second point, you can switch directly to a point-slope form calculator.
Parametric Lerp Weights and Geometric Interpretation
An equally powerful way to view linear interpolation is through a dimensionless progress parameter that tracks how far has traveled from toward :
In software engineering and computer graphics, this convex-combination identity is known universally as lerp. Because the weights and always sum identically to , the expression generalizes effortlessly from scalar numbers to multidimensional vectors in two or three dimensions, RGB color triples, and linear camera paths—and remains valid even when along a vertical line segment.
Setting evaluates , which matches the geometric average computed by a midpoint calculator. When you chain multiple linear interpolations hierarchically across three or more control points, the resulting nested lerp construction becomes De Casteljau’s algorithm inside a Bézier curve calculator. Meanwhile, the total Euclidean span between endpoints can be measured with a distance formula calculator.
| Blend Value t | Weight on P₁ | Weight on P₂ | Geometric Meaning |
|---|---|---|---|
| t < 0 | > 100% | < 0% | Backward extrapolation past P₁ |
| t = 0 | 100% | 0% | Exact match with first endpoint P₁ |
| t = 0.5 | 50% | 50% | Exact geometric midpoint between P₁ and P₂ |
| t = 1 | 0% | 100% | Exact match with second endpoint P₂ |
| t > 1 | < 0% | > 100% | Forward extrapolation past P₂ |
Interpolation Versus Extrapolation Boundaries
Although both regimes evaluate the exact same formula, distinguishing between interpolation () and extrapolation ( or ) is critical when interpreting results. Within the closed interval , any smooth monotone function lies near its chord, and any physical bounds satisfied by both endpoints (such as non-negative concentrations or bounded percentages) automatically hold for every convex combination .
Outside , linear extrapolation projects the local slope indefinitely into unmeasured territory. If you extrapolate saturation pressure across a phase-transition boundary, or project population growth decades beyond the last census measurement using a two-point tangent, curvature and structural regime shifts quickly invalidate the estimate. Our interactive plot highlights the bounded interpolation segment in solid blue and extends extrapolated wings as dashed indigo lines while flagging the exact status badge above your input field.
Inverse Interpolation and Higher-Dimensional Extensions
Scientists often need to solve the converse problem: given a measured response , determine which input value produces it along the segment between and . Switching the calculator to Inverse: Find x from y mode computes the vertical ratio whenever :
When datasets depend on two independent variables—for example, enthalpy tabulated by both temperature and pressure, or pixel color sampled at sub-pixel grid coordinates —engineers apply bilinear interpolation. Conceptually, bilinear interpolation performs three sequential 1D linear interpolations: first interpolating horizontally along the top and bottom grid edges, and then interpolating vertically between those two intermediate results. Extending once more across a third axis yields trilinear interpolation used in volumetric medical imaging and 3D lookup tables.
Truncation Error Bounds and Numerical Stability
Suppose the true underlying phenomenon follows a smooth, twice-continuously differentiable function sampled at and . By Rolle’s Theorem applied to the Newton remainder term, the difference between the true function and the linear interpolant is governed by the second derivative at some interior point :
Two practical insights follow immediately from this quadratic bound. First, maximum truncation error always peaks at the midpoint , where . Second, doubling the density of reference points (cutting step width in half) shrinks interpolation error by a factor of four. On the floating-point side, writing is numerically preferable to when endpoints have large baseline offsets, though guarantees monotonicity if .
Engineering Tables, Finance, and Computer Graphics Applications
Thermodynamics & Fluid Mechanics
Mechanical and chemical engineers constantly interpolate saturated and superheated steam tables to read enthalpy, entropy, specific volume, and vapor pressure between standardized 5 °C or 10 °C intervals.
Finance & Yield Curves
Fixed-income analysts estimate par swap rates, zero-coupon discount factors, and implied volatility at odd dates such as 4.25 years by interpolating between neighboring 3-year and 5-year market quotes.
Digital Audio & Image Resampling
Sample-rate converters, hardware GPU texture samplers, and keyframe animation engines rely on single-cycle multiply-add lerp instructions to reconstruct smooth intermediate samples in real time.
Machine Learning & Sensor Fusion
Time-series pipelines use linear interpolation to impute isolated missing sensor ticks or align asynchronous IMU and GPS timestamps prior to training forecasting models.
Step-by-Step Worked Numerical Examples
Example 1: Interpolating Saturated Steam Pressure at 112 °C
Suppose a steam table lists vapor pressure at and at . Estimate the saturation pressure at .
- Find the normalized progress factor: . Since , this is strictly interpolation.
- Compute the local slope: .
- Evaluate the interpolated pressure: .
Example 2: Inverse Interpolation for Concentration Threshold
A linear calibration curve measures absorbance at and at . Find the unknown concentration yielding absorbance .
- Compute the vertical blend fraction: .
- Recover : .
Common Mistakes and Edge-Case Pitfalls
- Swapping x₁ and x₂ inconsistently: Mixing up in the denominator while subtracting in the numerator flips the sign of the slope and produces values outside the segment bounds.
- Extrapolating non-linear curves too far: Because exponential, logarithmic, and trigonometric laws accelerate away from a chord, linear extrapolation beyond roughly 10% of the step width can introduce systematic bias.
- Forgetting vertical-line singularities: Whenever , is no longer a function of ; switch to 2D parametric mode instead of dividing by zero.
- Confusing interpolation with least-squares regression: Linear interpolation passes exactly through two endpoints and treats them as noise-free, whereas regression fits one best-fit line across three or more noisy observations (such as an overdetermined least-squares system).
Computational Methodology and Precision Standards
All calculations in this tool run locally inside your browser using IEEE-754 double-precision floating-point arithmetic without server round-trips. In addition to displaying 6-digit decimal outputs, the engine searches reduced denominators up to 10,000 via continued-fraction rational approximation to display clean exact fractions whenever inputs terminate cleanly. High-DPI canvas plotting automatically adapts its coordinate frame so both interpolation points, extrapolated rays, and axis ticks remain legible across mobile phones, tablets, and desktop displays.
Lead Developer & Founder of Basic Math Tools. Specializes in browser-native computational algorithms and applied mathematics.
Mathematics & curriculum specialists. Audited against standard algebraic and arithmetic principles.