Consider an arbitrary function, something like $f\left ( x \right )=\arccos \left ( \sin \left ( 4x \right ) \right )$.
Its graph looks like this:
I was greatly confused by the image below, because before using a tool to graph the function I came to following results:
$$y=\arccos \left ( \sin \left ( 4x \right ) \right )$$ $$\cos \left ( y \right )=\sin \left ( 4x \right )=\cos (\frac{\pi }{2}-4x)$$ $$y=\frac{\pi }{2}-x+2k\pi, k\in\mathbb{Z} $$ This answers the first part of my question about $f$ being a periodic function. However, since the range of the inverse cosine function is $\left [ 0,\pi \right]$ it seemed to me that I had made a crucial mistake somewhere. How should one variate the parameter $k$ in order do get a graph as shown below, and what would be the derivative of the function at points where it "breaks"? Is it zero because those points represent local extrema, or is it infinity (maybe the same case as with the function $y= \left | x \right |$ at zero)?
$\newcommand{\Reals}{\mathbf{R}}$Generally, if $f:\Reals \to \Reals$ is $\ell$-periodic (for some positive real number $\ell$), and if $g$ is an arbitrary real-valued function defined on the image of $f$, then $g \circ f$ is $\ell$-periodic (easy exercise).
In your case, you can take $f(x) = \sin(4x)$ (which is $\pi/2$-periodic) and $g(x) = \arccos x$. You can view $f:\Reals \to [-1, 1]$ and $g:[-1, 1] \to [0, \pi]$. The composition therefore sends $\Reals$ to $[0, \pi]$.
To sketch the graph, it's enough to plot $g \circ f$ over one period of $f$, i.e., over any convenient interval of length $\pi/2$, and then to "extend by periodicity", a fancy term for continuing the graph by shifting the existing curve horizontally by integer multiples of the period, $\pi/2$.
To see why your computation leads to a questionable conclusion, let's examine each step carefully.
If $$ y = \arccos\bigl(\sin(4x)\bigr), \tag{1} $$ then $$ \cos(y) = \sin(4x) \tag{2} $$ by taking cosines of both sides. However, (2) does not imply (1); by definition, $0 \leq \arccos(*) \leq \pi$, so (2) implies (1) only under the additional hypothesis $0 \leq y \leq \pi$.
To investigate the derivative, it's straightforward to calculate one-sided limits of $(g \circ f)'$ at $(\pi/8) + k\pi/4$, the points where $f$ achieves the value $\pm1$ and the graph of $g \circ f$ has corners.