TITLE: Finding maximum of two polynomial functions
QUESTION [7 upvotes]: Let's say I've got 
$$f : \mathbb{R} \to \mathbb{R}\\ \qquad\qquad\quad x\mapsto x^3+x^2-6x$$
and 
$$g : \mathbb{R} \to \mathbb{R}\\ \qquad\quad x\mapsto 3x+9$$
and I need to find $\max(f,g)$. I started setting them equal, and finding the roots, but this doesn't seem to be the right way. How does one find the max of two functions? I know, e.g.
$$\max(f,g)(x) = \max\{f(x),g(x)\}$$

REPLY [11 votes]: ODF's answer is great and you should probably accept it. If you want a single formula, you can use simply that $$\max(f,g)(x) = \frac{f(x)+g(x) + |f(x)-g(x)|}{2},$$although further analysis will require you to attack that absolute value. You also have $$\min(f,g)(x) = \frac{f(x)+g(x)-|f(x)-g(x)|}{2}.$$