Interpolation
Methods for constructing functions that pass through given data points.
Lagrange Interpolation
Theory
The Lagrange interpolating polynomial passes through all n+1 data points using basis polynomials.
Each basis polynomial equals 1 at and 0 at all other data points.
Data Points
P0: ,
P1: ,
P2: ,
P3: ,
P4: ,
Visualization
Polynomial Formula
Practice Problems
- Find the Lagrange polynomial through points (0, 1), (2, 5), (3, 4). Evaluate P(1).
- Construct L₁(x) for points (-1, 2), (0, 1), (1, 4), (2, 3).
- Show that Lagrange interpolation is exact for polynomials of degree ≤ n with n+1 points.
Implementation
INPUT: points (x0,y0), ..., (xn,yn), target x
OUTPUT: P(x)
P = 0
for i = 0 to n:
L_i = 1
for j = 0 to n, j ≠ i:
L_i = L_i * (x - x[j]) / (x[i] - x[j])
P = P + y[i] * L_i
RETURN P