Substitute t=3x:
int dx/(1-cos3x) = 1/3 int (dt)/(1-cost)
Use now the trigonometric identity:
cost= (1-tan^2(t/2))/(1+tan^2(t/2))
So that:
1/(1-cost) = 1/(1-(1-tan^2(t/2))/(1+tan^2(t/2)))
1/(1-cost) = (1+tan^2(t/2))/((1+tan^2(t/2))-(1-tan^2(t/2)))
1/(1-cost) = (1+tan^2(t/2))/(1+tan^2(t/2)-1+tan^2(t/2))
1/(1-cost) = (1+tan^2(t/2))/(2tan^2(t/2))
And as:
1+tan^2alpha = 1+ sin^2alpha/cos^2alpha = (cos^2alpha+sin^2alpha)/cos^2alpha = 1/cos^2alpha = sec^2alpha
we get:
int (dt)/(1-cost) = int sec^2(t/2)/(2tan^2(t/2))dt
Substitute now:
u=tan(t/2)
du=1/2sec^2(t/2)dt
and we have:
int sec^2(t/2)/(2tan^2(t/2))dt = int (du)/u^2 = -1/u+C
and undoing the substitution:
int (dt)/(1-cost) = -1/tan(t/2)+C = -cot(t/2)+C
int dx/(1-cos3x) = -1/3cot((3x)/2)+C