Which differential coefficient is correct and why? Given $$\cot{\theta} = \frac{\sqrt{1+\sin(x)}+\sqrt{1-\sin(x)}}{\sqrt{1+\sin(x)}-\sqrt{1-\sin(x)}}$$
I have to find its  differential coefficient w.r.t $x$ i.e. $\dfrac{d \theta }{dx}$.
Now I can find it in the following two ways:
(1). When I write $\sqrt{1-\sin(x)}=\cos(x/2)-\sin(x/2)$, I get 
    $$\cot(\theta) = \frac{\cos(x/2) + \sin(x/2) + \cos(x/2) - \sin(x/2)}{\cos(x/2) + \sin(x/2) - \cos(x/2) + \sin(x/2)} = \cot(x/2)$$
    $$\theta=x/2 \implies \frac{d \theta}{dx} = \frac12$$
(2). When I write $\sqrt{1-\sin(x)}=\sin(x/2)-\cos(x/2)$, I get
     $$\cot(\theta) = \frac{\cos(x/2) + \sin(x/2) - \cos(x/2) + \sin(x/2)}{\cos(x/2) + \sin(x/2) + \cos(x/2) - \sin(x/2)} = \tan(x/2)$$
    $$\theta=\pi/2 - x/2 \implies \frac{d \theta}{dx} = -\frac12$$
Which of the above two answers is correct and why? Please help me know it. Thanks.

Neither. When you deal in half-angle formulas, you have to be careful about sign.
Notice that $\sqrt{1-\sin x}$ is always positive, while $\sin (x/2)-\cos(x/2)$ and $\cos(x/2)-\sin(x/2)$ may be positive or negative depending on $x$. The correct statement is $\sqrt{1-\sin x}=|\cos(x/2)-\sin(x/2)|$; from there, you'll need to do some case analysis to compute the derivative you want.
