When differentiating expressions involving $|x|$, it is often safest to consider the cases $x>0$ and $x<0$ separately. After finding the derivative for one case (e.g., $x>0$), you can often generalize the result by replacing terms like $x^2$ with $x|x|$ to make it valid for both cases.