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

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

1 Answer 1


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.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .