Find $y'$ if $y=\cos^{-1}(\sin x)$
It is solved as $$ y=\cos^{-1}(\cos(\pi/2-x))=\frac{\pi}{2}-x\\ y'=-1 $$
My Attempt
The function is defined for all real numbers. $$ y'=\frac{-\cos x}{\sqrt{1-\sin^2x}}=\frac{-\cos x}{\sqrt{\cos^2x}}=\frac{-\cos x}{|\cos x|}=\pm1 $$
Even in the first method isn't it the right way to solve $$ y=\cos^{-1}(\cos(\pi/2-x))=\frac{\pi}{2}-x\\\implies\cos y=\cos(\pi/2-x)\\ \implies y=2n\pi\pm\big(\frac{\pi}{2}-x\big)\\ \implies y'=\pm1 $$
Is $y'=-1$ a complete solution ?
The function $\cos\mid_{[0,\pi]}:[0,\pi]\to[-1,1]$ is bijective and has the inverse $\arccos:[-1,1]\to [0,\pi]$ and $\arccos(\cos(x))=x$ for all $x\in[0,\pi]$ while $\cos(\arccos(y))=y$ for all $y\in[-1,1]$. Further $\cos\mid_{[0,\pi]}'(0)=\cos\mid_{[0,\pi]}'(\pi)=0$ and therefore $\arccos$ is just differentiable on $(-1,1)$.
Hence $\arccos(\cos(\frac{\pi}2-x))=\frac{\pi}2-x$ holds just if $\frac{\pi}2-x\in [0,\pi]$, so $x\in \left[-\frac{\pi}2,\frac{\pi}2\right]$.
That's why you should use the chain rule and note that $y$ is not differentiable if $\sin(x)=\pm1$ which is when $x=\frac{\pi}2+k\pi$ for some $k\in\mathbb Z$. Then, your computation are correct: $$ y'=-\frac{\cos(x)}{|\cos(x)|}. $$ But you can't just say $y'=\pm 1$. There is just one derivative and it depends on $x$. $$ y'=-\frac{\cos(x)}{|\cos(x)|}=\begin{cases} -1 & x\in \left(-\frac{\pi}2+2k\pi,\frac{\pi}2+2k\pi\right)\\ 1 & x\in \left(\frac{\pi}2+2k\pi,\frac{3\pi}2+2k\pi\right) \end{cases} $$ where $k\in\mathbb Z$.
If you plot the graph, then the result isn't even suprising:
https://www.desmos.com/calculator/odco70auib