I am trying to calculate the derivative of $\left| \sin x \right| $
Given the graphs, we notice that the derivative of $\left| \sin x \right|$ does not exist for $x= k\pi$.
Graph for $\left|\sin x\right|$:
We can rewrite the function as
$\left| \sin(x) \right| = \left\{ \begin{array}{ll} \sin(x),& 2k\pi < x < (2k+1)\pi \\ -\sin(x), & \text{elsewhere} \\ \end{array} \right. $
Therefore calculate its derivative as:
$(\left| \sin(x) \right|)^{'} = \left\{ \begin{array}{ll} \cos(x),& 2k\pi < x < (2k+1)\pi \\ -\cos(x), & \text{elsewhere} \\ \end{array} \right. $
Is there a way to rewrite this derivative, in a more elegant way (as a non-branch function) $(\left| \sin(x) \right|)^{'} = g(x)$?