# Finding maximum of two polynomial functions

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)\}$$

• This depe3nds on what "find" means. Why is the trivially correct answer $x\mapsto \max\{f(x),g(x)\}$ discouraged? – Hagen von Eitzen Jan 29 '18 at 20:49
• @HagenvonEitzen I agree, my question could have been asked more precisely – user3125470 Jan 29 '18 at 23:22

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