can any continuous function be represented as a sum of convex and concave function?

You need more conditions than even absolute continuity. A characterisation of continuous, convex functions defined on open intervals is that they must be the indefinite integral of a monotonically non-decreasing function. (See here for example.) In particular, this means that continuous, convex functions are absolutely continuous.

So if you take any function that is continuous and not absolutely continuous (Cantor's stair case comes to mind), it cannot be decomposed as a sum of a convex and a concave function.

What's more important is that a convex function, by Alexandrov's theorem, must have a second derivative almost everywhere. Therefore your initial function must be even better than just absolutely continuous, it needs to also admit almost everywhere second derivatives.

And even assuming almost everywhere second derivatives is not enough, if you take the function $x \sin(1/x)$ which is analytic away from the origin, you cannot represent it as the difference of two convex functions.

Of course, there is still a gap between twice almost everywhere differentiable and David Speyer's everywhere twice-continuously differentiable condition. I am not entirely sure where the correct boundary lies, or if there is a correct boundary using just classical differentiability notions.


If $f$ is $C^2$ (meaning the derivatives $f'$ and $f''$ are defined and continuous), and if $f$ is defined on a closed interval like $[0,1]$, then there is an easy solution. Since $f''$ is continuous, it has a minimal value $m$. Choose $c$ positive and greater than $m$. Then $f(x)+c x^2/2$ is convex, by the double derivative test, and $-c x^2$ is concave. Of course, $[f(x)+c x^2/2] + [-cx^2/2] = f(x)$.

It shouldn't be too much harder to do a general continuous function, but I don't see it right now.


A $C^1$ function $f$ on a compact interval is convex (or is it concave?) if and only if $f'$ is increasing and is concave (or is it convex?) if and only if $f'$ is decreasing. If a function on a compact interval is a sum of a convex and a concave function, each of which is $C^1$, then $f'$ is the sum of an increasing and a decreasing function and so has bounded variation. There are continuous functions which are not of bounded variation on a compact interval. Integrating one gives a $C^1$ function $f$ which is not the sum of a $C^1$ convex and a $C^1$ concave function. Perhaps it could be the sum of some more general convex and concave functions, but I wouldn't bet on it :-)