Enter four observed pairs, (x0, y0) through (x3, y3), and a target x. The calculator evaluates the unique polynomial of degree at most three passing through all four observations. The x values must be distinct, but they do not need to be equally spaced or entered in ascending order.

  1. Enter four pairs of observed x and y values. Keep each y paired with its corresponding x.
  2. Check that no two x values are equal. Repeated y values are allowed.
  3. Enter the target x where you want an estimate.
  4. Read the polynomial value and the four weighted contributions that sum to it.

Use one consistent unit for all x values, including the target, and one consistent unit for all y values. The result and contributions have the same unit as your y values. Inputs are entered as plain numbers; no unit conversion is performed.

\[P(x)=\sum_{i=0}^{3}y_iL_i(x),\qquad L_i(x)=\prod_{\substack{j=0\\j\ne i}}^{3}\frac{x-x_j}{x_i-x_j}\]

For valid distinct x values, the four Lagrange weights sum to one in exact arithmetic. Some weights can be negative, so this is not necessarily an average bounded by the observed y values. The polynomial can overshoot between observations.

When the target equals a sample x, that sample’s weight is one and the other weights are zero, reproducing its y value in exact arithmetic. Although four samples allow a cubic polynomial, the result can instead be quadratic, linear or constant when the observations lie on a lower-degree polynomial.

Default example: observations (0, 0), (1, 1), (3, 9), (4, 16), evaluated at x = 2.
ObservationLagrange weight at x = 2Weighted contribution
(0, 0)−1/60
(1, 1)2/32/3
(3, 9)2/36
(4, 16)−1/6−8/3
Sum14

The example observations lie on y = x², so the interpolating polynomial returns 4 at x = 2 despite the unequal spacing. The table uses exact fractions; displayed decimal contributions may have small rounding differences when added.

A target between the smallest and largest sample x values is interpolation. A target outside that interval is extrapolation. The calculator evaluates the same polynomial in either case, but extrapolated values can change rapidly and may poorly represent the underlying relationship.

Repeated x values make this four-point formula divide by zero, so the result and contributions are unavailable. Matching y values at a repeated x do not restore four distinct observations; different y values at the same x cannot both be matched by a single-valued polynomial.

Closely spaced x values create small denominators. Especially when the target lies farther away, the resulting large weights can magnify measurement errors and rounding. Large contributions of opposite signs can also cancel, losing numerical precision. Extremely large or small values can exceed numerical limits. Where practical, express x relative to a nearby origin and in a suitable common scale, applying the same transformation to the target.

Passing exactly through the samples does not guarantee an accurate estimate between them. This calculator does not estimate uncertainty or smooth noisy observations.

Use this calculator when all four observations belong to one independent x axis. Bilinear interpolation instead uses values at four corners of a rectangular grid with two independent coordinates.

A cubic Bézier point calculator evaluates a parametric curve defined by control points; the curve generally does not pass through its two interior control points. Here, every supplied observation must lie on the interpolating polynomial.

Least squares regression fits observations according to an error criterion and generally does not pass through every sample. It serves a different purpose when fitting noisy data.