This demo implements interpolation of data points using parametric Lagrange polynomials. Just click on any of the points and drag them around. Press the "Restart" button in order to start over with the constant line through the data points. Read on for more theory on Lagrange polynomials and interpolation.

A set of N points can be interpolated by a polynomial of degree at most N-1. This means that 3 points can be interpolated by a parabola (degree 2) or a straight line. Four points can be interpolated by a cubic (degree 3), or a parabola or straight line and so on. The points in this demo start off with an interpolating curve of degree 1, a straight line. The curve is constructed by taking a linear combination of the points to be interpolated with pre-computed Lagrange basis functions varying in time. The Lagrange basis functions, Li(t), satisfy the following two conditions: Li(ti) = 1, Li(tj) = 0 for i not equal to j. This will ensure that our polynomial passes through each of our points. Notice, when working in high degree (5 or more), how a slight change in one of the points in the interior usually affects the curve near the endpoints immensely. To remedy this, use another interpolation method such as Cubic Splines.

Note: This and the related demos were written some time ago by then-student Mark Hoefer. For mathematical background, see course handouts on Lagrange interpolation , cubic Bezier curves , cubic spline curves , and nonuniform splines . (A couple of diagrams are not included, as they were physically pasted into the handouts.)