# How do I calculate derivative of sgn(x)

We know $|x| = \sqrt(x^2)$, determine the second derivative

$\frac{d^2}{dx^2}|x|$,

So the first derivative is sgn(x), but how do I get the second?

• It doesn't have a derivative using the normal limit definition. It however has a weak derivative, a distribution, normally denoted $\delta$. – md2perpe Sep 17 '17 at 12:59
• If $f(x)=|x|$, then $f'(0)$ is undefined. If $x\neq 0$, then $f'(x)=\text{sgn}(x)$ (sign function; signum function). – user263326 Sep 17 '17 at 13:19

HINT:

Consider the graph of $sgn(x)$. What does it look like? What kind of slope does it have?

• Two horizontal lines from Y = -1 and Y = 1, so the slope is 0 but at X = 0 the slope becomes undefined. True? – JohnDoe Sep 17 '17 at 13:49
• Yes, this is not defined in $x=0$. However, you should already know that from the first derivative (where the derivative in $x=0$ is not defined). – Niki Di Giano Sep 17 '17 at 13:53
• In fact, the derivative of $|x|$ is not exactly e qual to the signum function, because you already need to restrict the domain to $\mathbb{R} - {0}$. This won't allow you to even consider what happens around $x=0$ to differentiate again, because while it is part of the domain of $sgn(x)$, it is not part of the domain of $\frac{d}{dx} |x|$. – Niki Di Giano Sep 17 '17 at 14:17
• Ok I'm lost, so I shouldn't try to get the derivative of sgn(x)? – JohnDoe Sep 17 '17 at 14:22
• Actually, you are not left exactly with the $sgn$ function. However, since the only point that is missing in the derivative of $|x|$ is the point at zero, using directly the signum function to differentiate is not that big a problem. You cannot say, though, that the derivative of $|x|$ and the signum function are exactly the same thing, because although they have exactly the same effect in their domains, they do not range over the same domain. – Niki Di Giano Sep 17 '17 at 14:31

You know that

$sgn(x)=\begin{cases} 1 & x>0 \\ 0 & x=0 \\ -1 & x<0 \end{cases}$

I think you can get the derivative from there, derivate each piece of the function. Notice the discontinuity points and consider how this affects the existence of derivative at some points.

Considering derivative of discontinuity as del(x). Derivative of sgn(x) would be 2*del(x), as there exist a discontinuity at x=0 and a change in step by 2 units (from -1 to +1).

Note : This method is being used in mathematical modeling of signals. Where del(t) is an unit impluse function. And sgn is made up of two step functions.