# Is the max of two differentiable functions differentiable?

Given that $f$ and $g$ are two real functions and both are differentiable, is it true to say that $h=\max{(f,g)}$ is differentiable too?

Thanks

• If you are interested, there is a function soft max that approximates the max-function smoothly.
– Eff
Apr 22, 2015 at 12:24
• As a slightly weaker argument -- $max(f,g)$ should at least always be piecewise-differentiable, correct? Apr 22, 2015 at 17:53
• @Brian I'm pretty sure that's true, though it's possibly a separate question to be asked. Apr 22, 2015 at 18:56
• @Matt Separate question asked Apr 22, 2015 at 19:08

No. Consider $f(x)=x$ and $g(x)=-x$. You get $\max(f(x),g(x))=|x|$.

• simplest and easiest approach. wonderful Jul 15, 2015 at 6:33

No, $h(x)=\max(\cos x,\sin x)$ is not differentiable at $x=\dfrac\pi4+k\pi$.

This is because when you switch from $f$ to $g$, the slopes have no reason to be equal. • may i ask what software you use to generate this graph? Apr 22, 2015 at 7:40
• @LeeKM: Microsoft Mathematics. It's free and does symbolic computation as well.
– user65203
Apr 22, 2015 at 7:41
• I'll remember this answer if I ever need to draw a pair of lips in a Mathematica plot. Apr 22, 2015 at 11:27

not quite. Observe that: $\text{max}(f,g) = \dfrac{f+g + |f-g|}{2}$, thus if we simply let $f(x) = 2x, g(x) = x$, then we run into problem at $|x|$.

• This is a nice answer; a little more work gives a precise condition for exactly when $\max(f,g)$ will be differentiable. Apr 22, 2015 at 12:24
• The condition is: whenever $f(a) = g(a)$, $f'(a) = g'(a)$. Apr 22, 2015 at 12:26

$f(x) > g(x)$ Then $F:={\rm max}\{f,g\} =f$ is differentiable at $x$

If $f(x)=g(x)$ and $f(y)< g(y),\ y< x$ and $f(z)> g(z),\ z>x$, then $\frac{F(y)-F(x) }{y-x}$ goes to $g'(x)$ when $y$ goes to $x$

And $\frac{F(z)-F(x) }{z-x}$ goes to $f'(x)$ when $z$ goes to $x$. Hence in general $f'(x)\neq g'(x)$ so that it is not differentiable.