Interpolation Error
Interpolation error is the difference f(x) − Pₙ(x) between a function and the polynomial that interpolates it at n + 1 nodes. It equals f⁽ⁿ⁺¹⁾(c)/(n + 1)! times (x − x₀)(x − x₁)⋯(x − xₙ) for some c in the interval, which gives an error bound. Adding equally spaced nodes can make the error worse (Runge’s phenomenon).
Before this lesson: Lagrange Interpolation, Newton’s Divided Differences and Lagrange Error Bound
The idea: where can the polynomial go wrong?
An interpolating polynomial is exact at its nodes, so the error is zero there. Between the nodes the error depends on two things: how sharply the function bends, measured by a high derivative, and how far x is from the nodes, measured by the product (x − x₀)(x − x₁)⋯(x − xₙ).
This mirrors the Lagrange error bound for Taylor polynomials. A Taylor polynomial matches n + 1 conditions at one point, and its remainder has the factor (x − a)ⁿ⁺¹. An interpolating polynomial matches n + 1 values at different points, so that factor spreads out into one factor for each node.
The product of factors is small near the middle of the nodes and grows quickly near and beyond the ends. That is why interpolation is most trustworthy in the middle of the data and why extrapolation, estimating outside the nodes, is risky.
Interpolation error formula and bound
Suppose f has n + 1 continuous derivatives on an interval containing the nodes x₀, x₁, …, xₙ and the point x. Then for some number c in that interval,
f(x) - P_n(x) = \dfrac{f^{(n+1)}(c)}{(n+1)!}\,(x - x_0)(x - x_1)\cdots(x - x_n)The number c is unknown, so in practice you bound the error. If M is the largest value of |f⁽ⁿ⁺¹⁾| on the interval, then
\left|f(x) - P_n(x)\right| \le \dfrac{M}{(n+1)!}\,\left|(x - x_0)(x - x_1)\cdots(x - x_n)\right|| Interpolation | Nodes | Error bound anywhere between the nodes |
|---|---|---|
| Linear | x₀ and x₁ = x₀ + h | \dfrac{M_2 h^2}{8}, where M_2 = \max|f''| |
| Quadratic, equally spaced | x₀, x₀ + h, x₀ + 2h | \dfrac{M_3 h^3}{9\sqrt{3}}, where M_3 = \max|f'''| |
The linear bound uses the fact that |(x − x₀)(x − x₁)| is largest at the midpoint, where it equals h²/4. The quadratic bound uses the largest value of |(x − x₀)(x − x₁)(x − x₂)|, which is 2h³/(3√3), and divides by 3! = 6.
Interpolation error examples
Example 1: Linear interpolation of ln x
Estimate ln 1.5 by linear interpolation between x = 1 and x = 2, bound the error, and compare with the actual error.
P_1(1.5) = \dfrac{\ln 1 + \ln 2}{2} = \dfrac{0.693147}{2} \approx 0.346574At the midpoint, linear interpolation is the average of the two values.
f''(x) = -\dfrac{1}{x^2}Differentiate ln x twice (see derivatives of logarithmic functions).
M = \max_{1 \le x \le 2} \left|-\dfrac{1}{x^2}\right| = 11/x² is largest at the left end, x = 1.
\left|(1.5 - 1)(1.5 - 2)\right| = (0.5)(0.5) = 0.25
Evaluate the node product at x = 1.5.
\text{bound} = \dfrac{1}{2!}(0.25) = 0.125Divide M times the product by (n + 1)! = 2.
\ln 1.5 - P_1(1.5) \approx 0.405465 - 0.346574 = 0.058891
Find the actual error.
Answer: P₁(1.5) ≈ 0.346574, with an error bound of 0.125; the actual error, about 0.0589, is within the bound. Using the smallest value of |f″|, which is 1/4 at x = 2, the same formula shows the error is at least 0.03125.
Example 2: Quadratic interpolation of eˣ
Use quadratic interpolation of f(x) = eˣ at the nodes 0, 0.5 and 1 to estimate e^0.25, and bound the error.
f[0, 0.5] = \dfrac{1.648721 - 1}{0.5} \approx 1.297443Build the divided differences, with e^0.5 ≈ 1.648721 and e ≈ 2.718282.
f[0.5, 1] = \dfrac{2.718282 - 1.648721}{0.5} \approx 2.139121Second first-column entry.
f[0, 0.5, 1] = \dfrac{2.139121 - 1.297443}{1 - 0} \approx 0.841678Second divided difference.
P_2(0.25) = 1 + 1.297443(0.25) + 0.841678(0.25)(-0.25)
Substitute x = 0.25 into the Newton form.
P_2(0.25) \approx 1 + 0.324361 - 0.052605 = 1.271756
Multiply, then add.
\left|(0.25)(0.25 - 0.5)(0.25 - 1)\right| = (0.25)(0.25)(0.75) = 0.046875
Node product at x = 0.25.
M = \max_{0 \le x \le 1} e^x = e \approx 2.718282f‴(x) = eˣ is largest at x = 1.
\text{bound} = \dfrac{2.718282}{3!}(0.046875) \approx 0.021237Divide by 3! = 6 and multiply by the product.
e^{0.25} - P_2(0.25) \approx 1.284025 - 1.271756 = 0.012269Find the actual error.
Answer: e^0.25 ≈ 1.271756, with an error bound of about 0.0212; the actual error is about 0.0123. Since f‴ is at least 1 on [0, 1], the error is also at least 0.046875/6 ≈ 0.0078.
Example 3: Choosing a table spacing (word problem)
A calculator library stores sin x at equally spaced points and uses linear interpolation between them. How small must the spacing h be to guarantee an error of at most 10⁻⁶?
|f''(x)| = |-\sin x| \le 1
The second derivative of sin x is −sin x, so M = 1.
\dfrac{M h^2}{8} \le 10^{-6}Use the linear interpolation bound.
h^2 \le 8 \times 10^{-6}Multiply both sides by 8 (M = 1).
h \le \sqrt{8 \times 10^{-6}} \approx 0.002828Take the positive square root.
Answer: a spacing of about 0.0028 or less guarantees an error of at most 10⁻⁶. Over one period of length 2π, that is about 2π/0.002828 ≈ 2,222 intervals.
Example 4: A bound for equally spaced quadratic interpolation
Bound the error of quadratic interpolation of cos x on the nodes 0, 0.1 and 0.2, anywhere in [0, 0.2].
f'''(x) = \sin x
Differentiate cos x three times: −sin x, −cos x, sin x.
M = \max_{0 \le x \le 0.2} |\sin x| = \sin 0.2 \approx 0.198669sin x is increasing on [0, 0.2].
\max\left|x(x - 0.1)(x - 0.2)\right| = \dfrac{2(0.1)^3}{3\sqrt{3}} \approx 0.000385Use the largest node product for equally spaced nodes with h = 0.1.
\text{bound} = \dfrac{0.198669}{6}(0.000385) \approx 1.27 \times 10^{-5}Divide by 3! and multiply.
Answer: the error is at most about 1.27 × 10⁻⁵ everywhere in [0, 0.2]. A computer check shows the actual largest error is about 7.3 × 10⁻⁶, so the bound is honest but not far off.
Example 5: Runge’s phenomenon
Interpolate f(x) = 1/(1 + 25x²) at the five equally spaced nodes −1, −0.5, 0, 0.5 and 1, and compare P₄(0.75) with f(0.75).
f(0) = 1,\quad f(\pm 0.5) = \dfrac{1}{1 + 6.25} = \dfrac{4}{29},\quad f(\pm 1) = \dfrac{1}{26}Evaluate f at the nodes.
P_4(x) = 1 + ax^2 + bx^4
f is even and the nodes are symmetric, so the unique interpolating polynomial is even with constant term f(0) = 1.
\dfrac{a}{4} + \dfrac{b}{16} = \dfrac{4}{29} - 1 = -\dfrac{25}{29}Require P₄(0.5) = 4/29 and subtract 1.
a + b = \dfrac{1}{26} - 1 = -\dfrac{25}{26}Require P₄(1) = 1/26 and subtract 1.
a + \dfrac{b}{4} = -\dfrac{100}{29}Multiply the first equation by 4.
\dfrac{3b}{4} = -\dfrac{25}{26} + \dfrac{100}{29} = \dfrac{1875}{754}Subtract this from a + b = −25/26 (see elimination method).
b = \dfrac{1875}{754} \cdot \dfrac{4}{3} = \dfrac{1250}{377} \approx 3.315650Multiply both sides by 4/3.
a = -\dfrac{25}{26} - \dfrac{1250}{377} = -\dfrac{3225}{754} \approx -4.277188Substitute into a + b = −25/26.
P_4(0.75) \approx 1 - 4.277188(0.5625) + 3.315650(0.31640625)
Substitute x = 0.75: x² = 0.5625 and x⁴ = 0.31640625.
P_4(0.75) \approx 1 - 2.405918 + 1.049092 = -0.356826
Multiply, then add.
f(0.75) = \dfrac{1}{1 + 14.0625} \approx 0.066390Evaluate f directly.
Answer: P₄(0.75) ≈ −0.3568, but f(0.75) ≈ 0.0664, an error of about 0.42, even though f is never negative. Using more equally spaced nodes makes it worse: with 11 nodes the largest error, near x = ±0.94, is about 1.92, and with 21 nodes it is about 59.8. This growth near the ends is Runge’s phenomenon.
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Using the nth derivative | Bounding linear interpolation with max |f′| | Use derivative number n + 1: f″ for 2 nodes, f‴ for 3 nodes. |
| Forgetting the factorial | \text{bound} = M\left|(x - x_0)(x - x_1)\right| | Divide by (n + 1)!: 2 for linear, 6 for quadratic. |
| Using f at the nodes for M | Taking M = |f″(x₀)| only | M is the largest value of |f⁽ⁿ⁺¹⁾| on the whole interval. |
| Leaving out a node factor | Using (x − x₀)(x − x₁) with three nodes | Include one factor for every node. |
| Assuming more nodes always help | Raising the degree with equally spaced nodes on 1/(1 + 25x²) | The bound needs high derivatives that may grow quickly; use Chebyshev nodes or splines. |
| Extrapolating far outside the nodes | Using a quadratic through x = 0, 1, 2 to predict x = 10 | The node product grows fast outside the data; the bound becomes huge. |
Related methods
Chebyshev nodes
Instead of equally spaced nodes on [−1, 1], use xₖ = cos((2k + 1)π/(2n + 2)) for k = 0, 1, …, n. They cluster near the ends, where the node product is largest, and they make the largest value of |(x − x₀)⋯(x − xₙ)| as small as possible, namely 1/2ⁿ. For f(x) = 1/(1 + 25x²), 11 Chebyshev nodes give a largest error of about 0.11, compared with about 1.92 for 11 equally spaced nodes.
Piecewise interpolation
Another fix is to keep the degree low and split the interval: use a separate low-degree polynomial on each small piece. Linear pieces give the h²/8 bound above. Cubic Splines, the next lesson, join cubic pieces so the curve is also smooth where the pieces meet.
Taylor remainder vs. interpolation error
| Approximation | Error term |
|---|---|
| Taylor polynomial of degree n at a | \dfrac{f^{(n+1)}(c)}{(n+1)!}(x - a)^{n+1} |
| Interpolating polynomial on n + 1 nodes | \dfrac{f^{(n+1)}(c)}{(n+1)!}(x - x_0)\cdots(x - x_n) |
Practice problems
- Linear interpolation of f(x) = x³ between x = 1 and x = 2 is used at x = 1.5. Find the error bound and the actual error.
- Estimate √5 by linear interpolation between x = 4 and x = 9, bound the error, and compare with the actual error.
- Write the error formula for quadratic interpolation with nodes 1, 2 and 4.
- Find the largest value of |(x − 2)(x − 5)| on [2, 5].
- A table of eˣ on [0, 1] has spacing h = 0.1. Bound the error of linear interpolation anywhere in the table.
- What spacing h guarantees that linear interpolation of ln x on [1, 2] has an error of at most 10⁻⁴?
- Bound the error of quadratic interpolation of sin x with nodes 0, π/4 and π/2 at x = π/8.
- Explain why quadratic interpolation of f(x) = 3x² − 5x + 2 at any three different nodes has no error.
- Linear interpolation of eˣ between 0 and 1 is used at x = 0.5. Find lower and upper bounds on the error and check them against the actual error.
- A data logger records temperature every 10 minutes. The temperature’s second derivative is at most 0.02 °C per minute squared in size. Bound the error of linear interpolation between readings.
Show answers
1.
f''(x) = 6x,\quad M = 6(2) = 12
The second derivative is largest at x = 2.
\text{bound} = \dfrac{12}{2}\left|(0.5)(-0.5)\right| = 6(0.25) = 1.5Divide by 2! and multiply by the node product at 1.5.
P_1(1.5) = \dfrac{1 + 8}{2} = 4.5,\quad f(1.5) = 3.375Find the estimate and the true value.
4.5 - 3.375 = 1.125
Actual error.
Answer: bound 1.5; actual error 1.125
2.
P_1(5) = 2 + \dfrac{3 - 2}{9 - 4}(5 - 4) = 2.2Line through (4, 2) and (9, 3).
f''(x) = -\dfrac{1}{4}x^{-3/2},\quad M = \dfrac{1}{4 \cdot 8} = \dfrac{1}{32}|f″| is largest at x = 4, where x^(3/2) = 8.
\text{bound} = \dfrac{1}{32 \cdot 2}\left|(5 - 4)(5 - 9)\right| = \dfrac{4}{64} = 0.0625Divide by 2! and multiply by the node product.
\left|2.236068 - 2.2\right| = 0.036068
Actual error, with √5 ≈ 2.236068.
Answer: estimate 2.2, bound 0.0625, actual error about 0.0361
3.
f(x) - P_2(x) = \dfrac{f'''(c)}{3!}(x - 1)(x - 2)(x - 4)Three nodes: use f‴ and 3! = 6.
Answer: f(x) − P₂(x) = (f‴(c)/6)(x − 1)(x − 2)(x − 4) for some c between the smallest and largest of 1, 4 and x
4.
x = \dfrac{2 + 5}{2} = 3.5The largest value is at the midpoint.
\left|(3.5 - 2)(3.5 - 5)\right| = (1.5)(1.5) = 2.25
Evaluate; this equals (5 − 2)²/4.
Answer: 2.25
5.
M = \max_{0 \le x \le 1} e^x = e \approx 2.718282f″(x) = eˣ is largest at x = 1.
\dfrac{M h^2}{8} = \dfrac{2.718282(0.01)}{8} \approx 0.003398Use the linear bound with h² = 0.01.
Answer: at most about 0.0034
6.
M = \max_{1 \le x \le 2} \dfrac{1}{x^2} = 1|f″(x)| = 1/x² is largest at x = 1.
\dfrac{h^2}{8} \le 10^{-4}Set the linear bound at most 10⁻⁴.
h^2 \le 8 \times 10^{-4}Multiply both sides by 8.
h \le \sqrt{8 \times 10^{-4}} \approx 0.028284Take the positive square root.
Answer: h ≤ about 0.0283
7.
M = \max|-\cos x| = 1
f‴(x) = −cos x, and |cos x| ≤ 1.
\left|\dfrac{\pi}{8}\left(\dfrac{\pi}{8} - \dfrac{\pi}{4}\right)\left(\dfrac{\pi}{8} - \dfrac{\pi}{2}\right)\right| = \dfrac{\pi}{8} \cdot \dfrac{\pi}{8} \cdot \dfrac{3\pi}{8} = \dfrac{3\pi^3}{512} \approx 0.181677Node product at x = π/8.
\text{bound} = \dfrac{0.181677}{6} \approx 0.030280Divide by 3! = 6.
Answer: at most about 0.0303
8.
f'''(x) = 0
The third derivative of a quadratic is zero.
f(x) - P_2(x) = \dfrac{0}{3!}(x - x_0)(x - x_1)(x - x_2) = 0The error formula gives zero.
Answer: the error is 0, so P₂ equals f; this also follows because only one polynomial of degree 2 or less passes through three points
9.
\left|(0.5)(0.5 - 1)\right| = 0.25
Node product at x = 0.5.
\dfrac{1}{2}(0.25) = 0.125,\quad \dfrac{2.718282}{2}(0.25) \approx 0.339785f″ = eˣ is between 1 and e on [0, 1].
P_1(0.5) = \dfrac{1 + 2.718282}{2} = 1.859141Average of e⁰ and e¹.
1.859141 - 1.648721 = 0.210420
Actual error, with e^0.5 ≈ 1.648721.
Answer: the error is between 0.125 and about 0.340; the actual error is about 0.2104
10.
\dfrac{M h^2}{8} = \dfrac{0.02(10)^2}{8}Use the linear bound with M = 0.02 and h = 10 minutes.
= \dfrac{2}{8} = 0.25Simplify.
Answer: at most 0.25 °C
Interpolation error FAQ
What is the interpolation error formula?
For a polynomial Pₙ that interpolates f at n + 1 nodes, f(x) − Pₙ(x) = f⁽ⁿ⁺¹⁾(c)/(n + 1)! · (x − x₀)(x − x₁)⋯(x − xₙ) for some c in the interval containing the nodes and x.
What is Runge’s phenomenon?
It is the large oscillation near the ends of an interval when a smooth function is interpolated at many equally spaced nodes. The classic example is 1/(1 + 25x²) on [−1, 1], where the largest error grows as the degree goes up.
Does using more data points always improve interpolation?
No. With equally spaced nodes the error can grow as more points are added, because high derivatives of some functions grow very fast. Chebyshev nodes or piecewise methods such as splines avoid this.
What is the error bound for linear interpolation?
For two nodes h apart, the error between them is at most M h²/8, where M is the largest value of |f″| on the interval.
Summary
- The interpolation error is f⁽ⁿ⁺¹⁾(c)/(n + 1)! times the node product (x − x₀)⋯(x − xₙ).
- Bound it with M = max |f⁽ⁿ⁺¹⁾| on the interval; linear interpolation gives M h²/8.
- The error is zero at the nodes, smallest near the middle and largest near the ends and outside the data.
- With equally spaced nodes, a higher degree can make the error worse (Runge’s phenomenon).
- Chebyshev nodes or piecewise polynomials keep the error under control.
Previous lesson: Newton’s Divided Differences
Next lesson: Cubic Splines
Back to the Numerical Methods Index