Minimum and maximum of two functions

Let’s say you want a function that outputs the smaller of two functions along its domain. It turns out that the expression for that function is this:
$$\operatorname{min}(f(x),\ g(x)) = \frac{f(x) + g(x) – |f(x) – g(x)|}{2}$$

For example, take $f(x) = x^2$ and $g(x) = x + 2$. Then,
$$\operatorname{min}(x^2,\ x + 2) = \frac{x^2 + x + 2 – |x^2 – (x + 2)|}{2}$$
whose graph looks like this:

As you can see, it takes on the shape of $f(x)$ (the parabola) when $f(x)$ is smaller and $g(x)$ (the linear part) when $g(x)$ is smaller.

This can be explained by splitting the fraction for the expression up:
$$\begin{align}
\operatorname{min}(f(x),\ g(x)) &= \frac{f(x) + g(x) – |f(x) – g(x)|}{2} \\
&= \frac{f(x) + g(x)}{2} – \frac{|f(x) – g(x)|}{2}
\end{align}$$

You can see that the first term in the split formula is the average of the two functions, and the second term is half the distance (absolute value) between the two functions. When you subtract half the distance between the two functions from the average of the two functions, you always get the smaller function.

What would happen if you add the distance between the two functions instead of subtracting? You get the greater of the two functions:
$$\operatorname{max}(f(x),\ g(x)) = \frac{f(x) + g(x) + |f(x) – g(x)|}{2}$$

I don’t remember where I found this, but it’s pretty awesome!

March 26, 2012, 2:58pm by Casey
Categories: Math | Permalink | 2 comments

Comments (2)

  1. How did you arrive at that formula for max and min. If we see with an example, then it definitely makes sense. But to generalize, how did you arrive at the statement “the diff between average and half the distance between the functions gives the minimum”? Thanks in advance

Leave a Reply

Required fields are marked *