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?
 A: Hint: $y = |\sin(x/2)-\cos(x/2)|$  and $|\sin(x/2)-\cos(x/2)|=\color{red}{-}(\sin(x/2)-\cos(x/2))$ for $0 \le x \le \pi/2$.
A: 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$$
A: $$y = \sqrt {1 - \sin x} ; 0 < x <\pi/2$$
$$ y' = \frac {-\cos x}{2 \sqrt {1 - \sin x}}$$
$$=\frac {-\cos x\sqrt {1 + \sin x  }}{2 \cos x}$$
$$=-\frac {\sqrt {1 + \sin x}}{2}=-\frac12(\sin x/2+\cos x/2)$$
Note that $$(\sin x/2+\cos x/2)^2=1+2\sin x/2\cos x/2=1+\sin x$$
A: An option:
$y^2 = 1-\sin x$; $0\lt x\lt π/2.$
Differentiate both sides with respect to x:
$2y\dfrac{dy}{dx} = -\cos x;$
Since $y \not =0:$
$\dfrac{dy}{dx} = -\dfrac{\cos x}{2\sqrt{1-\sin x}}$.
A: $$y=\sqrt {1-\sin x}$$
$$\ln y= \frac 12 \cdot \ln (1-\sin x)$$
$$\Rightarrow \frac 1y \frac {dy}{dx}=\frac 12\left (\frac {-\cos x}{1-\sin x}\right) $$
$$\Rightarrow \frac {dy}{dx}=\frac {-\cos x}{2\sqrt {1-\sin x}}$$
On rationalisation of denominator this turns out to be $$-\frac 12 (\sin x/2 +\cos x/2)$$
