Tool for calculating the Lagrange interpolating polynomial from a list of points. Lagrange polynomial interpolation allows us to find the equation of a polynomial function and perform extrapolation.
Lagrange Interpolating Polynomial - dCode
Tag(s) : Functions
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
Lagrange interpolation is a method for determining the polynomial $ P $ of degree $ n $ that passes through $ n+1 $ given distinct points $ \{ (x_0,y_0), (x_1,y_1), \dots, (x_n,y_n) \} $
The Lagrange interpolating polynomial can be written in the form $$ P(X) = \sum_{j=0}^n y_j \left(\prod_{i=0,i\neq j}^n \frac{X-x_i}{x_j-x_i} \right) $$
It checks that $ P(x_j) = y_j $ for all $ j $, which ensures that the curve passes exactly through the given points.
For distinct abscissas, there exists a unique Lagrange interpolating polynomial.
From a set of points with known coordinates, Lagrange interpolation allows us to explicitly construct the polynomial $ P(x) $. This polynomial can then predict other points (by extrapolation) based on the assumption that the curve formed by these points comes from a polynomial-type equation.
Example: By the knowledge of the points $ (x,y) $ : $ (0,0),(2,4),(4,16) $ the Polynomial Lagrangian Interpolation method allows to find back the équation $ y = x^2 $. Calculations details step by step: $$ P(x) = 0 \times \frac{(x-2)}{(0-2)} \frac{(x-4)}{(0-4)} + 4 \times \frac{(x-0)}{(2-0)} \frac{(x-4)}{(2-4)} + 16 \times \frac{(x-0)}{(4-0)} \frac{(x-2)}{(4-2)} \\ = 4 \times \frac{x}{2}\frac{(x-4)}{(-2)} + 16 \times \frac{x}{4}\frac{(x-2)}{2} \\ = -x(x-4)+2x(x-2) \\ = -x^2+4x+2x^2-4x \\ = x^2
$$ Once deducted, the interpolating function $ f(x) = x^2 $ allows to estimate the value for $ x = 3 $, here $ f(x) = 9 $.
There are other interpolation formulas (rather than Lagrange/Rechner) such as Newton interpolation or Neville interpolation also available online on dCode.
Lagrange interpolation requires that the x-coordinates $ x_i $ be distinct in pairs, a necessary condition to guarantee the existence and uniqueness of the interpolating polynomial.
As the number of points increases, the degree of the polynomial also increases, making the expression more complex and increasing the computational cost.
From a numerical perspective, the method can become unstable with many points or when they are poorly distributed, as rounding errors can be amplified. Furthermore, for equidistant points and a high degree, the polynomial can exhibit strong oscillations at the ends of the interpolation interval, a phenomenon known as the Runge phenomenon.
For estimating a new value $ x $, evaluate $ P(x) $:
— if $ x $ belongs to the interval $ [\min x_i,\max x_i] $, it is an interpolation;
— otherwise, it is an extrapolation, generally less reliable.
The quality of the estimation depends heavily on the number of points used and their distribution.
dCode retains ownership of the "Lagrange Interpolating Polynomial" source code. Any algorithm for the "Lagrange Interpolating Polynomial" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Lagrange Interpolating Polynomial" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Lagrange Interpolating Polynomial" or any other element are not public (except explicit open source licence). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Lagrange Interpolating Polynomial" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source (Creative Commons CC-BY free distribution license).
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Lagrange Interpolating Polynomial on dCode.fr [online website], retrieved on 2026-03-06,