Given:
#f(theta)=cot(theta/2)+3sin(theta/4+pi/2)#
#cot(theta/2)=cos(theta/2)/sin(theta/2)#
#sin(theta/4+pi/2)=sin(pi/2+theta/4)#
#=cos(theta/4)#
#3sin(theta/4+pi/2)=3cos(theta/4)#
Thus,
#cot(theta/2)+3sin(theta/4+pi/2)=cos(theta/2)/sin(theta/2)+3cos(theta/4)#
#cos(theta/2)=cos2(theta/4)#
#cos(theta/2)=cos^2(theta/4)-sin^2(theta/4)#
#sin(theta/2)=sin2(theta/4)#
#sin(theta/2)=2sin(theta/4)cos(theta/4)#
Thus,
#cot(theta/2)=(cos^2(theta/4)-sin^2(theta/4))/(2sin(theta/4)cos(theta/4)#
#cot(theta/2)=1/2(cot(theta/4)-tan(theta/4))#
Now,
#cot(theta/2)+3sin(theta/4+pi/2)=1/2(cot(theta/4)-tan(theta/4))+3cos(theta/4)#
#f(theta)=1/2(cot(theta/4)-tan(theta/4))+3cos(theta/4)#