First, use the chain rule to deal with the exponent. One way to visualize this would be to set \(u=\cos{3x}\), allowing us to use the exponent rule.
$$\frac{d}{dx}(\cos^2{3x}) = \frac{d}{dx}(u^2) = 2u^{2-1}\cdot \frac{du}{dx} = 2u\cdot\frac{du}{dx}$$
To obtain \(\frac{du}{dx}\), we must use chain rule again. We can set \(w=3x\) and use the derivative rule for \(\cos{w}\).
$$\frac{du}{dx}=\frac{d}{dx}(\cos{3x})=\frac{d}{dx}(\cos{w})=-\sin{w}\cdot\frac{dw}{dx} $$
The constant rule is shown below to find our last piece of information.
$$ \frac{dw}{dx}=\frac{d}{dx}(3x)=3 $$
Putting everything together,
$$\frac{d}{dx}(\cos^2{3x})=2\cdot\cos{3x}\cdot-\sin{3x}\cdot3 $$
$$ = \boxed{-6\sin{3x}\cos{3x}} $$
We can apply the chain rule multiple times through composition of functions.
For this question,
$$f(x)=3x \text{ and } f'(x)=3$$
$$g(x)=\cos{x} \text{ and } g'(x)=-\sin{x}$$
$$h(x)=x^2 \text{ and } h'(x)=2x$$
$$k(x)=h\Big(g\big(f(x)\big)\Big)$$
Applying the chain rule twice,
$$ k'(x)=h'\Big(g\big(f(x)\big)\Big)\cdot g'\big(f(x)\big)\cdot f'(x)) $$
$$={h'(\cos{3x})}\cdot g'(3x) \cdot f'(x) $$
$$= 2\cos{3x}\cdot-3\sin{3x}\cdot3 $$
$$ = \boxed{-6\sin{3x}\cos{3x}} $$