Getting two different answers on differentiating $\cos^{-1}(\frac{3x+4\sqrt{1-x^2}}{5})$ 
Question given in my book asks to find $\frac{dy}{dx} $ from the following equation.$$y=\cos^{-1}\left(\frac{3x+4\sqrt{1-x^2}}{5}\right)$$


My Attempt:
Starting with substitutions,

*

*Putting $\frac35=\cos\alpha\implies \frac45 = \sin\alpha$.


*Putting $x = \cos\beta\implies \sqrt{1-x^2} = \sin\beta$.
$$\begin{align}&y=\cos^{-1}\Big(\frac{3x+4\sqrt{1-x^2}}{5}\Big)\\ \implies& y = \cos^{-1}\Big(\frac{3}{5}x + \frac{4}{5}\sqrt{1-x^2}\Big)\\\implies& y = \cos^{-1}(\cos\alpha\cos\beta + \sin\alpha \sin \beta)\\\implies& y  = \cos^{-1}[\cos(\alpha-\beta )] \tag{1}\\\implies& y = \alpha-\beta\\\implies& y = \cos^{-1}\left(\frac35\right) - \cos^{-1}(x)\\\implies&\color{blue}{\boxed{ \dfrac{dy}{dx}  =\frac{1}{\sqrt{1-x^2}}}}.\end{align}$$
But, if I consider $(1.)$ again,
$$y = \cos^{-1}\left[\cos\color{red}{(\alpha-\beta)}\right]$$
This is also equals to, $$\cos^{-1}\left[\cos\color{red}{(\beta - \alpha)}\right].$$differentiating this, will give the negative of the answer which I got earlier.
My book shows that $\frac{-1}{\sqrt{1-x^2}}$ is correct. But why?

I think the mistakes lie in the very first step of substitution i.e.,$\frac35=\cos\alpha$ doesn't imply $\frac45 = \sin\alpha$. It should be $\sin\alpha = \pm \frac45$.
Similary $x = \cos\beta$ doesn't imply $\sqrt{1-x^2} = \sin\beta$ instead $\sin\beta = \pm \sqrt{1-x^2}$.
But how can I make sure that in the equation $(1.)$, $(\alpha - \beta)$ lies in the principal branch of the inverse cosine function?
 A: 
Starting with substitutions,

*

*Putting $\frac35=\cos\alpha\implies \frac45 = \sin\alpha$.


Instead, just let $$\alpha=\arccos\frac35$$ so that $\frac45$ indeed equals $\sin\alpha\,$ (no need for any $\pm$ sign).


*

*Putting $x = \cos\beta\implies \sqrt{1-x^2} = \sin\beta$.


Instead, let $$\beta=\arccos x$$ so that $\sqrt{1-x^2}$ indeed equals $\sin\beta\,$ (no need for any modulus sign).

\begin{align}
\implies& y  = \cos^{-1}\left[\cos(\alpha-\beta )\right] \tag{1}\\
\implies& y = \alpha-\beta\end{align}

This is true only for $$x\in[0.6,1],$$ that is, $\beta\in\left[0,\arccos\frac35\right],$ in which case $(\alpha-\beta)$ is in the first quadrant.
For $$x\in[-1,0.6],$$ that is, $\beta\in\left[\arccos\frac35,\pi\right],$ we have $(\alpha-\beta)$ in the third or fourth quadrant, so $y = \arccos(\cos(\alpha-\beta))= \color{red}{\boldsymbol-}(\alpha-\beta).$


$$y=\cos^{-1}\left[\frac{3x+4\sqrt{1-x^2}}{5}\right]$$
\begin{align}
\implies&\dfrac{dy}{dx}  =\frac{1}{\sqrt{1-x^2}}\tag2\end{align}


Note that since $\arccos \theta$ has no derivative at $\pm1$ and $$\frac{3x+4\sqrt{1-x^2}}{5}=\pm1\iff x=0.6,$$ the required derivative is undefined at $x=0.6.$
Furthermore, judging from $(2),$ it is also undefined at $x=\pm1.$
All in all, $$\dfrac{\mathrm dy}{\mathrm dx}=  
\begin{cases}\dfrac{-1}{\sqrt{1-x^2}} &&\text{if }\;-1<x<0.6;
\\\dfrac{1}{\sqrt{1-x^2}} &&\text{if }\;0.6<x<1;
\\\text{undefined} &&\text{otherwise}. \end{cases}$$
According to Wolfram Alpha and Desmos, an equivalent rewrite avoiding cases is $$\dfrac{\mathrm dy}{\mathrm dx}=\frac{4x- 3\sqrt{1 - x^2}}{\sqrt{(1 - x^2)(7 x^2 - 24 \sqrt{1 - x^2} x + 9)}};$$ that is, $$\dfrac{\mathrm dy}{\mathrm dx}=\frac{4x- 3\sqrt{1 - x^2}}{\left| 4x- 3\sqrt{1 - x^2} \right|\sqrt{1 - x^2}}.$$
A: $\cos^{-1}(\cos x)$ needn’t  always be equal to $x$. See the graph below for $\cos^{-1}(\cos x)$ :

When $x < 0$ then $\cos^{-1}(\cos x) = -x$.
 Now if $x < 0.6$ then $\beta >\alpha$ because $\cos^{-1} x$ is a decreasing function in $[-1, 1]$. So ideally there should be two cases, $x <   0.6$ and $x > 0.6$. Also note that in your substitution, you are perfectly entitled to restrict the values of $\alpha$ to $(0,\frac{\pi}{2})$ so there is nothing wrong in taking $\sin x =0.8$.
 As you will notice, there is a discontinuity in the graph at $x= 0.6$: 
