Casey Chu
• Minimum and maximum of two functions
• Let’s say you want a function that outputs the smaller of two functions $f$ and $g$ along its domain. It turns out that a neat way to express that function is this: $\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, $\min(x^2,\ x + 2) = \frac{x^2 + (x + 2) - |x^2 - (x + 2)|}{2}.$ The 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 neat formula can be explained by splitting the fraction for the expression up: \begin{aligned} \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{aligned}
• Here, the first term $\frac{f(x) + g(x)}{2}$ is the average of the two functions; graphically, this is halfway between the two functions. The second term $\frac{|f(x) - g(x)|}{2}$ is half absolute value between the two functions; graphically, this is half the distance between the two functions. What happens when you subtract half the distance from the average? 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: $\max(f(x),\ g(x)) = \frac{f(x) + g(x) + |f(x) - g(x)|}{2}.$
• Originally written March 26, 2012.