Imagine I have the following piecewise function: $$f(x)= \begin{cases} 6 & x\leq 8.5 \\ 14.5-x & 8.5< x < 10.5 \\ 4 & 10.5\leq x \end{cases} $$ This could be rewritten as the following $$ f(x) = \text{min}(6, \text{max}(4, 14.5-x)) $$ which can can be decomposed as $$ f(x)=\text{max}(0, 10.5-x)-\text{max}(0, 8.5-x)+4 $$ or $$ f(x)=\text{max}(0,x- 10.5)-\text{max}(0, x- 8.5)+6 $$ and I'm sure this could be also expressed using $\text{min}()$. My question then, is there a general rule to decompose nested max and mins in a linear combination of "simple" max and mins?
EDIT: by "simple" I mean with no nested max/min and ideally with $0$ as one of the two arguments