Stone-Weierstrass for monotone functions

Let $\; f : [0,1] \to \mathbb{R} \;$ be continuous and non-decreasing. $\;\;$ Let $\epsilon$ be a real number such that $\; 0 < \epsilon \;$.
Does it follow that that there exists a real polynomial $p$ such that $p$ is non-decreasing on

1. $\;$ $[0,1]$
2. $\;$ all of $\mathbb{R}$

and for all members $x$ of $[0,1]$, $\; |f(x)+(-(p(x)))| < \epsilon \;\;$?

-
... so, is this too easy for MO? $\;$ If no, what were the downvotes for? $\;\;$ –  Ricky Demer Jan 10 '12 at 23:57
Best guess: manual spacing doesn't render as well in every browser. –  François G. Dorais Jan 11 '12 at 0:06
It is "too easy". Basically it boils down to approximating $f$ by a smooth function $g$ with positive derivative, approximating $\sqrt {g'}$ by a polynomial $q$ on $[0,1]$, and putting $p=\int q^2$ on the line. There are many other solutions too. BTW, what's the point of writing $+((-p(x)))$ instead of the usual $-p(x)$? –  fedja Jan 11 '12 at 0:25
do you write the difference of two real numbers $x$ and $y$ as $x+(-y)$? –  John Pardon Jan 11 '12 at 3:22
Wow, people are really piling on here. While the question does not give any motivation, it is clearly formulated and has a definite answer. As a non-analyst, the answer was not obvious to me. As fedja points out it turns out to not be that difficult, but I don't think that's immediately obvious. –  MTS Jan 11 '12 at 3:44

2 Answers

In fact this question is a simple prototype of a serious problem of approximation maintaining additional qualitative properties of a function, with precise error estimates. See http://mathworld.wolfram.com/ComonotoneApproximation.html for the case of piecewise monotone functions. There are many problems and results of this kind (for example, with convex functions), which are useful in engineering applications and are far from trivial.

-

In fact, the Bernstein polynomials approximating $f$ are non-decreasing on $[0,1]$. A cute way to see this is via coupling (I learned this from Lindvall's book Lectures on the Coupling Method):

The $n$th Bernstein polynomial $p_n(x)$ can be written as $\mathbf{E}\Big[f\big(\frac{\sum_{i=1}^n Z^x_i}{n}\big)\Big]$, where $Z^x_i$ are Bernoulli random variables with parameter $x$. If $0\leq x\leq y\leq 1$, then we can define the variables $Z^x_i$ and $Z^y_i$ on the same probability space, such that $Z^x_i\leq Z^y_i$, which immediately gives $p_n(x)\leq p_n(y)$.

-