From an Error Goal to a Construction
The counterexamples in the previous tutorial showed how a shared constraint can prevent approximation. A density proof takes the opposite approach: for an arbitrary target and an arbitrary positive error tolerance, it constructs a candidate whose error is smaller than that tolerance everywhere on the domain. On a compact interval, a useful way to do this is to sample the target on a fine mesh and connect the sampled values by straight line segments.
This method turns continuity into a global error estimate. Uniform continuity says that values of the target at nearby points are close. A mesh ensures that every point is near the sample points used to define its interpolant. The key proof step is to show that the interpolated value is a weighted average of nearby sampled values, so it cannot drift far from the target value at that point.
Uniform Mesh Interpolation
Let \(a<b\), let \(f\in C[a,b]\), and choose a positive integer \(N\). Divide the interval into \(N\) equal subintervals with nodes
Define \(I_Nf\) to agree with \(f\) at each node and to be linear on every subinterval \([x_i,x_{i+1}]\). More explicitly, if \(x=x_i+th\) for \(0\leq t\leq1\), then
The coefficients \(1-t\) and \(t\) are nonnegative and sum to one. Thus the interpolated value lies between the two sampled values. To measure how close those values must be, define the modulus of continuity of \(f\) by
The supremum is finite because \(f\) is bounded on the compact interval. Uniform continuity of \(f\) means precisely that \(\omega_f(\delta)\) tends to zero as \(\delta\) tends to zero from above. Indeed, for any \(\varepsilon>0\), uniform continuity supplies a \(\delta_0>0\) such that \(|f(u)-f(v)|<\varepsilon\) whenever \(|u-v|<\delta_0\). If \(0\leq\delta<\delta_0\), every pair in the supremum defining \(\omega_f(\delta)\) satisfies this inequality, so \(\omega_f(\delta)\leq\varepsilon\). The converse follows directly from the definition of the supremum.
Proof. Fix \(x\in[a,b]\). If \(x\) is a mesh node, then \(I_Nf(x)=f(x)\), so the error is zero. Otherwise, \(x\) lies in some subinterval \([x_i,x_{i+1}]\) and can be written \(x=x_i+th\) with \(0<t<1\). By the definition of the interpolant and the triangle inequality,
Both distances \(|x-x_i|\) and \(|x-x_{i+1}|\) are at most \(h\). Therefore each difference of function values on the right is at most \(\omega_f(h)\). Since \(1-t\) and \(t\) sum to one, the right-hand side is at most \(\omega_f(h)\). The same bound holds at the mesh nodes, so it holds for every \(x\in[a,b]\). Taking the supremum over \(x\) proves the estimate. \(\square\)
The Density Proof
Proof. Let \(f\in C[a,b]\) and let \(\varepsilon>0\). By the Heine–Cantor Theorem, \(f\) is uniformly continuous on \([a,b]\). Choose \(\eta>0\) such that \(|f(u)-f(v)|<\varepsilon\) whenever \(u,v\in[a,b]\) and \(|u-v|<\eta\). Choose a positive integer \(N\) large enough that \(h=(b-a)/N<\eta\). The interpolation estimate gives
In fact, the continuous function \(|f-I_Nf|\) attains its maximum on the compact interval \([a,b]\) at some point \(x^*\). If \(x^*\) is a mesh node, the error is zero; otherwise, both endpoint differences in the interpolation estimate are less than \(\varepsilon\), since their distances from \(x^*\) are at most \(h<\eta\), and their nonnegative weights sum to one. Thus \(\|f-I_Nf\|_{\infty,[a,b]}<\varepsilon\). The function \(I_Nf\) is continuous and piecewise linear by construction. Thus, for every target \(f\) and every positive tolerance, there is a continuous piecewise linear function within that tolerance. This is exactly density in the supremum norm. \(\square\)
The proof follows a reusable pattern: choose a mesh fine enough to control variation of the target, define a candidate using only nearby data, and prove that the construction preserves the error bound throughout each mesh cell. The uniform interpolation estimate makes the central step explicit; the density theorem then follows by choosing the mesh width sufficiently small.
Worked Examples: Choosing and Using a Mesh
Worked Example: An Exact Error for Interpolating the Square
Consider \(f(x)=x^2\) on \([0,1]\), with the uniform mesh of \(N\) subintervals. Let \(h=1/N\), and consider one cell \([u,u+h]\). At a point \(x=u+th\), where \(0\leq t\leq1\), the interpolant is
Since \(x=u+th\), direct expansion gives
This error is nonnegative and satisfies \(t(1-t)\leq1/4\), because \((t-\tfrac12)^2\geq0\). Equality holds at the midpoint \(t=1/2\) of each cell. Consequently, the maximum error on every cell, and hence on the entire interval, is \(h^2/4\). For \(N=4\), the mesh width is \(1/4\), so
Here a direct calculation gives a sharper value than the general modulus-of-continuity estimate. The general estimate is a flexible guarantee; when the target has a simple formula, additional algebra may improve it.
Worked Example: A Lipschitz Bound for Cosine
Let \(f(x)=\cos x\) on \([0,\pi/2]\), and interpolate at the \(21\) equally spaced nodes \(x_i=i\pi/40\), for \(i=0,\ldots,20\). The mesh width is \(h=\pi/40\). The Mean Value Theorem and the bound \(|-\sin x|\leq1\) give, for any \(u,v\in[0,\pi/2]\),
Thus \(f\) is Lipschitz with constant \(1\). At \(x=x_i+th\), the interpolation error estimate can use the distances to the two endpoints separately:
The last inequality follows from \(t(1-t)\leq1/4\). Therefore this particular interpolant satisfies
This calculation illustrates how a known rate of change can turn a qualitative density argument into a numerical error guarantee. For a Lipschitz target with constant \(L\), the same reasoning gives an error at most \(Lh/2\) on a uniform mesh.
Proof. On a cell, write \(x=x_i+th\). The endpoint distances are \(th\) and \((1-t)h\). Applying the Lipschitz inequality to each term in the interpolation estimate gives an error at most \((1-t)Lth+tL(1-t)h=2Lt(1-t)h\). Since \(2t(1-t)\leq1/2\), this is at most \(Lh/2\). At nodes the error is zero, so the bound holds throughout the interval. \(\square\)
Worked Example: A Mesh That Captures a Corner
Take \(f(x)=|x-\tfrac13|\) on \([0,1]\), and use \(N=3\). The mesh nodes are \(0,\tfrac13,\tfrac23,1\), so the corner at \(x=\tfrac13\) is a node. On \([0,\tfrac13]\), the function equals \(\tfrac13-x\), which is linear. On \([\tfrac13,1]\), it equals \(x-\tfrac13\), which is also linear. The interpolant agrees with \(f\) at the nodes and is linear on each cell; on each cell it therefore agrees with \(f\) everywhere. Hence
A mesh need not always be made very fine to work well. If its nodes capture the points where a target changes its linear formula, interpolation may be exact. This example also shows why the general density proof does not claim that every target needs the same mesh size.
What the Strategy Does—and Does Not—Guarantee
A density proof must control the error at every point, not just at the mesh nodes. Matching the target at finitely many points is not by itself a uniform approximation argument. The interpolation estimate supplies the missing step: it relates the value between nodes to nearby target values and bounds the error across the whole interval.
The compact interval matters because continuity there implies uniform continuity, by the Heine–Cantor Theorem. On a noncompact domain, continuity alone need not provide one mesh scale that controls variation everywhere. The argument also proves density of piecewise linear functions, not density of polynomials; the latter was established earlier by polynomial approximation theorems. Different candidate families require different constructions, even when the overall proof architecture is similar.
For a prescribed error tolerance, the practical choices are clear. First obtain a scale on which the target varies little. Then choose a mesh whose cell width is smaller than that scale. If a Lipschitz constant or another quantitative regularity estimate is available, use it to select the mesh directly. If the target has special structure, as in the corner example, place nodes strategically and check whether the construction is exact.
Check Your Understanding
Use the interpolation estimates and constructions to answer the following questions.
- Why does uniform continuity allow the mesh width to be chosen so that \(\omega_f(h)\) is smaller than a prescribed positive tolerance?
- On a mesh cell, why is the interpolated value a weighted average of the two endpoint values?
- For a Lipschitz function with constant \(L\), what uniform error bound follows from a mesh of width \(h\)?
- Why can interpolation of \(x^2\) on a uniform cell have its maximum error at the cell midpoint?
- What feature of \(|x-\tfrac13|\) makes the three-subinterval mesh produce zero error?