Theorem: Weierstrass Approximation Theorem

Let $f$ be a real function which is continuous on the closed interval $\Bbb I = \closedint a b$.
Then $f$ can be uniformly approximated on $\Bbb I$ by a polynomial function to any given degree of accuracy.

Proof:
Let $\map f t: \Bbb I = \closedint a b \to \R$ be a continuous function.
Introduce $\map x t$ with a rescaled domain:
:$\map f t \mapsto \map x {a + t \paren {b - a} } : \closedint a b \to \closedint 0 1$
From now on we will work with $x: \closedint 0 1 \to \R$, which is also continuous.
Let $n \in \N$.
For $t \in \closedint 0 1$ consider the Bernstein polynomial:
:$\ds \map {B_n x} t = \sum_{k \mathop = 0}^n \map x {\frac k n} \binom n k t^k \paren {1 - t}^{n - k}$
For $t \in \closedint 0 1$, $0 \le k \le n$, let:
:$\map {p_{n, k} } t := \dbinom n k t^k \paren {1 - t}^{n - k}$
By Binomial Theorem for Integral Index:
:$\ds \sum_{k \mathop = 0}^n \map {p_{n, k} } t = 1$
=== Lemma 1 ===
{{:Weierstrass Approximation Theorem/Lemma 1}}{{qed|lemma}}
=== Lemma 2 ===
{{:Weierstrass Approximation Theorem/Lemma 2}}{{qed|lemma}}
Now we construct the estimates.
{{begin-eqn}}
{{eqn | l = \sum_{k \mathop : \size {\frac k n \mathop - t} \mathop \ge \delta}^n \map {p_{n, k} } t
      | o = \le
      | r = \sum_{k \mathop : \size {\frac k n \mathop - t} \mathop \ge \delta}^n \map {p_{n, k} } t \frac {\paren {k - n t}^2} {\delta^2 n^2}
      | c = as $\dfrac {\paren {k - n t}^2} {\delta^2 n^2} \ge 1$
}}
{{eqn | o = \le
      | r = \frac 1 {n^2 \delta^2} \sum_{k \mathop = 0}^n \paren {k - n t}^2 \map {p_{n, k} } t
}}
{{eqn | r = \frac {t \paren {1 - t} } {n \delta^2}
      | c = {{Lemma|Weierstrass Approximation Theorem|2}}
}}
{{eqn | o = \le
      | r = \frac 1 {4 n \delta^2}
      | c = $\forall t \in \closedint 0 1: \dfrac 1 4 \ge t \paren {1 - t}$
}}
{{end-eqn}}
Here $\ds \sum_{k \mathop : \size {\frac k n \mathop - t} \mathop \ge \delta}^n$ denotes the summation over those values of $k \in \N$, $k \le n$, which satisfy the inequality $\size {\dfrac k n - t} \ge \delta$.
For some $\delta > 0$ denote:
:$\ds \map {\omega_\delta} x := \sup_{\size {t - s} \mathop < \delta} \size {\map x s - \map x t}$
Then:
{{begin-eqn}}
{{eqn | l = \size {\map {B_n x} t - \map x t}
      | r = \size {\map {B_n x} t - \map x t \sum_{k \mathop = 0}^n \map {p_{n, k} } t}
}}
{{eqn | r = \size {\sum_{k \mathop = 0}^n \map x {\frac k n} \map {p_{n, k} } t - \map x t \sum_{k \mathop = 0}^n \map {p_{n, k} } t}
}}
{{eqn | o = \le
      | r = \sum_{k \mathop = 0}^n \size {\map x {\frac k n}  - \map x t} \map {p_{n, k} } t
      | c = as $\map {p_{n, k} } t \ge 0$
}}
{{eqn | r = \sum_{k \mathop : \size {\frac k n \mathop - t} \mathop < \delta}^n \size {\map x {\frac k n}  - \map x t} \map {p_{n, k} } t + \sum_{k \mathop : \size {\frac k n \mathop - t} \mathop \ge \delta}^n \size {\map x {\frac k n}  - \map x t} \map {p_{n, k} } t
}}
{{eqn | o = \le
      | r = \map {\omega_\delta} x \sum_{k \mathop : \size {\frac k n \mathop - t} \mathop < \delta}^n \map {p_{n, k} } t + 2 \norm x_\infty \frac 1 {4 n \delta^2}
}}
{{eqn | o = \le 
      | r = \map {\omega_\delta} x \cdot 1 + \frac {\norm x_\infty} {2 n \delta^2}
}}
{{end-eqn}}
where $\norm {\,\cdot \,}_\infty$ denotes the supremum norm.
Let $\epsilon > 0$.
By Continuous Function on Closed Real Interval is Uniformly Continuous, $\map x t$ is uniformly continuous.
We choose $\delta > 0$ such that $\map {\omega_\delta} x < \dfrac \epsilon 2$.
Choose $n > \dfrac {\norm x_\infty} {\epsilon \delta^2}$
Then:
:$\norm {\map {B_n x} t - \map x t}_\infty < \epsilon$.
{{qed}}