Finding maximum of two polynomial functions

You have the right idea.

The best way to go about finding $\textrm{max}(f,g)$ is to find their intersection points by setting $f=g$ and finding the roots, and then plot the two graphs to see where each is at a maximum. The curves $y = x^3 + x^2 - 6x$ and $y = 3x + 9$

In your case, the two functions intersect at $x = -3$, $x = -1$ and $x = 3$. Looking at the graph above we clearly see which of $f$ and $g$ are at a maximum for each of the intervals $x \leq -3$, $-3 \leq x \leq -1$, $-1 \leq x \leq 3$ and $x \geq 3$. As a result we get that

\begin{equation*} \textrm{max}(f,g) = \left\{\begin{array}{cc} 3x + 6 & x \leq -3 \\ x^3 + x^2 - 6x & -3 \leq x \leq -1 \\ 3x + 6 & -1 \leq x \leq 3 \\ x^3 + x^2 - 6x & x \geq 3 \end{array} \right. \end{equation*}

This function looks like this for $-5 \leq x \leq 5$:

enter image description here


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}.$$