How Lagrange Polynomial Interpolation Works
This article provides a straightforward guide to how Lagrange polynomial interpolation constructs a single, smooth mathematical curve that passes directly through a given set of known data points. By breaking the interpolation problem down into smaller, manageable components called basis polynomials, the Lagrange method completely avoids the need to solve complex systems of linear equations. Below, we explore the core concept of the zero-and-one property, break down the mathematical formula, and walk through a practical example to demonstrate how these pieces combine to form a continuous polynomial function.
The Core Objective
Suppose you have a set of \(n\) data points: \((x_1, y_1), (x_2, y_2), \dots, (x_n, y_n)\), where all the \(x\)-values are distinct. The goal of polynomial interpolation is to find a single polynomial function, \(P(x)\), of the lowest possible degree that passes through every single point. This means that if you plug \(x_1\) into the polynomial, it outputs \(y_1\); if you plug in \(x_2\), it outputs \(y_2\), and so on.
Because polynomials are continuous and infinitely differentiable, the resulting function \(P(x)\) naturally forms a smooth curve without any sharp corners or breaks.
The Clever Trick: Lagrange Basis Polynomials
Instead of trying to find the final polynomial all at once, Joseph-Louis Lagrange devised a method to build it out of smaller pieces. For each data point, we construct a specific "basis polynomial," denoted as \(L_i(x)\).
Each basis polynomial \(L_i(x)\) is designed to follow two strict rules:
- It must equal \(1\) when \(x = x_i\) (its own point's \(x\)-value).
- It must equal \(0\) when \(x\) is any of the other given \(x\)-values.
Step 1: Forcing the Zeros
To make a polynomial equal zero at specific \(x\)-values, we multiply terms of \((x - x_j)\) together for all points except the current point \(x_i\).
For example, if our \(x\)-values are \(x_1, x_2,\) and \(x_3\), and we are building the basis polynomial for the first point (\(x_1\)), the numerator will be: \[(x - x_2)(x - x_3)\] If you plug \(x_2\) or \(x_3\) into this expression, the result is immediately \(0\).
Step 2: Forcing the One
Next, we need this expression to equal \(1\) when we plug in \(x_1\). Remember that any non-zero number divided by itself equals \(1\). Therefore, we simply divide our numerator by the exact same expression, but with \(x\) replaced by \(x_1\): \[L_1(x) = \frac{(x - x_2)(x - x_3)}{(x_1 - x_2)(x_1 - x_3)}\] Now, if you plug in \(x = x_1\), the top and bottom are identical, resulting in \(1\). If you plug in \(x_2\) or \(x_3\), the top becomes \(0\), resulting in \(0\).
Combining the Pieces
Once you have a basis polynomial for every data point, you scale each one by multiplying it by its corresponding \(y\)-value, and then add them all together.
For three points, the final Lagrange polynomial \(P(x)\) looks like this: \[P(x) = y_1 L_1(x) + y_2 L_2(x) + y_3 L_3(x)\]
Why does this work? Let's test what happens when we plug \(x_1\) into \(P(x)\):
- \(L_1(x_1)\) becomes \(1\).
- \(L_2(x_1)\) becomes \(0\).
- \(L_3(x_1)\) becomes \(0\).
The equation simplifies to: \[P(x_1) = y_1(1) + y_2(0) + y_3(0) = y_1\]
The polynomial hits the exact point \((x_1, y_1)\) because all the other terms cancel out to zero. This exact same cancellation happens at every other given data point, guaranteeing the curve passes through all of them. For values of \(x\) between the data points, the basis polynomials blend together smoothly to create the connecting curve.
A Step-by-Step Example
Let's find the smooth curve that passes through these three points: \((1, 4)\), \((2, 7)\), and \((3, 12)\). Here, \(x_1 = 1, x_2 = 2, x_3 = 3\) and \(y_1 = 4, y_2 = 7, y_3 = 12\).
1. Build the first basis polynomial \(L_1(x)\) (for \(x_1 = 1\)): \[L_1(x) = \frac{(x - 2)(x - 3)}{(1 - 2)(1 - 3)} = \frac{(x - 2)(x - 3)}{(-1)(-2)} = \frac{x^2 - 5x + 6}{2}\]
2. Build the second basis polynomial \(L_2(x)\) (for \(x_2 = 2\)): \[L_2(x) = \frac{(x - 1)(x - 3)}{(2 - 1)(2 - 3)} = \frac{(x - 1)(x - 3)}{(1)(-1)} = -(x^2 - 4x + 3)\]
3. Build the third basis polynomial \(L_3(x)\) (for \(x_3 = 3\)): \[L_3(x) = \frac{(x - 1)(x - 2)}{(3 - 1)(3 - 2)} = \frac{(x - 1)(x - 2)}{(2)(1)} = \frac{x^2 - 3x + 2}{2}\]
4. Multiply by the \(y\)-values and add them together: \[P(x) = 4 L_1(x) + 7 L_2(x) + 12 L_3(x)\] \[P(x) = 4\left(\frac{x^2 - 5x + 6}{2}\right) - 7(x^2 - 4x + 3) + 12\left(\frac{x^2 - 3x + 2}{2}\right)\]
5. Simplify the algebra: \[P(x) = 2(x^2 - 5x + 6) - 7(x^2 - 4x + 3) + 6(x^2 - 3x + 2)\] \[P(x) = (2x^2 - 10x + 12) + (-7x^2 + 28x - 21) + (6x^2 - 18x + 12)\]
Group the like terms:
- \(x^2\) terms: \(2x^2 - 7x^2 + 6x^2 = 1x^2\)
- \(x\) terms: \(-10x + 28x - 18x = 0x\)
- Constants: \(12 - 21 + 12 = 3\)
This leaves us with the final, smooth curve: \[P(x) = x^2 + 3\]
If you plug \(x = 1, 2,\) and \(3\) into \(P(x) = x^2 + 3\), you get \(4, 7,\) and \(12\) respectively, confirming that the constructed curve passes directly through all the required points.