# Derivative and integral of the abs function

I would like to ask about how to find the derivative of the absolute value function for example :

$\dfrac{d}{dx}|x-3|$

My try:$$f(x)=|x-3|\\ f(x) = \begin{cases} x-3, & \text{if }x \geq3 \\ 3-x, & \text{if }x \leq3 \end{cases}$$

So: $$f'(x) = \begin{cases} 1, & \text{if }x \geq3 \\ -1, & \text{if }x \leq3 \end{cases}$$

What is wrong with this approcah?.Please clarify. Also I want also like to find out how to integrate the absolute value function.

Thanks

-
$f'(x)$ is not defined in $x=3$: actually what you have written is not even a function since it assigns two values to $3$. –  Dario Jul 5 at 15:44

It is almost right..But you have to consider that, at $x=3$, $f(3)=0$.

So:

$$f(x)=\left\{\begin{matrix} x-3, x>3\\ 0, x=3\\ 3-x, x<3 \end{matrix}\right.$$

Therefore,

$$f'(x)=\left\{\begin{matrix} 1, x>3\\ -1, x<3 \end{matrix}\right.$$

EDIT: The derivative does not exist at $x=3$,because:

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

The last limit does not exist,because:

$$\lim_{h \to 0^-}\frac{|h|}{h}=-1 \text{ BUT } \lim_{h \to 0^+}\frac{|h|}{h}=+1$$ The limits are different on either side,so the limit does not exist.

Therefore,the function $f(x)=|x-3|$ is not differentiable at $x=3$.

-
The function is continuous at $3$, it isn't differentiable. –  Thomas Jul 5 at 15:48
Why isn't it differentiable at $3$? –  evinda Jul 5 at 15:49
Try using the definition of derivative. The derivative is given as a limit, but the right hand limit and the left hand limit will be different. So the limit doesn't exist and the function isn't differentiable. –  Thomas Jul 5 at 15:51
I understood it now..thank you!!! –  evinda Jul 5 at 15:53
I added a bit more to my answer. –  Thomas Jul 5 at 15:54

In your answer, the derivative isn't even not well defined since $f(3) = -1$ and $f(3) = 1$. The same note goes for the original function. The function is $$f(x) = \begin{cases} x-3, & \text{if }x \geq3 \\ 3-x, & \text{if }x \color{red}{<}3 \end{cases}$$ There is nothing wrong with your approach. The only thing is that the function is not differentiable at $3$. So you should get $$f'(x) = \begin{cases} 1, & \text{if }x >3 \\ -1, & \text{if }x <3 \end{cases}$$

So show that the function isn't differentiable at $3$, you consider the limit $$\lim_{h\to 0}\frac{f(3+h) - f(3)}{h}.$$ Here the left hand limit is $$\lim_{h\to 0^-}\frac{f(3+h) - f(3)}{h} = -1$$ while the right hand limit $$\lim_{h\to 0^+}\frac{f(3+h) - f(3)}{h} = 1.$$ (You can probably work out the details.) Since these two limit do not equal $$\lim_{h\to 0}\frac{f(3+h) - f(3)}{h}$$ does not exist, and so by definition the function is not differentiable at $3$.

-

1) Differentiation:

Define the signum function

$$\mathop{sgn}{(x)}= \begin{cases} -1 \quad \text{if } x<0 \\ +1 \quad \text{if } x>0 \\ 0 \quad \text{if } x=0 \\ \end{cases}$$

Claim: $$\frac{d |x|}{dx} = \mathop{sgn}(x), x\neq 0$$ Proof: Use the definition of the absolute value function and observe the left and right limits at $x=0$.

Hence, $$\frac{d |x-3|}{dx} = \begin{cases} -1 \quad \text{if } x-3<0 \quad(x<3)\\ +1 \quad \text{if } x-3>0 \quad(x>3) \end{cases}$$

2) Indefinite integration:

$$\int |x| \, \mathrm{d}x = \frac{x|x|}{2} + C$$

Proof: $$\frac{d}{dx}\left(\frac{x|x|}{2}\right)=\frac{1}{2}[ |x|+x \mathop{sgn}(x)] = \frac{1}{2}(2|x|)=|x|$$

3)Definite integration:

Look at the interval over which you need to integrate, and if needed break the integral in two pieces - one over a negative interval, the other over the positive. For example, if $a<0, b>0$, $$\int_a^b |x| \, \mathrm{d}x = \int_a^0 (-x)\, \mathrm{d}x + \int_0^b x \, \mathrm{d}x = \frac{b^2+a^2}{2}.$$

-