2

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)?

nbro
  • 39,006
  • 12
  • 98
  • 176
Peyman
  • 534
  • 3
  • 10

1 Answers1

6

Not sure wether this question is suitable here or should rather be on the math SE but here goes.

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<y$ 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.

quarague
  • 281
  • 1
  • 2