In Apostol exercise set 6.22, question 15, the following derivative is offered to evaluate:
$$f(x) = \arcsin(\sin(x))$$
I solve it using this: $\sin^{-1}(\sin(x)) = x$. Then the derivative is simply $1$. And it makes a lot of sense. However, the answer in Apostol is
$$\frac{\cos(x)}{|\cos(x)|}\,,\quad x \neq (k + \frac{1}{2})\pi, k \in \mathbb{Z}$$
I understand how he got it: he used the direct definition of the derivative as such: $$f'(x) = \frac{1}{\sqrt{1 - \sin^2(x)}} \times \cos(x) = \frac{\cos(x)}{\sqrt{\cos^2(x)}} = \frac{\cos(x)}{|\cos(x)|}$$ but I think this is wrong.
In Apostol, the $\arcsin$ is clearly defined on $x \in [-1, 1]$ and its range is $f(x) \in [-\frac{\pi}{2}, \frac{\pi}{2}]$. Here is a picture which depicts it exactly as in Apostol:
$\hskip2in$ 
Thus, whatever value the sine takes in $[-1, 1]$, the corresponding range has to be from $-\pi/2$ and $\pi/2$, where $\cos(x) > 0$, so the identity makes no sense in terms of writing it: the derivative is simply $f'(x) = x' = 1$. The reference answer in Apostol seems to violate the inverse assumption, because the comparison of the simplified expression and Apostol answer do not match:
$$f'(x) = \frac{d}{dx}\arcsin(\sin(x)) = \frac{d}{dx}x = 1 \neq \frac{\cos(x)}{|\cos(x)|}$$
Is it the correct reasoning and Apostol solution is wrong, or I am wrong about domains here?