A13 · Lesson 11 · Polynomial interpolation
A curve through the points, and where it goes wrong between them
A thermistor's datasheet gives resistance at every 5 °C; your firmware needs it at 23.7 °C. A sine table in a synthesizer has 256 entries; the phase lands between them. A sample-rate converter needs the signal halfway between samples. Each time, you fit a polynomial through nearby points and evaluate it between them. Low-degree pieces work beautifully. One high-degree polynomial through many equally spaced points can fail spectacularly, swinging wildly near the ends; the fix is to choose the points, clustering them toward the ends as the Chebyshev nodes do.
- The black curve is Runge's function. The orange curve is the polynomial through n + 1 equally spaced points; the dashed one goes through n + 1 Chebyshev points, crowded toward ±1.
- At n = 4 both are rough. Raise n to 8 and 12: the equally spaced interpolant gets worse near the ends (its largest error grows to 3.7), while the Chebyshev one gets steadily better.
- More points only help if they're in the right places.
Predict
A 256-entry sine table is read with linear interpolation between entries. About how large is the worst error, for a sine of amplitude 1?
: the linear-interpolation error is at most , with and , so . Doubling the table quarters it.
Name it
The interpolating polynomial
Through n + 1 points with distinct there's exactly one polynomial of degree at most n. In Lagrange form
and in Newton form, built from divided differences , :
In practice use the barycentric form of Lagrange, which is stable and costs O(n) per evaluation. Never solve the Vandermonde system for the coefficients: its condition number grows exponentially with n.
The error
for some ξ in the interval. For linear interpolation with spacing h this gives at most .
Runge's phenomenon and Chebyshev nodes
With equally spaced points the product is enormous near the ends, and for functions like the error grows without bound as n increases. The Chebyshev nodes
make as small as possible on [−1, 1], namely , and the interpolant converges for every smooth function. For another interval, scale them linearly.
Worked example
A thermistor table gives 10.00 kΩ at 25 °C and 8.06 kΩ at 30 °C. Estimate R at 27 °C by linear interpolation.
Show the solution
- Interpolate.
- Compare with the curve. The true curve is convex (it's roughly exponential), so the line overestimates slightly: the exponential through both points gives 9.166 kΩ.
- How good that is. A thermistor table every 5 °C with linear interpolation is good to within about 1%.
Answer linear interpolation gives 9.224 kΩ, slightly high; the exponential through both points gives 9.166 kΩ.
Worked example
Find the quadratic through (0, 1), (1, 3), (3, 2) in Newton form.
Show the solution
- First divided differences.
- Second divided difference.
- The Newton form.
- Evaluate at 2.
Answer , with .
Worked example
Interpolate on [−1, 1] with a degree-10 polynomial, once through equally spaced nodes and once through Chebyshev nodes. How large are the errors?
Show the solution
- Equally spaced nodes. With 11 equally spaced nodes the interpolant swings wildly near the ends: the largest error is 1.92, larger than the function itself.
- Chebyshev nodes. With the 11 Chebyshev nodes the largest error is 0.109.
- More equally spaced nodes. Adding them makes it worse, which is Runge's phenomenon.
- Why Chebyshev nodes work. They cluster near the ends, where the node polynomial would otherwise be largest, and their error keeps shrinking as nodes are added.
Answer the largest error is 1.92 with equally spaced nodes and 0.109 with Chebyshev nodes.
Check
A table gives 12.49 kΩ at 20 °C, and the value changes by −1.8 kΩ over the next 10 °C. By linear interpolation, what's the resistance a fraction 0.7 of the way across that step?
Write units the way you normally would: 1.5 kΩ, 1500 Ω and 0.0015 MΩ are the same answer.
Check
The quadratic through (0, 1), (1, 3), (2, 4): what's its value at x = 0.5?
Check
For the points (0, 1), (1, 3), (3, 9), what's the divided difference ?
Check
What's Chebyshev node for n = 8 (n + 1 nodes on [−1, 1])?
Check
A sine table has 256 entries per cycle, read with linear interpolation. What's the worst-case error, for amplitude 1?
Check
Why do Chebyshev nodes cluster near the ends of the interval?
Check
The quadratic through nodes 0, 1, 2 uses the Lagrange basis polynomials.
(a)
What is at x = 1.5?
(b)
And ?
Check
Data , , .
Step 1
What is the divided difference ?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What is ?
Explain why
Why can adding more equally spaced points make a polynomial interpolant worse?
The interpolant must pass through every point, and a high-degree polynomial pinned at equally spaced points has the freedom to swing between them. The error formula shows how much: it's the (n + 1)th derivative of f over (n + 1)! times the product of the distances to all the nodes. For equally spaced nodes that product is many times larger near the ends of the interval than in the middle, and for functions like Runge's the derivatives grow fast enough that the error near the ends increases with n. Chebyshev nodes crowd toward the ends exactly enough to keep the product uniformly small, so the error then shrinks as n grows.
Practice
Keep practicing
9 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.