From my uni's textbook, classified as 'difficult'. Find the derivative (or right/left side derivative) of function $f$ on it's domain.
$f(x)=\max\left \{ \min\left \{ \cos(x),\frac{1}{2} \right \},-\frac{1}{2} \right \}$
Understandably, the domain of $f$ is $\mathbb{R}$
I've realized that the values of the function (which is periodic are):
$f(x)=\left\{\begin{matrix}\cos(x) &, -\frac{1}{2}< \cos(x)< \frac{1}{2} \\ \frac{1}{2}&, \frac{1}{2} \leq \cos(x)) \\ -\frac{1}{2}&, \cos(x)\leq -\frac{1}{2})\end{matrix}\right.$
So if I differentiated it, then:
$f'(x)\left\{\begin{matrix}-\sin(x) &, -\frac{1}{2}< \cos(x)< \frac{1}{2} \\ 0 &, \text{ otherwise} \\ \end{matrix}\right.$
So, if I'm right, the function behaves like a constant function on two intervals and then it behaves like a curve. I'm a bit worried about the points on the edges of each interval (where $f$ stops acting like a constant function at behaves like $cos(x)$ and vice versa- these points are probably kind of sharp (reminds me of function $|x|$ at $x=0$). Should I worry about the derivative there?