**Context:** In formulating problems for secondary school mathematics teachers (and students) about **absolute value functions**, which we define as functions $\mathbb{R} \rightarrow \mathbb{R}$ that send $x \mapsto a|x-h|+k$ for fixed parameters $a, h, k \in \mathbb{R}$, I was able to rewrite the **nested** absolute value function


$$f(x) = \Big||x|-1\Big|$$


as a linear combination of absolute value functions,


$$g(x) = |x+1| + |x-1| - (|x|+1)$$


(You can view the graphs of $f$ and $g$ [**here**](https://www.desmos.com/calculator/j5rgrj1ihh); although not delved into in this post, my colleagues enjoyed finding similar relationships even when there is a quadratic $x$ term, for example, in the graphs/functions depicted [**here**](https://www.desmos.com/calculator/wljf0czsyj).)


My **question** is twofold (although the follow-up question depends on the first answer):



> 
> **1.** Is it true that every nested absolute value function (NAVF) or linear combination of NAVFs can be written as a linear combination of AVFs?
> 
> 
> **2a.** If not, what is a counterexample, and what criteria must be satisfied for de-nesting to be possible?
> 
> 
> **2b.** If so, is there an algorithm for de-nesting, i.e., rewriting an arbitrary NAVF as a linear combination of AVFs?
> 
> 
> 


Pointers to related literature/references would be welcome, even if they do not explicitly answer the questions above. Please edit the questions, title, or tags if you believe it will improve clarity.



De-Nesting Absolute Value Function into Linear Combination of Absolute Value Functions
$\newcommand{\al}{\alpha}
\newcommand{\de}{\delta}
\newcommand{\De}{\Delta}
\newcommand{\ep}{\varepsilon}
\newcommand{\ga}{\gamma}
\newcommand{\Ga}{\Gamma}
\newcommand{\la}{\lambda}
\newcommand{\Si}{\Sigma}
\newcommand{\thh}{\theta}
\newcommand{\om}{\omega}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\F}{\mathcal{F}}
\newcommand{\E}{\operatorname{\mathsf E}} 
\renewcommand{\P}{\operatorname{\mathsf P}}
\newcommand{\ii}[1]{\operatorname{\mathsf I}\{#1\}} 
\newcommand{\tf}{\widetilde{f}}$ 


Lemma 3 in [Explicit additive decomposition of norms](https://www.tandfonline.com/doi/abs/10.4169/amer.math.monthly.123.5.491) (which is Lemma 1.2 in the [arXiv version](https://arxiv.org/abs/1506.00537) of that note) states the following: 



> 
> Suppose that $f\colon\R\to\R$ is a convex function such that for some real $k$ there exist finite limits 
>  \begin{equation\*}
>  d\_+:=d\_{f,k;+}:=\lim\_{u\to\infty}[f(u)-ku]\quad\text{and}\quad d\_-:=d\_{f,k;-}:=\lim\_{u\to-\infty}[f(u)+ku]. 
> \end{equation\*}
>  Then for all $x\in\R$ 
>  \begin{equation\*}
>  f(x)=\frac{d\_++d\_-}2+\frac12\,\int\_\R|x-t|\,d f'(t). \tag{1}
> \end{equation\*}
> 
> 
> 


As is clear from the short proof, this lemma holds for any absolutely continuous function $f$ with (possibly infinite) limits $\lim\_{x\to\pm\infty}f'(x)$. So, it is easy to see by induction on the nesting depth that the lemma holds for any nested absolute value function. 


**Added details:** 


For a finite nesting depth, the function $f$ is piecewise-affine: 
\begin{multline\*}
 f(x)=(a\_1+b\_1 x)\ii{x\le t\_1}+(a\_2+b\_2 x)\ii{t\_1<x\le t\_2}+\dots \\ 
 +(a\_n+b\_n x)\ii{t\_{n-1}<x\le t\_n}
+(a\_{n+1}+b\_{n+1} x)\ii{x>t\_n}
\end{multline\*}
for some natural $n$, some real "switch points" $t\_1<\dots<t\_n$, some real $a\_i$ and $b\_i$'s, and all real $x$, where $\ii\cdot$ denotes the the indicator. 
So, the integral in the lemma reduces to a sum: 
\begin{equation\*}
 f(x)=\frac{d\_++d\_-}2+\frac12\,\sum\_1^n|x-t\_i|\,\De f'(t\_i) \tag{2}
\end{equation\*}
for all real $x$, 
where $\De f'(t):=f'(t+)-f'(t-)$, the "jump" of $f'$ at $t$, so that $\De f'(t\_i):=b\_{i+1}-b\_i$ for all $i=1,\dots,n$. 


For the example at the link provided in the comment by the OP, formula (2) is illustrated in this [Mathematica notebook](https://my.pcloud.com/publink/show?code=XZ6Woj7ZyF3PLVH86Nz2uavdz11N84K1DFKk) and its [pdf image](https://my.pcloud.com/publink/show?code=XZEWoj7ZCRAmBXtEmWjb56h9hy64EzrxmSV7). 


