# How is the max function differentiable wrt multiple arguments?

I recently came across an answer on StackOverflow that mentioned the max function being differentiable with respect to its values.

From my current understanding of mathematics, I'm struggling to comprehend how this is possible.

Could someone help explain how we can define the derivative of the max function in the case of multiple arguments as max(a1, a2, ..., an)?

• Are you asking how the derivative of a function of multiple arguments is defined?
– Plop
May 26 at 8:11
• @Plop No. Actually, someone changed the original title. The tile is not mine. May 26 at 17:58

First restrict to two arguments, the general case is similar. Let $$f(x,y):=max(x,y)$$. This is a function defined on the entire real plane. When restricted to the region of the plane where $$x then in this region $$f(x,y)=y$$ which is clearly differentiable. Similarly in the region where $$x>y$$ we have $$f(x,y)=x$$ which is also differentiable.
However on the line where $$x=y$$ this function is continuous but not differentiable. To see this consider for example $$max(t, 1-t)$$ for a real value $$t$$. This is continuous but has a kink at $$t=1/2$$ so is not differentiable at this point. This is exactly where it crosses the $$x=y$$ line.