# How to get back the first form in terms of absolute function from the component form of a function?

Let $f(x)=|x|+|x-1|$. And we know that $f(x)$ can be written as $$f(x)=\begin{cases} -x-(x-1), & x<0\\ 0+1, & x=0\\ x-(x-1), &x\in (0, 1)\\ 1+0, &x=1\\ x+(x-1)& x>1 \end{cases}$$ which is $$f(x)=\begin{cases} -2x+1, & x<0\\ 1, & x=0\\ 1, &x\in (0, 1)\\ 1, &x=1\\ 2x-1& x>1 \end{cases}$$ i.e. $$f(x)=\begin{cases} -2x+1, & x<0\\ 1, & x\in [0, 1]\\ 2x-1& x>1 \end{cases}$$

My query is: suppose that the last expression is given. Viz the component form of $f(x)$ is given. Is it possible or is there any method or procedure through which we can obtain the first expression in the form of sum of absolute value functions?

Warning: you have cases like $f(x)=|2x+2|=|x+1|+|x+1|$.
Solution for the case $f=|f_1|+\cdots+|f_n|$ with $f_i$ a first degree polynomial with root $x_i$ and $x_i\ne x_j$ for $i\ne j$
The "angled points" ofe the graph will be $x_1,\cdots,x_n$. Write $$f(x)=|a_1(x-x_1)+b_1|+\cdots+|a_n(x-x_n)+b_n|.$$ Can you continue?