# 6.7. The Weierstrass Approximation Theorem

In part 4.5. we already used the Lagrange interpolating polynomials to connect given points in the xy-plane. The main issue then however was to capture finitely many values exactly. If these values are values of a function we normally have no idea how acurate its other values are hit..

This part now will prove that polynomials are able to match any continuous function on a closed interval with arbitrary acuracy within the whole range. K. Weierstrass proved this approximation behaviour in 1886, the constructive proof presented here however is due to S. N. Bernstein and originates from 1912.

Theorem (Weierstrass approximation theorem):  For any  $f\in {\mathcal{C}}^{0}\left(\left[a,b\right]\right)$ and any $\epsilon >0$ there is a polynomial p such that

 [6.7.1]

At first we only consider the interval $\left[0,1\right]$. It will be sufficient to carry out the essential prove for this special interval. To this end we construct a sequence of polynomials $\left({B}_{n}f\right)$ which converges on $\left[0,1\right]$ uniformly to  f, thus a sequence which allows an ${n}_{0}\in {ℕ}^{\ast }$ for each $\epsilon >0$ such that

 [6.7.2]

${B}_{{n}_{0}}f$ for example would then be a polynomial to prove the Weierstrass theorem.

We now introduce the approximating polynomials using the binomial coefficients  $\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}$.

Definition:  Let  $f:\left[0,1\right]\to ℝ$ be any function. For an arbitrary $n\in {ℕ}^{\ast }$ we call

 ${B}_{n}f≔\sum _{k=0}^{n}f\left(\frac{k}{n}\right)\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{\mathrm{X}}^{k}{\left(1-\mathrm{X}\right)}^{n-k}$ [6.7.3]

the n-th Bernstein polynomial of  f.

The first Bernstein polynomials for an arbitrary  f  are easily calculated:

• $\begin{array}{ll}{B}_{1}f\hfill & =f\left(\frac{0}{1}\right)\left(\phantom{T}\begin{array}{c}1\\ 0\end{array}\right)\phantom{T}{\mathrm{X}}^{0}{\left(1-\mathrm{X}\right)}^{1}+f\left(\frac{1}{1}\right)\left(\phantom{T}\begin{array}{c}1\\ 1\end{array}\right)\phantom{T}{\mathrm{X}}^{1}{\left(1-\mathrm{X}\right)}^{0}\hfill \\ \hfill & =\left(f\left(1\right)-f\left(0\right)\right)\mathrm{X}+f\left(0\right)\hfill \end{array}$

• $\begin{array}{ll}{B}_{2}f\hfill & =f\left(\frac{0}{2}\right)\left(\phantom{T}\begin{array}{c}2\\ 0\end{array}\right)\phantom{T}{\mathrm{X}}^{0}{\left(1-\mathrm{X}\right)}^{2}+f\left(\frac{1}{2}\right)\left(\phantom{T}\begin{array}{c}2\\ 1\end{array}\right)\phantom{T}{\mathrm{X}}^{1}{\left(1-\mathrm{X}\right)}^{1}+f\left(\frac{2}{2}\right)\left(\phantom{T}\begin{array}{c}2\\ 2\end{array}\right)\phantom{T}{\mathrm{X}}^{2}{\left(1-\mathrm{X}\right)}^{0}\hfill \\ \hfill & =\left(f\left(0\right)-2f\left(\frac{1}{2}\right)+f\left(1\right)\right){\mathrm{X}}^{2}+2\left(-f\left(0\right)+f\left(\frac{1}{2}\right)\right)\mathrm{X}+f\left(0\right)\hfill \end{array}$

With the function $|\mathrm{X}-\frac{1}{2}|$ e.g. we have  ${B}_{1}|\mathrm{X}-\frac{1}{2}|=\frac{1}{2}$ and ${B}_{2}|\mathrm{X}-\frac{1}{2}|={\mathrm{X}}^{2}-\mathrm{X}+\frac{1}{2}$.

To prove [6.7.2] we need some conclusions from the generalized binomial theorem:

${\left(a+b\right)}^{n}=\sum _{k=0}^{n}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{a}^{n-k}{b}^{k}$

Proposition:  For all $n\in {ℕ}^{\ast }$ and each $x\in ℝ$ we have

 $\sum _{k=0}^{n}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}=1$ [6.7.4]
 $\sum _{k=0}^{n}k\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}=nx$ [6.7.5]
 $\sum _{k=0}^{n}k\left(k-1\right)\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}=n\left(n-1\right){x}^{2}$ [6.7.6]
 $\sum _{k=0}^{n}{k}^{2}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}=nx-n{x}^{2}+{n}^{2}{x}^{2}$ [6.7.7]
 $\sum _{k=0}^{n}{\left(k-nx\right)}^{2}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}\le \frac{n}{4}$ [6.7.8]

Proof:
1.  The assertion results immediately from the generalized binomial theorem:

$\sum _{k=0}^{n}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}={\left(x+1-x\right)}^{n}=1$

2.  If $n=1$ there is nothing to show in essence. If $n>1$ we quote [6.7.4] with $n-1$ and calculate as follows (note the index shift):

$\begin{array}{ll}nx\hfill & =nx\sum _{k=0}^{n-1}\left(\phantom{T}\begin{array}{c}n-1\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-1-k}\hfill \\ \hfill & =\sum _{k=0}^{n-1}\frac{n!}{k!\left(n-1-k\right)!}{x}^{k+1}{\left(1-x\right)}^{n-k-1}\hfill \\ \hfill & =\sum _{k=1}^{n}\frac{n!}{\left(k-1\right)!\left(n-k\right)!}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \\ \hfill & =\sum _{k=1}^{n}k\frac{n!}{k!\left(n-k\right)!}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \\ \hfill & =\sum _{k=0}^{n}k\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \end{array}$

3.  Only $n>2$ is non trivial and in that case we proceed similar as before:

$\begin{array}{ll}n\left(n-1\right){x}^{2}\hfill & =n\left(n-1\right){x}^{2}\sum _{k=0}^{n-2}\left(\phantom{T}\begin{array}{c}n-2\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-2-k}\hfill \\ \hfill & =\sum _{k=0}^{n-2}\frac{n!}{k!\left(n-2-k\right)!}{x}^{k+2}{\left(1-x\right)}^{n-2-k}\hfill \\ \hfill & =\sum _{k=2}^{n}\frac{n!}{\left(k-2\right)!\left(n-k\right)!}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \\ \hfill & =\sum _{k=2}^{n}k\left(k-1\right)\frac{n!}{k!\left(n-k\right)!}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \\ \hfill & =\sum _{k=0}^{n}k\left(k-1\right)\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \end{array}$

4.  We just need to join [6.7.5] and [6.7.6]:

$\begin{array}{ll}nx-n{x}^{2}+{n}^{2}{x}^{2}\hfill & =nx+n\left(n-1\right){x}^{2}\hfill \\ \hfill & =\sum _{k=0}^{n}k\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}+\sum _{k=0}^{n}k\left(k-1\right)\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \\ \hfill & =\sum _{k=0}^{n}\left(k+k\left(k-1\right)\right)\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \\ \hfill & =\sum _{k=0}^{n}{k}^{2}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \end{array}$

5.  For all x we have  $0\le {\left(2x-1\right)}^{2}=4{x}^{2}-4x+1\text{ }⇔\text{ }4x\left(1-x\right)\le 1$. Thus:

$x\left(1-x\right)\le \frac{1}{4}$

This estimate and the results obtained so far now yield:

$\begin{array}{ll}\hfill & \sum _{k=0}^{n}{\left(k-nx\right)}^{2}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \\ =\hfill & \sum _{k=0}^{n}{k}^{2}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}-2nx\sum _{k=0}^{n}k\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}+{n}^{2}{x}^{2}\sum _{k=0}^{n}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \\ =\hfill & nx-n{x}^{2}+{n}^{2}{x}^{2}-2nx\cdot nx+{n}^{2}{x}^{2}\hfill \\ =\hfill & nx\left(1-x\right)\hfill \\ \le \hfill & \frac{n}{4}\hfill \end{array}$

Now we are prepared to prove version [6.7.2] of the Weierstrass theorem. For any  $f\in {\mathcal{C}}^{0}\left(\left[a,b\right]\right)$ and any $\epsilon >0$ we have to find an ${n}_{0}\in {ℕ}^{\ast }$ such that

We may abbreviate  $m≔\mathrm{sup}\left\{f\left(x\right)|x\in \left[0,1\right]\right\}$ as  f is bounded on $\left[0,1\right]$ according to [6.6.4]. As  f is uniformly continuous on $\left[0,1\right]$ (see [6.5.5]) there is a $\delta >0$ such that

Using the equality  $f\left(x\right)=f\left(x\right)\sum _{k=0}^{n}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}=\sum _{k=0}^{n}f\left(x\right)\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}$ (see [6.7.4]) as well as the triangle inequality we see that every n holds the estimate

$|f\left(x\right)-{B}_{n}f\left(x\right)|\le \sum _{k=0}^{n}|f\left(x\right)-f\left(\frac{k}{n}\right)|\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}$

For a fixed x we now split the addends involved into two disjoint lots:

$\begin{array}{l}A≔\left\{k\in \left\{0,\dots ,n\right\}||x-\frac{k}{n}|<\delta \right\}\hfill \\ B≔\left\{k\in \left\{0,\dots ,n\right\}||x-\frac{k}{n}|\ge \delta \right\}\hfill \end{array}$

If $k\in A$ we have $|f\left(x\right)-f\left(\frac{k}{n}\right)|<\frac{\epsilon }{2}$ due to   For $A\ne \varnothing$ we thus may estimate as follows (In case $A=\varnothing$  is valid as well as the empty sum's value equals 0):

$\begin{array}{ll}\hfill & \sum _{k\in A}|f\left(x\right)-f\left(\frac{k}{n}\right)|\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \\ <\hfill & \sum _{k\in A}\frac{\epsilon }{2}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \\ =\hfill & \frac{\epsilon }{2}\sum _{k\in A}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}=\frac{\epsilon }{2}\hfill \end{array}$

If $k\in B$ the equivalence $|\frac{k}{n}-x|\ge \delta \text{ }⇔\text{ }\frac{{\left(k-nx\right)}^{2}}{{n}^{2}}\ge {\delta }^{2}\text{ }⇔\text{ }\frac{{\left(k-nx\right)}^{2}}{{n}^{2}{\delta }^{2}}\ge 1$ allows to employ [6.7.8]:

$\begin{array}{ll}\hfill & \sum _{k\in B}|f\left(x\right)-f\left(\frac{k}{n}\right)|\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \\ \le \hfill & 2m\sum _{k\in B}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \\ \le \hfill & 2m\sum _{k\in B}\frac{{\left(k-nx\right)}^{2}}{{n}^{2}{\delta }^{2}}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \\ =\hfill & \frac{2m}{{n}^{2}{\delta }^{2}}\sum _{k\in B}{\left(k-nx\right)}^{2}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \\ \le \hfill & \frac{2m}{{n}^{2}{\delta }^{2}}\sum _{k=0}^{n}{\left(k-nx\right)}^{2}\left(\phantom{T}\begin{array}{c}n\\ k\end{array}\right)\phantom{T}{x}^{k}{\left(1-x\right)}^{n-k}\hfill \\ \le \hfill & \frac{2m}{{n}^{2}{\delta }^{2}}\cdot \frac{n}{4}=\frac{m}{2n{\delta }^{2}}\hfill \end{array}$

Choosing now a natural number ${n}_{0}>\frac{m}{\epsilon {\delta }^{2}}$ and employing  and  we may, for $n\ge {n}_{0}$, extend the estimate  to

$|f\left(x\right)-{B}_{n}f\left(x\right)|<\frac{\epsilon }{2}+\frac{m}{2n{\delta }^{2}}\le \frac{\epsilon }{2}+\frac{\epsilon }{2}=\epsilon$

Thus the Weierstrass theorem is valid for the interval $\left[0,1\right]$. The general case is easily reduced to this special one:

For an arbitrary interval $\left[a,b\right]$ we consider the linear (and thus continuous) function $g≔\left(b-a\right)\mathrm{X}+a$. It is a bijection from $\left[0,1\right]$ to $\left[a,b\right]$ with  $f\in {\mathcal{C}}^{0}\left(\left[a,b\right]\right)$ being equivalent to  $f\circ g\in {\mathcal{C}}^{0}\left(\left[0,1\right]\right)$. Thus for any $\epsilon >0$ there is a polynomial p such that

As the inverse of g is linear the function $p\circ {g}^{-1}$ is a polynomial as well. The equivalence of $x\in \left[a,b\right]$ and ${g}^{-1}\left(x\right)\in \left[0,1\right]$ now allows to restate  as follows:

The applet below creates and illustrates the Bernstein polynomials for three selected functions. 