Lagrange Interpolation

Lagrange interpolation is a way to pass a polynomial of degree N-1 through N points. In the applet below you can modify each of the points (by dragging it to the desired position) and the number of points by clicking at the number shown in the lower left corner of the applet.

This applet requires Sun's Java VM 2 which your browser may perceive as a popup. Which it is not. If you want to see the applet work, visit Sun's website at, download and install Java VM and enjoy the applet.

What if applet does not run?

Note how dragging just one point affects the whole graph. Compare this to the behavior of the cubic spline.

Lagrange polynomials are the interpolating polynomials that equal zero in all given points, save one. Say, given points x1, x2, ..., xN, Lagrange's polynomial #k is the product

Pk(x)= (x - x1)/(xk - x1) · (x - x2)/(xk - x2) · ... · (x - xk-1)/(xk - xk-1) · (x - xk+1)/(xk - xk+1) ·...· (x - xN)/(xk - xN),

such that Pk(xk) = 1 and Pk(xj) = 0, for j different from k. There is a simpler way to write Lagrange polynomials. Let

  P(x) = ∏(x - xi),

where product is taken over all possible indices i (1 ≤ i ≤ N). Define also

  P'k(x) = ∏'(x - xi),

where the "prime" indicates the omission of one of the factors, viz., (x - xk). Using P'k Lagrange polynomials appear in a very compact form:

  Pk(x) = P'k(x) / P'k (xk).

In terms of Lagrange's polynomials the polynomial interpolation through the points (x1, y1), (x2, y2), ..., (xN, yN) could be defined simply as

(1) P(x) = y1P1(x) + y2P2(x) + ... + yNPN(x).

You can observe Lagrange's polynomials by clicking on the number to the right of "Show polynomial #". If the number is 0, the starting function is a parabola instead.

(The form (1) of the interpolating polynomial, while correct, is quite inconvenient in several respects for numerical computations. Usually, another one that makes use of Newton's divided differences is implemented instead. This is the route taken by the applet above.)

Related material

  • What Is Line?
  • Functions, what are they?
  • Cartesian Coordinate System
  • Addition and Subtraction of Functions
  • Function, Derivative and Integral
  • Graph of a Polynomial of arbitrary degree
  • Graph of a Polynomial Defined by Its Roots
  • Inflection Points of Fourth Degree Polynomials
  • Lagrange Interpolation (an Interactive Gizmo)
  • Equations of a Straight Line
  • Taylor Series Approximation to Cosine
  • Taylor Series Approximation to Cosine
  • Linear Function with Coefficients in Arithmetic Progression
  • Sine And Cosine Are Continuous Functions
  • |Activities| |Contact| |Front page| |Contents| |Algebra|

    Copyright © 1996-2018 Alexander Bogomolny