We can use chain rule here. In order to differentiate a function of a function, say #y, =f(g(x))#, where we have to find #(dy)/(dx)#, we need to do substitute #u=g(x)#, which gives us #y=f(u)#. Then we need to use a formula called Chain Rule, which states that #(dy)/(dx)=(dy)/(du)xx(du)/(dx)#.
Here we have #y=tan3x-cot3x#. Let #u=3x#
Then #y=tanu-cotu# and #(dy)/(du)=sec^2u-(-csc^2u)#
= #sec^2u+csc^2u#
Now as #u=3x#, we have #(du)/(dx)=3#
and hence #(dy)/(dx)=(dy)/(du)xx(du)/(dx)#
= #(sec^2u+csc^2u)xx3#
= #(sec^2 3x+csc^2 3x)xx3#
= #(1/(cos^2 3x)+1/(sin^2 3x))xx3#
= #(3(cos^2 3x+sin^2 3x))/(cos^2 3xsin^2 3x)#
= #3sec^2 3xcsc^2 3x#