Derivative of absolute function

Recall the definition of the derivative as the limit of the slopes of secant lines near a point.

$$f'(x) = \lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$

The derivative of a function at $x=0$ is then

$$f'(0) = \lim_{h\to 0}\frac{f(0+h)-f(0)}{h}= \lim_{h\to 0}\frac{f(h)-f(0)}{h}$$

If we are dealing with the absolute value function $f(x)=|x|$, then the above limit is

$$\lim_{h\to 0}\frac{|h|-|0|}{h} = \lim_{h\to 0}\frac{|h|}{h}$$

If $h$ approaches $0$ from the left, it is negative, so that $|h| = -h$ and the above limit is $-1$. But if $h$ approaches $0$ from the right, it is positive, so that $|h|=h$ and the limit is $1$. The left and right hand limits disagree, so the derivative does not exist at $0$.


First compare the graphs:

$|x|$

$x|x|$

$|x|$ is very sharp at $(0,0)$, so it doesn't have a derivative there.

$x|x|$ has derivatives because $x|x|$ is equal to:

$\begin{cases}y=x^2 & x > 0\\y=0 & x = 0\\y=-x^2& x<0\end{cases}$

And "square" makes $y = x^2$ tangent same of the $y=-x^2$. Same tangents = differentiable.

See those:

Source of tangent animations: Alice Ryhl (https://math.stackexchange.com/users/132791/alice-ryhl), Why is the absolute value function not differentiable at $x=0$?, URL (version: 2014-10-26): https://math.stackexchange.com/q/991559


I know you've already accepted an answer on how to find the derivatives of these functions using the definition, but you also have an interesting question on the power rule and how it relates. You asked in the comments above if we could write $f(x) = x^1 |x^1|$ and apply the power rule.

Starting with a more basic function, look at $x \mapsto x$, which you can write as $x\mapsto x^1$. The power rule applied to this function gives $$ \frac{d}{dx} x^1 = 1 \cdot x^0 = 1 \cdot 1 = 1 $$ This comports with our by-the-definition computation. The two things that prevent applying the power rule directly to $f(x) = x^1 |x^1|$ are the product rule and the chain rule.

I don't know if you've learned these yet. In case not: the product rule is the rule by which we can compute derivatives of products of functions. If $f(x) = g(x) h(x)$, you might hope that $f'(x) = g'(x) h'(x)$. If that were true, differentiating products would be as simple as differentiating sums. But that is not the case. Instead: $$ f'(x) = g'(x)h(x) + g(x) h'(x) $$ So even on a product of power functions you can't just take the derivative of each factor. The chain rule is for differentiating a composition function. If $h(x) = k(\ell(x))$, you might try $h'(x) = k(\ell'(x))$, but in fact that's not true. Instead: $$ h'(x) = k'(\ell(x)) \ell'(x) $$

So if you want to write $f(x) = x^1 |x^1|$, you can, but it's still not a power function. It's a product of two functions. The first is a power function, but the second is the composition of the absolute value function with a power function. If $g(x) = \ell (x) = x$, and $k(x) = |x|$, then $$ f(x) = g(x)\cdot k(\ell(x)) $$

We need the derivative of the absolute value function $k(x) = |x|$.
As you have seen from the definition: $$ k'(x) = \frac{d}{dx} |x| = \begin{cases} 1 & \text{if $x>0$;}\\ -1 & \text{if $x<0$.} \end{cases} = \frac{|x|}{x} $$ For the rest of the derivative, we need the product and chain rules: $$ f'(x) = g'(x) k(\ell(x)) + g(x) k'(\ell(x)) \ell'(x) $$ We know $g'(x) = \ell'(x) = 1$, so $$ g'(x) = 1\cdot |x| + x \cdot \left(\frac{|x|}{x}\right) \cdot 1 = 2 |x| $$