Approximating a continuous function by piece-wise functions Let $f: [a,b]\to \mathbb{R}$ be continuous. Then for any $\epsilon>0$, there exists a piece-wise constant function $f^{\epsilon}(.)$ such that 
$$|f(x)-f^{\epsilon}(x)|<\epsilon\:\:\: \text{for all}\:\: x\in [a,b].$$
I have no clue about this questions, by drawing an arbitrary continuous function, I can see, fr any epsilon, for any partition of $[a,b]$ there exist some lines above or below the graph which are very close to the graph ( less than $\epsilon$). By I don't know how to have a vigorous proof for this problem.
 A: You can make good use of the fact that $f$ is uniformly continuous (because $f$ is continuous on a segment). Thus there exists $\eta > 0$ such that $\forall (x,y) \in [a,b]^2, |x-y| \le \eta \implies |f(x)-f(y)| \le \varepsilon$. There exists $n \in \mathbb{N}$ such that $\frac{b-a}{n} \le \eta$. Now let us define $$f^{\varepsilon}\ \colon\ 
x\longmapsto\begin{cases}
f\big(a+\frac{k}{n} (b-a)\big)&\text{if $x \in \big[ a+\frac{k}{n} (b-a), a + \frac{k+1}{n} (b-a)\big[\ \ $ for $0 \le k < n$}\\
f(b) &\text{if $x=b$}
\end{cases}$$
Then $f^{\varepsilon}$ is piecewise constant, $|f(b)-f^{\varepsilon}(b)|=0$, and for $x \in [a,b[$, there exists $k \in [\![0,n-1]\!]$ such that $a+\frac{k}{n}(b-a) \le x < a+ \frac{k+1}{n}(b-a) $, so $| f(x)-f^{\varepsilon}(x) | = \big| f(x)-f\big(a+\frac{k}{n}(b-a)\big)\big| \le \varepsilon$ because $\big| x-\big(a+\frac{k}{n}(b-a) \big) \big| \le \frac{b-a}{n} \le \eta$. Hence $||f-f^{\varepsilon}||_{\infty} \le \varepsilon$.
A: HINT: because $f$ is continuous in a closed interval for any partition of $[a,b]$ the function achieve in each closed subinterval of the partition a maximum and a minimum.
Then your statement is equivalent to show that for a continuous function in a closed interval and any $\epsilon>0$ there exists a partition $P_\epsilon:=\{a_1,a_2,\ldots,a_n\}$ such that
$$\max\{f(x):x\in[a_k,a_{k+1}]\}-\min\{f(x):x\in[a_k,a_{k+1}]\}<\epsilon,\quad\forall k\in [n-1]$$
