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

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}.
$$
