# Absolute value: First Derivative Heaviside Function + Second Derivative Dirac Delta Function Distribution

I have some issues concerning the derivative of an absolute value $|x|$, the Heaviside function $\theta(x)$ and the Dirac Delta Distribution.

Given the definition of the Heaviside function $$\theta(x) = \left\{ \begin{array}{ll} 1 \quad \text{for} \quad x \ge 0\\ 0 \quad \text{for} \quad x<0 \end{array} \right.$$ I suppose it is right to express the first derivative of an absolute value as $$\frac{d |x|}{dx} = \left\{ \begin{array}{ll} +1 \quad \text{for} \quad x > 0\\ -1 \quad \text{for} \quad x<0 \end{array} \right. \overset{!}{=} \theta(x) - \theta(-x),$$ evaluating the derivatives of $|x|$ from the left and right side. Here I have some issues with the case of $x=0$ $$\left.\frac{d |x|}{dx}\right|_{x=0}=\theta(0)-\theta(0)=1-1=0,$$ which is not defined in my original "first derivative" of $d |x|/ dx$. So how can the first derivative of an absolute value be correctly expressed in terms of the Heaviside function?

Anyways taking my assumption of the first derivative for granted I want to perform a second derivative with the identity $$\frac{d \theta(x)}{dx} = \delta(x)$$, which then leads to $$\frac{ d^2 |x|}{dx^2} = \frac{d}{dx}(\theta(x)-\theta(-x)) = \delta(x)-\delta(-x)=\delta(x)-\delta(x)=0.$$

The last expression cannot be true and should be $$\frac{d^2 |x|}{dx^2} = 2 \delta(x)$$ following Second derivative of absolute value function proportional to Dirac delta function?

What am I missing to get to the correct expression?

• $\frac{d|x|}{dx} = \text{sign}(x)$ because $|x| = \int_0^x \text{sign}(t)dt$. When integrating, the isolated value of $\text{sign}(x)$ at $x=0$ doesn't change anything. And $\frac{d\text{ sign}(x)}{dx}= 2 \delta(x)$ because $\text{sign}(x) = \int 2 \delta(x) dx$ – reuns May 13 '17 at 14:58

If you draw $|x|$ then you should see the derivative does depend on the direction you approach the point from. Trying to assign it a numerical value does not make sense. Your expressions are correct although you could try to assign the derivative to be infinite at $x=0$.
For your second point, the chain rule is missing from your calculation, $$\frac{d\theta(-x)}{dx} = \left.\frac{d(-x)}{dx} \frac{d\theta(y)}{dy}\right\vert_{y=-x} = - \delta(y)\vert_{y=-x} = -\delta(-x)=-\delta(x) .$$
Basically you take the one-sided derivatives at $$0$$, and you get both $$+1$$ and $$-1$$ simultaneously for $$x=0$$, depending on the side you approach from. This forms a range of values, I will express as the interval $$(-1,1)$$. An argument can be made that $$f' \in (-1,1)$$, being all possible slopes concurrently. This can be argued because any line you draw through the point at $$x=0$$ and having any slope in this range will fail to cross through the function. And as you can see, $$0\in(-1,1)$$; a slope of $$0$$ is indicative of a peak. Consequently, $$x=0$$ is a local optimization point. So its not unreasonable to suggest that the derivative of $$|x|$$ at $$x=0$$ is zero, or, at least, we can say that a horizontal line is tangent to the function.