<s>[INST] Finding the the derivative of $y=\sqrt{1-\sin x}; 0A question I'm attempting is:

Find the derivative of $ y = \sqrt {1 - \sin x} ; 0 < x <\pi/2$.

I did this:
$y = \sqrt {1 - \sin x} = \sqrt {\cos^2\frac{x}{2} + \sin^2\frac{x}{2} - 2\sin \frac{x}{2}\cos \frac{x}{2}} = \sqrt { (\sin \frac{x}{2}-\cos \frac{x}{2})^2} = \sin \frac{x}{2} - \cos \frac{x}{2}$
So,  $\frac{dy}{dx} = \frac{1}{2} \cdot (\cos\frac{x}{2} + \sin\frac{x}{2})$. 
But apparently this is wrong. The correct solution is:
$\frac{dy}{dx} = -\frac{1}{2}\cdot(\cos\frac{x}{2} + \sin\frac{x}{2})$. 
So I want to know what I have done wrongly here. Why is my answer not right?
 [/INST] Let apply chain rule
$$\left( \sqrt{f(x)} \right)'=\frac{f'(x)}{2\sqrt{f(x)}}=\frac{-\cos x}{2\sqrt {1 - \sin x}}=\frac12\frac{\sin^2 x/2-\cos^2 x/2}{(\cos x/2-\sin x/2)}=\\=\frac12\frac{ (\sin x/2+\cos x/2)(\sin x/2-\cos x/2) }{(\cos x/2 - \sin x/2)}=-\frac12(\sin x/2+\cos x/2)$$
Note indeed that for $0<x<\pi/2$ since


*

*$\cos x/2 >0$

*$0<\tan x/2<1$


$$\cos x/2-\sin x/2=\cos x/2\cdot(1-\tan x/2)>0$$
</s>