Lagrange interpolation is used to find a unique polynomial of least degree that best fits a set of distinct data points. To find the polynomial that passes through a set of \(k+1\) data points
\[ (x_0, y_0), (x_1, y_1), \ldots, (x_k, y_k) \]
begin by finding the basis polynomials for each point. The scaled basis polynomial \(L_i(x)\) corresponding to the point \((x_i,y_i)\) is given by
\[ L_i(x) = y_i \frac{(x-x_0)}{(x_i-x_0)}\cdot\frac{(x-x_1)}{(x_i-x_1)}\cdots\frac{(x-x_{i-1})}{(x_i-x_{i-1})}\cdot\frac{(x-x_{i+1})}{(x_i-x_{i+1})}\cdots \frac{(x-x_k)}{(x_i-x_k)} \]
Each basis polynomial will then have a root at each \(x_j \neq x_i\), and will pass through the point \((x_i,y_i)\). The final interpolating polynomial \(f(x)\) that passes through all data points is a linear combination of these basis polynomials:
\[ f(x) = L_0(x) + L_1(x) + \cdots + L_k(x) \]

Using the Applet

Drag the data points around the graph, and the Lagrange interpolation polynomial will be updated as a solid black line. Remove a data point by double clicking the point you'd like to remove. Double click the background to add a point (up to 10). You can also choose to hide or display the scaled basis polynomials generated by the data points as dashed lines.

About this Applet

This applet was created using JavaScript and the Raphael library. If you are unable to see the applet, make sure you have JavaScript enabled in your browser. This applet may not be supported by older browsers.