Recall the double angle identities:
cos(x/2) = cos(x/4 + x/4) = cos²(x/4) - sin²(x/4)
sin(x/2) = sin(x/4 + x/4) = 2 sin(x/4) cos(x/4)
So
(1 + cos(x/2) - sin(x/2)) / (1 - cos(x/2) - sin(x/2))
= (1 + cos²(x/4) - sin²(x/4) - 2 sin(x/4) cos(x/4)) / (1 - cos²(x/4) + sin²(x/4) - 2 sin(x/4) cos(x/4))
sin²(x) + cos²(x) = 1, so
(1 + cos(x/2) - sin(x/2)) / (1 - cos(x/2) - sin(x/2))
= (2 cos²(x/4) - 2 sin(x/4) cos(x/4)) / (2 sin²(x/4) - 2 sin(x/4) cos(x/4))
= (cos(x/4) / sin(x/4)) • (2 cos(x/4) - 2 sin(x/4)) / (2 sin(x/4) - 2 cos(x/4))
= (cos(x/4) / sin(x/4)) • (-1)
= - cot(x/4)