# Is a piecewise linear function always a sum of concave and convex functions?

If I take a piecewise linear function (piecewise affine) is it true that I can always write it as a sum of concave and convex functions?

https://mjo.osborne.economics.utoronto.ca/index.php/tutorial/index/1/cv1/t

suggests that any linear function is both convex and concave, so for a piecewise linear function is it always possible to 'separate' the convex and concave parts?

Let me assume that you are talking about a real-valued function $$f : [a,b] \to \mathbb{R}$$. A characterization of which such functions may be written as $$f=g-h$$ with $$g$$ and $$h$$ convex (so $$-h$$ concave) is known. The result is the following (see this book):

Let $$f : [a,b] \to \mathbb{R}$$. Then there exists $$g$$ and $$h$$ convex such that $$f = g-h$$ if and only if the derivative of $$f$$ is in the class $$BV[a,b]$$ of functions of bounded variation on $$[a,b]$$.

Here, "derivative" is in the sense that there exists a function $$r \in BV[a,b]$$ such that, for all $$x \in [a,b]$$, $$f(x)-f(a) = \int_a^x r$$

Hence, the answer to your question is both yes and no. If you take an $$f$$ which is piecewise affine but has discontinuities, then you will not be able to find such a decomposition. Conversely, if it is continuous, then its derivative will be piecewise constant, so of bounded variation, so the above result applies.

• Discontinuous functions on a finite interval $[a,b]$ are in BV if they are bounded and if there are only finitely many discontinuities. I think that's pretty much the case the OP had in mind. May 16, 2023 at 4:28
• Sure. But here the characterization requires that the derivative is BV, not the function itself. Having a BV derivative implies continuity.
– cs89
May 16, 2023 at 4:48
• Ah, yes. And I now also realize that the decomposition of a piecewise but discontinuous function would likely also be discontinuous, and discontinuous functions are neither convex nor concave. May 16, 2023 at 21:30