#f(theta)=-cot(theta/2)+2sec(theta/4+pi/2)#
and as #sec(pi/2+A)=-cscA#
#f(theta)=-cot(theta/2)-2csc(theta/4)#
= #-(cos(theta/2)+2)/sin(theta/2)#
As #costheta=2cos^2(theta/2)-1=1-2sin^2(theta/2)#
#cos(theta/2)=sqrt((1+costheta)/2)# and
#sin(theta/2)=sqrt((1-costheta)/2)#
and #f(theta)=-(sqrt((1+costheta)/2)+2)/sqrt((1-costheta)/2)#
= #-(sqrt(1+costheta)+2sqrt2)/sqrt(1-costheta)#
multiplying numerator and denominator by #sqrt(1+costheta)#, we get
#f(theta)=-(sqrt(1+costheta)+2sqrt2)/sqrt(1-costheta)xxsqrt(1+costheta)/sqrt(1+costheta)#
= #(1+costheta+2sqrt(2(1+costheta)))/sintheta#