# What is $\frac{d}{dx}|x|$ and how would I figure that out?

In other words, how do you differentiate a piecewise function?

Are they just done in several parts, as if differentiating more than one function, and so then the derivative is also a piecewise function? I imagine then that if the seperate functions that make up the 'pieces' of the piecewise derivative are the same, then the derivative can then be rewritten as a non-piecewise function.

Is that the general idea?

-
Not only the general idea, but the exact idea! (Though I guess you have to be a teeny bit careful about differentiability at the endpoints when gluing together to make your non-piecewise derivative.) – Cam McLeman Jan 6 '12 at 18:02
That's the kind of response I like. Thanks! Maybe you can take a look at my follow up question math.stackexchange.com/questions/96990/… – Korgan Rivera Jan 6 '12 at 18:22

The general idea would be to compute $$\lim_{x \to x_0} \frac{ f(x) - f(x_0) }{x - x_0}.$$ Now it would help if we could save ourselves some time in particular cases. When the derivative of the function is just well-known by standard techniques, go for it. If your function is piece-wise defined, then you can look at the domain where the pieces are well-known differentiable functions. For instance $$|x| = \begin{cases} x & \text{ if } x > 0 \\ -x & \text{ if } x < 0 \\ 0 & \text{ if } x = 0. \end{cases}$$ Note that I haven't included $0$ in either of the cases. Why? Because a single point can be treated alone, and the other constraints on the domain are open sets, that is, for every point in the set $\{ x > 0 \}$, when I get close enough to any point $x_0$ from that set, I am sure that I am still in that set. The same goes for $x < 0$. Although for $x = 0$ I don't have such luxury ; if I want to compute the derivative, I have to consider two "pieces" of my piece-wise defined function, which is not very nice to deal with.
Since $x$ and $-x$ are differentiable functions and that they coincide with $|x|$ over open intervals (here $x$ coincides with $|x|$ over $\{ x > 0 \}$ and $-x$ coincides with $|x|$ over $\{ x < 0\}$, everywhere there I can say that their derivatives are equal (i.e. $+1$ when $x > 0$ and $-1$ when $x < 0$). I cannot say the same for $x = 0$ because no differentiable function coincides with $|x|$ over an open interval containing $0$, since $|x|$ is not differentiable there.