Given:
$f:\mathbb{R}\rightarrow\mathbb{R}, x \mapsto x^3+x^2-6x$ and
$g:\mathbb{R}\rightarrow\mathbb{R},x\mapsto 3x+9$
I need to to determine $\max\{f,g\}$.
I search on the internet and found:
$\max\{f(x),g(x)\}:=\frac{f(x)+g(x)+|f(x)-g(x)|}{2}$
If I use my functions I get:
$\frac{x^3+x^2-3x+9+|x^3+x^2-9x-9|}{2}$, but how can I get rid of the absolute value?
Thabks in advance.


Let us see first when is it that we have $f(x)=g(x)$:\begin{align}f(x)=g(x)&\iff x^3+x^2-6x=3x+9\\&\iff x^3+x^2-9x-9=0\\&\iff x^2(x+1)-9(x+1)=0\\&\iff(x^2-9)(x+1)=0\\&\iff x=-3\vee x=-1\vee x=3.\end{align}It turns out that $f(x)\geqslant g(x)$ if and only if $x\in[-3,-1]\cup[3,+\infty)$. Therefore$$\max\bigl\{f(x),g(x)\bigr\}=\begin{cases}f(x)&\text{ if }x\in[-3,-1]\cup[3,+\infty)\\ g(x)&\text{ otherwise.}\end{cases}$$