<s>[INST] About proof: $\cot^{-1}\left(\frac{\sqrt{1+\sin x}+\sqrt{1-\sin x}}{\sqrt{1+\sin x}-\sqrt{1-\sin x}}\right)=\frac x2$ I have the following question:

Prove that: $$ \cot^{-1}\Biggl(\frac{\sqrt{1+\sin x} + \sqrt{1-\sin x}}{\sqrt{1+\sin x} - \sqrt{1-\sin x}}\Biggl) = \frac x2, \ x \in \biggl(0, \frac \pi4\biggl) $$
The solution: 


My question is about the second step (i.e., highlighted). We know that it has came from the following resolution: $$ \sqrt{1\pm \sin x} = \sqrt{\sin^2\frac x 2 + \cos^2\frac x 2 \pm2\sin\frac x 2\cos\frac x 2} = \pm \biggl( \cos\frac x 2 \pm \sin\frac x 2 \ \biggl) $$
I've included the $\pm$ symbol in accordance with the standard definition of square root. The above solution uses the positive resolution (i.e., $ \cos\frac x 2 - \sin\frac x 2 $) for $ \sqrt{1- \sin x} $. But, if I use the negative one, then the result changes. The sixth step changes to: $$ \cot^{-1}\biggl(\tan\frac x 2\biggl) = \cot^{-1}\Biggl(\cot\left(\frac \pi 2 - \frac x 2\right)\Biggl) $$
which yield the result: $$ \frac \pi 2 - \frac x 2 $$
Mathematically, this result is different from that provided in the RHS of question.
Is the question statement wrong or I've been hacked up?
 [/INST] We see that
$$\frac{\sqrt{1+\sin x} + \sqrt{1-\sin x}}{\sqrt{1+\sin x} - \sqrt{1-\sin x}}$$
$$= \sqrt{(\frac{\sqrt{1+\sin x} + \sqrt{1-\sin x}}{\sqrt{1+\sin x} - \sqrt{1-\sin x}})^2}$$
$$= \sqrt{\frac{1+\sin x +1-\sin x + 2\cdot\sqrt{1-\sin^2 x}}{1+\sin x +1-\sin x -2\cdot\sqrt{1-\sin^2 x}}}$$
$$= \sqrt{\frac{1+\cos x}{1-\cos x}}$$
$$= \sqrt{\frac{2\cdot\cos^2\frac{x}{2}}{2\cdot\sin^2\frac{x}{2}}}$$
$$= \cot \frac{x}{2}$$
And hence,
$$\cot^{-1} (\frac{\sqrt{1+\sin x} + \sqrt{1-\sin x}}{\sqrt{1+\sin x} - \sqrt{1-\sin x}})$$
$$= \cot^{-1} (\cot \frac{x}{2})$$
$$= \frac{x}{2}$$
Note: as $x\in [0,\frac{\pi}{4}]$, $\sqrt{1-\sin x} \le \sqrt{1+\sin x}$.
And hence
$$0\le\frac{\sqrt{1+\sin x} + \sqrt{1-\sin x}}{\sqrt{1+\sin x} - \sqrt{1-\sin x}}$$
</s>