How this calculation works
Polynomial interpolation finds the unique polynomial of degree at most n minus one passing through n supplied values at distinct x coordinates. This page supports a general node list rather than only a line or three-point quadratic. Inputs are interpreted as exact rational numbers, so the expanded polynomial, query value and divided differences do not depend on floating-point pivot tolerances. Newton and Lagrange representations describe the same polynomial and are kept together on this page.
p(x) = Σ yᵢ ∏(j≠i) (x−xⱼ)/(xᵢ−xⱼ); the equivalent Newton form uses divided differences.A worked example
Enter (0,0), (1,1), (2,8) and (3,27). The interpolant is x³. Evaluating at x = 3/2 gives 27/8 exactly. In the supplied node order the Newton coefficients are 0, 1, 3 and 1, so p(x) = x + 3x(x−1) + x(x−1)(x−2). Expanding that expression cancels its lower-degree terms.
Good to know
Accepts 2 through 12 nodes with distinct x values, including equivalent-fraction duplicate detection. Rational components and decimal inputs use the shared bounds of ±1,000,000 and at most six decimal places. Intermediate exact fractions have a size limit and may reject difficult large inputs. The graph is a decimal sample; exact interpolation does not guarantee a reliable model between or beyond observations.
Reference: SciPy — polynomial interpolation and barycentric Lagrange form (opens in a new tab) ↗
One polynomial can have several useful representations
For the default cubic example, the expanded expression x³ is compact, but the Newton table explains how the polynomial is assembled from observations. Each successive coefficient multiplies one more factor involving an earlier node. Lagrange weights instead quantify the reciprocal products of node separations. The table provides those weights without creating a separate calculator for an algebraically equivalent answer.
Changing node order changes Newton coefficients and their associated basis products. It does not change the final polynomial when the same distinct observations are supplied. A useful check is to substitute every original x value and recover its given y exactly. The reported degree can be smaller than n minus one when the observations happen to lie on a simpler polynomial.
The Hermite interpolation calculator using values and derivatives adds explicit slope conditions to the value-only problem.
Exact arithmetic does not remove interpolation sensitivity
Exact fractions remove arithmetic rounding from this bounded calculation, but they do not establish that observed values are exact measurements of an underlying function. A small change in one y value can significantly alter a high-degree interpolant, particularly near interval ends or outside the node range. Oscillation between equally spaced nodes is a property of the interpolation problem, not merely a programming defect.
Two identical x values cannot specify two independent values for one function. Equal y values would duplicate a constraint, while different y values would be inconsistent. This page rejects both rather than guessing how to merge them. Use the Hermite values-and-derivatives calculator when a repeated location is intended to supply a derivative constraint. The existing linear and three-point quadratic tools remain useful smaller cases, while this general workflow handles more nodes and exposes exact representation details.
A few questions, answered
Is this a least-squares fit?
No. Every supplied value must be matched exactly. Regression usually minimizes residuals and need not pass through each observation.
Can I evaluate outside the node range?
Yes, within the input limits, but that is extrapolation. A mathematically exact polynomial value does not prove an accurate prediction of an unknown real process.