gradient of max function

6.9k Views Asked by At

If I have a function $f=\max \{0, y-t\}$, and I want to find the gradient of with respect to $[y \ \ t]$, would that simply be

$$ \nabla f = \begin{bmatrix} \max\{0,0\} \\ \max\{1,-1\} \end{bmatrix} = \begin{bmatrix} 0 \\ 1 \end{bmatrix} $$

1

There are 1 best solutions below

0
On

No. You would need to explicitly write out the function and derivative:$$f(y,t)=\begin{cases}0, y\le t\\y-t,y\gt t\end{cases}$$ Then $$\partial_t f=\begin{cases}0, y\le t\\-1,y\gt t\end{cases}$$ and $$\partial_y f=\begin{cases}0, y\le t\\1,y\gt t\end{cases}$$ So now you can write $$\nabla f=\begin{bmatrix}\partial_y f\\\partial_t f \end{bmatrix}=\begin{cases}\begin{bmatrix}0\\0 \end{bmatrix}, y\le t\\\begin{bmatrix}1\\-1 \end{bmatrix}, y\gt t\end{cases}$$