Convexity of piecewise constant functions Can a piecewise constant function be convex?
My idea: constant functions are both concave and convex by definition. I think that I can approximate a convex function such as $f(x)=x^2$ by piecewise constant functions and I believe it can be convex. But maybe there can be much simpler examples of some convex functions that are piecewise constant. Is my idea right? How can I build simpler examples?
 A: A piecewise constant function can never be concave or convex, if you're using this definition. These notions can be understood by considering an auxiliary function which I'll call $Slope(f(x,y),x,y)$. Slope eats a function and two numbers, and computes the secant $\frac{f(y)-f(x)}{y-x}$. Being concave or convex is the statement that for a fixed $f$, Slope is monotonic in both x and y, either increasing or decreasing.
A piecewise constant function lacks this property. Take two intervals on which $f$ is constant, and let $x', y'$ be their midpoints, and let $y' > x'$ without loss of any generality, and also $f(y') > f(x')$, since we're dealing with both notions this is also without loss of generality. Now if I increase $y'$ just a little bit to $y''$, $f(y'') = f(y')$, but $y'' > y'$, so the slope decreases. On the other hand, if I increase $x'$ just a little bit, the slope increases.
By swapping my assumptions on the $x$s and the $y$s, the same works for the other case(s).
In fact, one can establish readily that convex functions enjoy many nice properties that piecewise constant functions do not, for example, they are always continuous when defined on an open interval.
