Approximation of continuous function uniformly by linear combination of constant functions on intervals Let $f:[a,b] \rightarrow \mathbb R$ be a continuous function. I wish to prove that for $\varepsilon >0$ there are a subintervals $P_1,...,P_n \subset [a,b]$ and constants $c_1,...,c_n$ such that for $h=c_1 \chi_{P_1}+...+c_n \chi_{P_n}$ is $\sup_{x\in [a,b]} |f(x)-h(x)|<\varepsilon$.
Thanks
 A: This may not exactly be what you are after, but I'll put it here just in case.

As $f$ is continuous on a compact interval, it attains a minimum value, say $k$. By considering $f - k$, we may assume that $f$ is non-negative. Now consider the sequence of functions $$f_n = 2^n\chi_{A_n}+\sum_{j = 0}^{2^{2n}-1}j2^{-n}\chi_{B_j}$$ where $A_n = f^{-1}([2^n, \infty))$ and $B_j = f^{-1}([j2^{-n}, (j+1)2^{-n}))$. 
If $N$ is the first integer such that $\max_{x\in[a,b]} f(x) < 2^N$ (such an $N$ exists because a continuous function on a compact set attains a maximum value), then $$\sup_{x\in[a,b]}|f(x) - f_n(x)| < 2^{-n}$$ for any $n \geq N$. So for any $\varepsilon > 0$, let $h(x) = f_n(x)$ where $n$ is chosen such that $n \geq N$ and $2^{-n} < \varepsilon$. Then $$\sup_{x\in[a,b]}|f(x) - h(x)| = \sup_{x\in[a,b]}|f(x) - f_n(x)| < 2^{-n} < \varepsilon.$$
This actually shows that the sequence $\{f_n\}_{n=1}^{\infty}$ converges to $f$ uniformly. This is the sequence of functions used (in Folland's Real Analysis for example) to show that any $L^+$ function is the pointwise limit of simple functions, and the limit is uniform on any set on which $f$ is bounded.
