In the book they have given it as x/2 and on differentiation, it is 1/2. But, my friend proceeded by rationalizing the denominator by multiplying the conjugate. I could not understand which method I have to adopt and why? it was given only that x lies between 0 and Pi/2. That means x is in the first quadrant.
$\sin \dfrac{x}{2} + \cos \dfrac{x}{2}\ge 0$ when $4n\pi -\dfrac{\pi}{2} \le x \le \dfrac{3\pi}{2}, n\in \mathbb{N}$ (this covers quadrant 1 when $n=0$).
$\sin \dfrac{x}{2}-\cos \dfrac{x}{2} < 0$ when $4n\pi - \dfrac{3\pi}{2} < x < 4n\pi + \dfrac{\pi}{2}, n \in \mathbb{N}$ (this covers quadrant 1 when $n=0$).
So, $\left| \sin \dfrac{x}{2} + \cos \dfrac{x}{2} \right| = \sin \dfrac{x}{2} + \cos \dfrac{x}{2}$ in quadrant 1 while $\left| \sin \dfrac{x}{2} - \cos \dfrac{x}{2} \right| = \cos \dfrac{x}{2} - \sin \dfrac{x}{2}$ when x is in quadrant 1.
Then, you have:
$\displaystyle \dfrac{ \left| \sin \dfrac{x}{2} + \cos \dfrac{x}{2} \right| + \left| \sin \dfrac{x}{2} - \cos \dfrac{x}{2} \right| }{ \left| \sin \dfrac{x}{2} + \cos \dfrac{x}{2} \right| - \left| \sin \dfrac{x}{2} - \cos \dfrac{x}{2} \right| } = \dfrac{2\cos \dfrac{x}{2} }{2\sin \dfrac{x}{2}}$ when x is in quadrant 1.
Thus, you have $\cot^{-1}\cot \dfrac{x}{2} = \dfrac{x}{2}$ when x is in quadrant 1. Your method works just fine. You just needed to check the intervals where each answer was true.