Skip to main content

Section 5.1 The Weierstrass Approximation Theorem

The following is one of the statements that we want to prove in this chapter.
Figure 5.1. Consider the function \(f \in C^0([-1,1])\) defined by \(f(x)=\abs x\) for \(x \in [-1,1]\text{.}\) Since \(f\) is not differentiable at \(0\text{,}\) it does not have a Taylor series there. Nevertheless, in Lemma 5.16 below, we find an explicit sequence of polynomials \(p_n \in C^0([-1,1])\) such that \(\n{p_n - f}_{\sup} \to 0\) as \(n \to \infty\text{.}\) Theorem 5.1 guarantees that such a sequence \((p_n)_{n \in \N}\) exists for any \(f \in C^0([-1,1])\text{,}\) although it does not tell us how to actually compute this sequence.
One consequence of the theorem is the following.
A related result makes a similar statement about the approximation of continuous \(2\pi\)-periodic functions with trigonometric polynomials.

Definition 5.3.

Let \(T \gt 0\text{.}\) A function \(f \maps \R \to \R\) is called \(T\)-periodic if \(f(x + T) = f(x)\) for all \(x \in \R\text{.}\)

Definition 5.4.

A trigonometric polynomial of degree \(n\) is an expression of the form
\begin{equation*} a_0 + \sum_{k = 1}^n \big(a_k \cos(kx) + b_k \sin(kx)\big) \end{equation*}
with \(a_0, \dotsc, a_n, b_1, \dotsc, b_n \in \R\) where \(a_n\) and \(b_n\) are not both zero.
We will prove not only these results, but also an elegant and powerful generalisation due to M. H. Stone, which is given in the next section.

Exercises Exercises

1. (PS10) \(C^0([a,b])\) is separable.

Let \(P=P([a,b]) \subset C^0([a,b])\) be the subset of polynomials with real coefficients, and let \(Q \subset P\) be the analogous set of polynomials with rational coefficients.
(a)
Show that \(Q\) is a dense subset of \(P\) when the latter set is equipped with the \(\n\blank_{C^0([a,b])}\) norm.
Hint.
This is relatively big hint. Let \(p \in P\text{,}\) say
\begin{equation*} p(x) = \alpha_0 + \alpha_1 x + \cdots + \alpha_M x^M \end{equation*}
for some \(M \in \N\) and coefficients \(\alpha_0,\ldots,\alpha_M \in \R\text{.}\) Argue that we can find a sequence \(\seq qn\) in \(Q\) of polynomials of the form
\begin{gather*} q_n(x) = \beta_0^{(n)} + \beta_1^{(n)} x + \cdots + \beta_M^{(n)} x^M \end{gather*}
whose coefficients converge to the coefficients of \(p\text{,}\) i.e. \(\beta_m^{(n)} \to \alpha_m\) as \(n \to \infty\) for all \(m \in \{1,\ldots,M\}\text{.}\) Then show that this implies \(q_n \to p\) in \(C^0([a,b])\text{.}\)
Solution 1. Argument using sequences
Following the hint, \(p \in P\) with
\begin{equation*} p(x) = \alpha_0 + \alpha_1 x + \cdots + \alpha_M x^M \end{equation*}
for some \(M \in \N\) and coefficients \(\alpha_0,\ldots,\alpha_M \in \R\text{.}\) As \(\Q\) is dense in \(\R\text{,}\) we can pick a sequence \(\seq qn\) in \(Q\) of polynomials of the form
\begin{gather*} q_n(x) = \beta_0^{(n)} + \beta_1^{(n)} x + \cdots + \beta_M^{(n)} x^M \end{gather*}
whose rational coefficients converge to the coefficients of \(p\text{,}\) i.e. \(\beta_m^{(n)} \to \alpha_m\) as \(n \to \infty\) for all \(m \in \{1,\ldots,M\}\text{.}\) Since the functions \(x \mapsto x^m\) all lie in \(C^0([a,b])\text{,}\) the convergence \(q_n \to p\) in \(C^0([a,b])\) now follows by repeatedly applying the second part of Exercise 1.3.1 (e.g. using induction on \(M\)).
Alternatively, we just emulate the official solution to Exercise 1.3.1 and use the triangle inequality to estimate
\begin{align*} \n{q_n-p}_{C^0([a,b])} \amp\le \abs{\beta_0^{(n)}-\alpha_0} \n{x^0}_{C^0([a,b])} + \cdots + \abs{\beta_M^{(n)}-\alpha_M} \n{x^M}_{C^0([a,b])}\\ \amp\to 0 \end{align*}
as \(n \to \infty\text{,}\) where here we have abused notation and written \(x^0,\ldots,x^M\) for the functions \(x \mapsto x^0, \ldots, x \mapsto x^M\text{.}\)
Solution 2. Direct argument
Let \(p \in P\) with
\begin{equation*} p(x) = \alpha_n x^n + \cdots + \alpha_1 x + \alpha_0\text{.} \end{equation*}
Let \(\varepsilon \gt 0\text{.}\) Define \(c = \max\{\abs a, \abs b\}\) and choose \(\beta_0, \ldots, \beta_n \in \Q\) with
\begin{equation*} |\alpha_k - \beta_k| \lt \frac{\varepsilon}{(n + 1) c^k}. \end{equation*}
Set
\begin{equation*} q(x) = \beta_n x^n + \cdots + \beta_1 x + \beta_0. \end{equation*}
Then
\begin{equation*} \begin{split} \sup_{x \in [a,b]} |p(x) - q(x)| \amp \le |\alpha_n - \beta_n| c^n + \cdots + |\alpha_1 - \beta_1| c + |\alpha_0 - \beta_0| \\ \amp \lt \frac{\varepsilon}{n + 1} + \cdots + \frac{\varepsilon}{n + 1} = \varepsilon. \end{split} \end{equation*}
That is, we have shown that \(\|p - q\|_{C^0([a,b])} \lt \varepsilon\text{,}\) which proves that \(Q\) is dense in \(P\text{.}\)
Comment.
On the one hand the solution above using sequences is easier than direct argument: we don’t have to mess around quite as much with inequalities or estimate the \(C^0([a,b])\) norm of \(x \mapsto x^m\text{.}\) On the other hand dealing with sequences does makes complicated in other ways, for instance in terms of the notation.
(b)
Conclude that \(Q\) is dense in \(C^0([a,b])\text{.}\)
Hint.
This follows relatively easily from the previous part and the Weierstrass approximation theorem.
Solution.
Let \(f \in C^0([a,b])\) and \(\varepsilon \gt 0\text{.}\) As \(P\) is dense in \(C^0([a,b])\) by the Weierstrass approximation theorem, there exists \(p \in P\) such that \(\n{p-f}_{C^0([a,b])} \lt \varepsilon/2\text{.}\) By the previous part, \(Q\) is dense in \(P\text{,}\) and so there similarly exists \(q \in Q\) such that \(\n{p-q}_{C^0([a,b])} \lt \varepsilon/2\text{.}\) Using the triangle inequality we conclude that \(\n{f-q}_{C^0([a,b])} \lt \varepsilon\) as desired.
(c)
Show that \(Q\) is countable. Conclude that \(C^0([a,b])\) is separable.
Hint 1.
This is probably the most sophisticated cardinality argument in the entire unit, and so if you are pressed for time you may just want to skip it and wait for the solutions. On the other hand it is doable with only the tools in Section 1.8; see the next hint.
Hint 2.
Let \(Q_n\) denote the set of polynomials in \(Q\) of degree \(\le n\text{.}\) First argue that \(Q_n\) is countable by appealing to Lemma 1.70. Then notice that \(Q = \bigcup_{n\in\N} Q_n\) and appeal to Lemma 1.72.
Solution.
We have already shown that \(Q\) is dense in \(C^0([a,b])\text{,}\) and so it suffices to show that \(Q\) is countable.
Let \(n \in \N\) and consider the set \(Q_n\) of polynomials in \(Q\) of degree \(n\) or less. Note that we have the bijection
\begin{equation*} \Q^{n + 1} \to Q_n, \qquad (\beta_0, \ldots, \beta_n) \mapsto \beta_n x^n + \cdots + \beta_1 x + \beta_0. \end{equation*}
\(\Q^{n+1}\) is countable as it is a finite product of countable sets (Lemma 1.70), and so \(Q_n\) is also countable. Thus \(Q = \bigcup_{n = 0}^\infty Q_n\) is a countable union of countable sets, and hence countable as well (Lemma 1.72).
Comment.
Note that infinite products of countably infinite sets are not countable. Often this is an intermediate step in the proof that \(\R\) is not countable.

2. Trigonometric polynomials dense in \(L^2([a,b])\).

Let \(A \subset C^0([0, 2\pi])\) denote the subset of all continuous functions \(f \maps [0, 2\pi] \to \R\) with \(f(0) = f(2\pi)\text{.}\) Let \(T \subset A\) denote the further subset of all trigonometric polynomials (Definition 5.4).
(a)
Show that \(A\) is dense in \(\big(C^0([0,2\pi]),\scp\blank\blank_{L^2(0, 2\pi)}\big)\text{.}\) Conclude that \(A\) is dense in \(L^2(0,2\pi)\text{.}\)
Hint.
Fix \(f \in C^0([0,2\pi])\text{.}\) Now let \(f_n\) be a continuous function obtained by replacing the graph of \(f\) for \(x \in [0,1/n]\) with a straight line segment in such a way that \(f_n \in A\text{.}\) Estimate \(\n{f-f_n}_{L^2(0,2\pi)}^2\text{,}\) and show that it tends to \(0\) as \(n \to \infty\text{.}\)
(b)
Show that \(T\) is dense in \(\big(A,\scp\blank\blank_{L^2(0,2\pi)}\big)\text{.}\) Conclude that \(T\) is dense in \(L^2(0,2\pi)\text{.}\)
Hint.
Given \(f \in A\text{,}\) extend it to \(2\pi\)-periodic continuous function \(\tilde f \maps \R \to \R\) and apply Theorem 5.5 to find a trigonometric polynomial \(p \in T\) which is close to \(f\) in terms of \(\n\blank_{\sup}\text{.}\) Now use this to estimate \(\n{f-p}_{L^2(0,2\pi)}\text{.}\) Finally, tie things together by applying the previous part.