0

I am wondering what the correct derivative of the $clip(x,min\_value, max\_value)$ function is, where the $clip(\cdot)$ function clips $x$ to the range $[min\_value, max\_value]$.

For convenience, take $f(\cdot) = clip(\cdot)$, $a = min\_value$, and $b = max\_value$. Then, the function can be defined as:

$f(\cdot) = \left\{\begin{matrix} a\ \text{if}\ x \leq a\\ b\ \text{if}\ x \geq b\\ x\ \text{else} \end{matrix}\right.$

Inspired by this graphic, stemming from a research paper, I defined the derivative of the $clip(\cdot)$ function as follows:

$f'(\cdot) = \left\{\begin{matrix} 0\ \text{if}\ x \leq a\\ 0\ \text{if}\ x \geq b\\ 1\ \text{else} \end{matrix}\right.$

Thus, at $a (= min\_value)$, we have $f'(a) = 0$.

However, equivalently to $f(\cdot) = clip(\cdot)$, we could take $g(\cdot) = clip(\cdot)$ and use the following definition:

$g(\cdot) = \left\{\begin{matrix} a\ \text{if}\ x < a\\ b\ \text{if}\ x > b\\ x\ \text{else} \end{matrix}\right.$

In this case, I'd define $g'(\cdot)$ as follows:

$g'(\cdot) = \left\{\begin{matrix} 0\ \text{if}\ x < a\\ 0\ \text{if}\ x > b\\ 1\ \text{else} \end{matrix}\right.$

In this case, we would get $g'(a) = 1$.

So, if I did not make an error somewhere, two effectively identical function definitions, $f(\cdot)$ and $g(\cdot)$, lead to two distinct derivatives. Now, I was wondering whether I made an error somewhere or, if not, which derivative (i.e. $f'(\cdot)$ or $g'(\cdot)$) to prefer.

Daniel B.
  • 133
  • 2
    The derivative cannot exist at $a$ or $b$ either way, so you need strict inequalities to define the derivative as a piecewise function. – anon Jan 09 '21 at 00:05
  • Can you maybe explain why exactly it cannot exist at $a$ and $b$? Because these constitute positions of in-continuities or why is that? – Daniel B. Jan 09 '21 at 00:11
  • Look at the limit definition of the derivative. That limit does not exist. If you want, you can adjoin points to the graph of the derivative anyway so that it is defined at $a$ and $b$. – anon Jan 09 '21 at 00:12
  • 3
    At points $(a,a)$ and $(b,b)$ there are no tangents lines to the graph, only two lines, one with slope $0$ and the other with slope $1$. If you increasingly magnify the graph at those two points the graph does not eventually 'flatten out' and become indistinguishable from the tangent line. – John Wayland Bales Jan 09 '21 at 00:35
  • Sorry, I think I confused something in my previous (now deleted comment). So, the only correct way of defining $clip'(\cdot)$ is $g'(\cdot)$, correct? – Daniel B. Jan 18 '21 at 14:10

0 Answers0