How to turn a piecewise function into a linear polynomial and absolute equation Original Question Image
Help! Does anybody know how to do part b?
a) Let $a$ be a real number and consider the function $f:\mathbb R \to \mathbb R$ defined piecewise by
$$f(x) := \begin{cases}
x-a, & \text{if $x>a$}\\
0, & \text{if $x\le a$}
\end{cases}$$
Show that for every real number $x$ we have
$$f(x) = 0.5(x-a)+0.5|x-a|$$
b) Consider the function $P:(0,+\infty)\to\mathbb R$, which is defined piecewise by
$$P(x) = \begin{cases}
27, & \text{if $0<x\le 2$}\\
9.5x+8, & \text{if $2<x\le 9$}\\
6.5x+35, & \text{if $x>9$}
\end{cases}$$
Using the result from a), express $(x)$ as the sum of a linear polynomial and absolute values of linear polynomials, i.e. write $(x)$ in the form
$$P(x)=(b_0x+c_0)+|b_1x+c_1|+|b_2x+c_2|+...$$
where $b_i$ and $ c_i$ are real numbers.
 A: One can observe the logic behind the example in the question and then prove the following. Let:
$$a(x) = \frac{p(x) + q(x) + |p(x) - q(x)|}{2}$$
Then, if $p(x)\ge q(x)$, we get $a(x) = p(x)$. Otherwise, $a(x) = q(x)$. And:
$$b(x) = \frac{p(x) + q(x) - |p(x) - q(x)|}{2}$$ yields $b(x) = q(x)$ if $p(x) \ge q(x)$ and $b(x) = p(x)$ otherwise. We will use these rules to find $P(x)$.
Let:
$$\color{blue}{f(x) = 27}$$$$\color{blue}{g(x) = 9.5x+8}$$$$\color{blue}{h(x) = 6.5x+35}$$
Now, the question breaks down $P(x)$ into piecewise functions based on $x$, not $f(x),g(x),$or $h(x)$. But our formulae only work for comparisons between functions of $x$. So, before using the above formulae, you must make the conditions equivalent. Note that $g(x) = f(x)$ at $x = 2$ and $g(x) > f(x)$ for  $x > 2$. Similarly, $g(x) = h(x)$ at $x = 9$ and $g(x)>h(x)$ for $x>9$, which is lucky(as 2 and 9 are the cusps where $P(x)$ changes the 'output function'), since it gives us:
$$P(x) =
\begin{cases}
Q(x),  & \text{if $h(x) \ge Q(x)$} \\
h(x), & \text{if $h(x)<Q(x)$}
\end{cases}$$ where
$$Q(x) =
\begin{cases}
f(x),  & \text{if $f(x) \ge g(x)$} \\
g(x), & \text{if $f(x)<g(x)$}
\end{cases}$$
Using the first formula:
$$\color{green}{Q(x) = \frac{f(x) + g(x) + |f(x) - g(x)|}{2}}$$
Using the second formula:
$$\color{green}{P(x) = \frac{h(x) + Q(x) - |h(x) - Q(x)|}{2}}$$
Now, substitute the values to get the desired answer.
