We know that, #tan3x=(3tanx-tan^3x)/(1-3tan^2x)#.
#:. cot3x=1/(tan3x)=(1-3tan^2x)/(3tanx-tan^3x)#.
Let, #tan(A/2)=t#. Then,
#cot(A/2)-3cot(3A/2)=1/t-(3(1-3t^2))/(3t-t^3)#,
#=1/t-(3(1-3t^2))/(t(3-t^2)#,
#={(3-t^2)-(3-9t^2)}/(t(3-t^2)#,
#=(8t)/(3-t^2)#,
#={(8t)/(1+t^2)}-:{(3-t^2)/(1+t^2)}#,
#={(8t)/(1+t^2)}-:{{(1+t^2)+(2-2t^2)}/(1+t^2)}#,
#={(8t)/(1+t^2)}-:{(1+t^2)/(1+t^2)+(2(1-t^2))/(1+t^2)}#,
#={4((2t)/(1+t^2))}-:{1+2((1-t^2)/(1+t^2))}#.
Since, #sinA=(2tan(A/2))/(1+tan^2(A/2)), and, cos2y=(1-tan^2(A/2))/(1+tan^2(A/2))#,
#cot(A/2)-3cot(3A/2)=4sinA-:(1+2cosA)#, as desired!