Lagrange interpolation and its error
Statement
Let \(x_0, x_1, \ldots, x_n\) be \(n+1\) distinct real nodes lying in an interval \([a,b]\), and let \(y_0, y_1, \ldots, y_n \in \mathbb{R}\) be prescribed values (typically \(y_i = f(x_i)\) for some function \(f\)). Then there exists a unique polynomial \(p \in \mathbb{R}[x]\) of degree \(\le n\) such that \(p(x_i) = y_i\) for \(i = 0, 1, \ldots, n\); it is given explicitly by the Lagrange interpolation formula \(p(x) = \sum_{i=0}^{n} y_i L_i(x)\), where \(L_i(x) = \prod_{j=0, j \ne i}^{n} \frac{x - x_j}{x_i - x_j}\). If in addition \(y_i = f(x_i)\) for a function \(f\) that is \(n+1\) times differentiable on an interval \(I \supseteq \{x_0,\ldots,x_n,x\}\), then for every \(x \in I\) there exists \(\xi = \xi(x)\) lying strictly between the smallest and largest of \(x_0,\ldots,x_n,x\) such that \(f(x) - p(x) = \frac{f^{(n+1)}(\xi)}{(n+1)!} \prod_{i=0}^{n} (x - x_i)\).
Why it matters
Interpolation is the basic device by which numerical analysis replaces an inconvenient function (given only by samples, or expensive to evaluate) with a polynomial that can be differentiated, integrated, or evaluated cheaply. Lagrange's formula is the cleanest possible closed form for the interpolant and it settles existence and uniqueness in one stroke; almost every other interpolation scheme (Newton's divided differences, Hermite interpolation, spline theory, quadrature rule derivations) either derives from it or must reprove the same uniqueness fact.
The error formula is what turns interpolation from a bookkeeping exercise into a numerical tool: it tells you, in terms of a derivative bound and the geometry of the nodes, exactly how far the interpolant can be trusted. It is the ancestor of the error analysis behind Newton–Cotes quadrature, the trapezoidal and Simpson's rules, and finite-difference formulas for derivatives.
Hypotheses
Proof
Result
Reading. The unique degree-\(\le n\) polynomial through \(n+1\) distinct data points can be written down explicitly as a weighted sum of the basis polynomials \(L_i\), each of which is \(1\) at its own node and \(0\) at every other node. The gap between the true function and this polynomial, at any point \(x\), is controlled by the \((n+1)\)-th derivative of \(f\) evaluated at some unknown but existent point \(\xi\), multiplied by the "node polynomial" \(\prod(x-x_i)\), which vanishes at the nodes and grows the further \(x\) is from them.
Scope. Existence and uniqueness require only that the nodes be distinct and hold over any field (in particular \(\mathbb{C}\), or a finite field, with no differentiability needed). The error formula requires \(f \in C^{n+1}\) on an interval containing all nodes and \(x\); it is a real-variable, Rolle-based result and does not extend verbatim to complex \(f\) (the complex analogue uses contour integration, e.g. via the Hermite/Cauchy integral remainder, and is a genuinely different proof).
Corollaries & converses
- If \(f\) is itself a polynomial of degree \(\le n\), then \(f^{(n+1)}\equiv 0\), so the error formula gives \(f(x)-p(x)=0\) for all \(x\): Lagrange interpolation reproduces polynomials of degree \(\le n\) exactly. This is the standard sanity check on any interpolation-based numerical scheme (exactness degree).
- If \(|f^{(n+1)}(t)| \le M\) for all \(t\) in the relevant interval, then \(|f(x)-p(x)| \le \dfrac{M}{(n+1)!}\left|\prod_{i=0}^n (x-x_i)\right|\), a genuinely usable a priori error bound not requiring knowledge of \(\xi\).
- Converse direction: knowing only that \(p\) interpolates \(f\) at \(n+1\) points does not let you recover \(f^{(n+1)}\) or deduce smoothness of \(f\) beyond the nodes — the theorem is one-directional (smoothness \(\Rightarrow\) error formula), and no converse statement of the form "a small interpolation error at these nodes implies \(f\) is smooth" holds; one can build a wildly non-smooth \(f\) agreeing with a smooth \(p\) at finitely many points.
- Taking \(n=0\) recovers the Mean Value Theorem in disguise: \(p(x)=f(x_0)\) (constant), and the formula reads \(f(x)-f(x_0) = f'(\xi)(x-x_0)\), which is exactly the MVT. The interpolation error theorem is thus a genuine generalisation of the MVT.
Fails without
- Distinct nodes dropped: nodes \(x_0=x_1=0\), \(x_2=1\) with values \(y_0=0, y_1=1, y_2=2\). The two conditions at \(x=0\) are contradictory (\(p(0)\) cannot equal both \(0\) and \(1\)); no degree-\(\le 2\) interpolant exists at all, and the Lagrange formula's denominators \(x_i-x_j\) divide by zero.
- Differentiability dropped (error formula): take \(n=1\), nodes \(x_0=-1,x_1=1\), and \(f(x)=|x|\), which is continuous but not differentiable at \(0\), so certainly not \(C^2\) on \([-1,1]\). The linear interpolant is \(p(x)=1\) (since \(f(-1)=f(1)=1\)); at \(x=0\), \(f(0)-p(0) = 0-1=-1\). The claimed formula would require \(-1 = \frac{f''(\xi)}{2}(0-(-1))(0-1) = -\frac{f''(\xi)}{2}\), i.e. \(f''(\xi)=2\) for some \(\xi\in(-1,1)\) — but \(f''(t)=0\) wherever it exists (\(t\ne0\)) and does not exist at \(t=0\); no such \(\xi\) exists, and the formula's guarantee simply fails, exactly as the hypothesis warns.
- Degree bound dropped: nodes \(0,1\) with values \(0,1\). Both \(p_1(x)=x\) and \(p_2(x)=x+x(x-1)(x-2)\) agree with the data at \(x=0,1\), but \(p_1\ne p_2\) (they disagree at \(x=3\)); uniqueness is meaningless once the degree cap \(\le n\) is removed, since infinitely many higher-degree polynomials pass through any finite point set.
Common errors
- Believing the error bound \(\frac{M}{(n+1)!}\max|\prod(x-x_i)|\) applies uniformly well as \(n\) grows — ignoring that \(M=\sup|f^{(n+1)}|\) can itself grow faster than \((n+1)!\) shrinks (Runge's phenomenon), so blindly adding more equally-spaced nodes can increase, not decrease, the actual error.
- Quoting the error formula with a specific numerical value for \(\xi\) (e.g. "\(\xi\) is the midpoint") — \(\xi\) is merely known to exist somewhere in the spanning interval; its location is generally uncomputable without already knowing \(f(x)\) exactly.
- Applying the formula for \(x\) outside the convex hull of the nodes (extrapolation) while still using a derivative bound \(M\) estimated only on the node interval — the theorem requires \(f\in C^{n+1}\) on an interval containing \(x\) too, and \(\prod(x-x_i)\) can be huge outside the node span.
- Confusing the interpolating polynomial \(p\) with a Taylor polynomial of \(f\) — they coincide only in the degenerate limit where all nodes merge to a single point; for distinct nodes the two constructions and their error terms are different objects (compare the Lagrange remainder above with the Taylor/Lagrange remainder of a Taylor series, which uses only one base point).
- Forgetting that the Lagrange basis polynomials \(L_i\) depend on the full node set, so recomputing them from scratch is required whenever a single node is added or moved — an efficiency error, not a correctness one, but a very common practical mistake motivating Newton's divided-difference form.
Discussion
The formula is named for Joseph-Louis Lagrange, who published it in 1795, though it was known earlier to Edward Waring (1779) and to Euler; the underlying idea — building a basis of "indicator" functions equal to \(1\) at one node and \(0\) at the rest — recurs throughout mathematics, from finite-element shape functions to the Chinese Remainder Theorem (which is the same construction over \(\mathbb{Z}/m\mathbb{Z}\) instead of \(\mathbb{R}[x]\)).
Practically, the Lagrange form is elegant for theory but poor for computation: adding one new node forces recomputation of every \(L_i\) from scratch, and the formula is numerically less stable than Newton's divided-difference representation of the very same unique polynomial. The theorem's true computational content is uniqueness — different algorithms (Lagrange, Newton, Neville) construct the identical polynomial by Step 4–5 of the proof, so a numerically better algorithm can always be substituted without changing the answer.
The error formula is the ancestor of an entire family of remainder theorems obtained by the same "insert an auxiliary function and apply Rolle repeatedly" technique: the Lagrange form of the Taylor remainder, the error term in linear/quadratic interpolation used to derive the trapezoidal and Simpson quadrature errors, and error bounds for finite-difference approximations to derivatives all reuse this exact proof skeleton with a different auxiliary function \(\varphi\).
A subtlety often missed at degree level: the existence of \(\xi\) is non-constructive and the map \(x\mapsto \xi(x)\) need not be continuous or even measurable in general; it is merely guaranteed to exist pointwise by Rolle's theorem for each fixed \(x\). This is why the error formula is used almost exclusively through the derived bound \(|f(x)-p(x)|\le \frac{M}{(n+1)!}|\prod(x-x_i)|\) rather than through \(\xi\) itself — the bound only needs the existence, not any regularity, of \(\xi\).
Common misconception: that Lagrange interpolation with more nodes is always more accurate. Runge's phenomenon (large oscillations for high-degree interpolation on equally spaced nodes, e.g. for \(f(x)=\frac{1}{1+25x^2}\) on \([-1,1]\)) shows the error can diverge as \(n\to\infty\) even for a smooth \(f\), because \(\sup|f^{(n+1)}|\) or the node polynomial's maximum can outpace \(\frac{1}{(n+1)!}\); the fix is node clustering (e.g. Chebyshev nodes), not merely more nodes.
Worked examples
Reading. Check: \(p(0)=1,p(1)=2,p(2)=5\) — matches the data exactly, and indeed the data was generated by \(f(x)=x^2+1\), so the quadratic interpolant recovers \(f\) exactly, consistent with the exactness corollary (\(f^{(3)}\equiv0\) here).
Reading. The true value is \(\ln 1.5 \approx 0.405465\), so the actual error is \(|0.405465-0.346574|\approx0.0589\), comfortably inside the guaranteed bound of \(0.125\) — the bound is an upper limit, not a tight estimate, exactly as the theorem promises.
Problems
- Find the Lagrange interpolating polynomial through \((0,1), (1,0), (2,1)\).
Solution
\(L_0(x)=\frac{(x-1)(x-2)}{2}\), \(L_1(x)=-x(x-2)\), \(L_2(x)=\frac{x(x-1)}{2}\) (same nodes as Worked Example 1). Then \(p(x) = 1\cdot L_0(x)+0\cdot L_1(x)+1\cdot L_2(x) = \frac{(x-1)(x-2)}{2}+\frac{x(x-1)}{2} = \frac{(x-1)}{2}\left[(x-2)+x\right] = \frac{(x-1)(2x-2)}{2}=(x-1)^2\). Check: \(p(0)=1,p(1)=0,p(2)=1\). Correct. - Prove directly (without citing the general theorem) that two distinct polynomials of degree \(\le 1\) cannot both pass through two distinct given points.
Solution
Let \(p(x)=ax+b\), \(q(x)=cx+d\) both satisfy \(p(x_0)=q(x_0)=y_0\), \(p(x_1)=q(x_1)=y_1\) with \(x_0\ne x_1\). Then \(r=p-q=(a-c)x+(b-d)\) satisfies \(r(x_0)=r(x_1)=0\). If \(a\ne c\), \(r\) is a nonconstant linear function with a unique root, so it cannot vanish at two distinct points \(x_0\ne x_1\) — contradiction. Hence \(a=c\); substituting into \(r(x_0)=0\) gives \(b=d\). So \(p\equiv q\). This is the \(n=1\) case of Proof Steps 4–5. - Let \(f(x)=e^x\) be interpolated at \(x_0=0,x_1=1\) by a linear polynomial \(p\). Give an upper bound for \(|f(x)-p(x)|\) on \([0,1]\), and state at which \(x\in[0,1]\) the bound \(\left|\frac{(x-0)(x-1)}{2}\right|\) is largest.
Solution
Here \(n=1\), \(f''(t)=e^t\), and on \([0,1]\), \(\sup|f''|=e^1=e\) (since \(e^t\) is increasing). The error bound is \(|f(x)-p(x)| \le \frac{e}{2}|x(x-1)|\). The function \(g(x)=|x(x-1)|=x-x^2\) on \([0,1]\) (nonnegative there since roots are \(0,1\)) is maximised where \(g'(x)=1-2x=0\), i.e. \(x=1/2\), giving \(g(1/2)=1/4\). So the bound is largest, \(\frac{e}{8}\approx0.340\), at the midpoint \(x=1/2\) — errors from linear interpolation are typically worst near the middle of the interval, not at the endpoints (where the bound is exactly \(0\)). - Explain why, for \(n=0\) (a single node \(x_0\), constant interpolant \(p(x)=f(x_0)\)), the Lagrange error formula reduces exactly to the Mean Value Theorem, and verify this reduction algebraically.
Solution
With \(n=0\): \(p(x)=f(x_0)\) constant, \(w(x)=(x-x_0)\), and the error formula gives \(f(x)-f(x_0) = \frac{f'(\xi)}{1!}(x-x_0)=f'(\xi)(x-x_0)\) for some \(\xi\) strictly between \(x_0\) and \(x\). Rearranged, \(f'(\xi)=\frac{f(x)-f(x_0)}{x-x_0}\), which is precisely the conclusion of the Mean Value Theorem applied to \(f\) on the interval between \(x_0\) and \(x\). The general proof (Steps 6–12) with \(n=0\) collapses to: \(\varphi(t)=f(t)-f(x_0)-K(t-x_0)\), \(\varphi(x_0)=\varphi(x)=0\), one application of Rolle's theorem gives \(\varphi'(\xi)=0\), i.e. \(f'(\xi)=K\) — exactly the standard MVT proof. - Nodes \(x_0=-1,x_1=0,x_2=1\) interpolate \(f(x)=\cos x\). Using the error formula, find a bound on \(|f(x)-p(x)|\) valid for all \(x\in[-1,1]\), and comment on whether the bound is small enough to be useful (compare to the trivial bound \(|f(x)-p(x)|\le|f(x)|+|p(x)|\), not asked to compute, just to reflect on order of magnitude).
Solution
Here \(n=2\), so we need \(f^{(3)}(t)=\sin t\), and \(\sup_{t\in[-1,1]}|\sin t| = \sin 1 \approx 0.8415 =: M\) (since \(|\sin t|\) is increasing on \([0,1]\) and odd, its max magnitude on \([-1,1]\) is at the endpoints). The node polynomial is \(w(x)=(x+1)x(x-1)=x^3-x\); on \([-1,1]\), \(\max|w(x)|\) occurs (by calculus, \(w'(x)=3x^2-1=0 \Rightarrow x=\pm1/\sqrt3\)) at \(x=1/\sqrt3\), giving \(|w(1/\sqrt3)| = \left|\frac{1}{3\sqrt3}-\frac{1}{\sqrt3}\right| = \frac{2}{3\sqrt3}\approx0.3849\). So the bound is \(|f(x)-p(x)| \le \frac{0.8415}{3!}\times0.3849 \approx \frac{0.8415}{6}\times0.3849\approx0.0540\). This is a useful bound (much smaller than \(|\cos x|\le1\) itself), showing quadratic interpolation of \(\cos x\) on three equally spaced points in \([-1,1]\) already achieves roughly two-decimal-place accuracy.