# 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.

• Perhaps of interest: A discontinuous midpoint-convex function. (Midpoint-convexity implies convexity when the function is continuous, but not necessarily otherwise.) – Michael Seifert Aug 3 '17 at 12:32
• @MichaelSeifert thank you, that's very interesting – alfalfa Aug 3 '17 at 13:35
• Just for fun, let's drill down a bit (no pun intended): How pathological can a LOGARITHMICALLY convex function be? My guess: not very. After all, there is only one such continuous generalization of the factorial function. – Mike Jones Aug 10 '17 at 0:48

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.

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

The set of points with non-differentiability can be dense in the support e.g for $x\in[-1,1]$ take

$$x\mapsto\sum_{i=0}^\infty\sum_{j=0}^{2^i-1}4^{-i}|2^{1-i}j+2^{-i}-1-x|$$

• Could we could also get a function with non-differentiable points dense in all of $\mathbb R$ just by taking @Lord Shark's function $x \mapsto \sum_{n=1}^\infty a_n|x - c_n|$ where $\{c_n\}$ is an enumeration of $\mathbb Q$? – alfalfa Aug 3 '17 at 14:25
• @alfalfa Yes that works, you can also use the compactly supported function $f$ in my answer. $f$ converge for all $x\in\mathbb{R}$ so just expand the range of non-differentiability like $\sum_{k=0}^{\infty} a_k f(x/2^k)$, where $a_k$ decrease e.g. exponentially. – lasen H Aug 3 '17 at 14:46

According to Wikipedia (point 2.), it can at most be non-differentiable at a countable number of points.

Pathological cases are not restricted to non-differentiability. Actually, a convex function need not even be continuous. A convex function on a closed domain may be discontinuous at the boundary. For example $f : [0,1] \rightarrow \mathbb{R}$: $$f (x) = \begin{cases} x^2 & \text{if x\in (0,1)}\\ 5 & \text{otherwise} \end{cases}$$ is convex in its domain.

• Maybe this is just my opinion, but isn't it obvious that a convex function need not be continuous at the boundary? I don't see anything pathological here. – BigbearZzz Aug 5 '17 at 3:24

You can get another one with discontinuities at a dense set of points by integrating the inverse of Cantor's function. (Yes, it's not injective so it doesn't really have an inverse, but there are only countably many points in the Cantor function's range where the inverse isn't defined, so you can define the value of the inverse as whatever there.)

• interesting, thank you – alfalfa Sep 21 '17 at 22:58