How pathological can a convex function be?

Let $f : \mathbb R \to \mathbb R$ be convex. How weird can $f$ be? I know $f$ can easily be non-differentiable at finitely many points, for example $f(x) = \sum_{i=1}^n | x - c_i|$. Can it be non-differentiable at infinitely many points? Or on a set of positive measure?

My motivation for this is that when I picture an arbitrary convex function I tend to think of very regular ones like $f(x) = x^2$ but I want to make sure that I'm not building my intuition on examples that aren't rich enough.


Solution 1:

You can get non-differentiability at a countable infinite set by considering $$\sum_{n=1}^\infty a_n|x-c_n|$$ where $a_n>0$ and $(a_n)$ goes to zero rapidly.

Solution 2:

Others have provided examples in which the functions have countable sets of points at which $f$ is nondifferentiable. However, the answer to the question on whether this set of nondifferentiable points has measure zero is affirmative. This is even true for convex functions $f:\mathbb{R}^n\to \mathbb{R}$ and is just a consequence of Rademacher's theorem plus the fact that continuous convex functions in normed spaces are locally Lipschitz continuous.

Here are the details:

Let $f:\mathbb{R}^n\to \mathbb{R}$ be convex, and let $\{x_n\}$ be a enumeration of the elements of $\mathbb{R}^n$ with rational coordinates. It is easy to see that this set is dense in $\mathbb{R}^n.$ For each $x \in \mathbb{R}^n,$ define

$$\epsilon(x)= \sup\{\epsilon>0: f \textrm{ is locally Lipschitz on the ball }B(x,\epsilon) \}.$$ Since convex functions are locally Lipschitz continuous, we have that $\epsilon(x)$ is well defined and positive. Now it is easy to prove that $$\mathbb{R}^n= \bigcup_{n\in \mathbb{N}} B(x_n, \epsilon(x_n)).$$ Let $ND$ be the set of points at which $f$ is nondifferentiable. Applying Rademacher's theorem on each $B(x_n, \epsilon(x_n))$ we find that the set $ND\cap B(x_n, \epsilon(x_n))$ has measure zero. Therefore

$$\mu(ND)\leq \sum_{n=1}^\infty \mu(ND\cap B(x_n, \epsilon(x_n)))=0,$$ as desired.

Hope this helps