Given $g(x)$ and $f(g(x))$, solve for $f(x)$.
Hint: $(f \circ g) \circ g^{-1} =f \circ (g \circ g^{-1}) = f$
$$y=g(x)=3x+4$$ $$x=\frac{y-4}{3} \Rightarrow g^{-1}(x)=\frac{x-4}{3}$$ $$f=f \circ (g \circ g^{-1})=(f \circ g) \circ g^{-1} =\cos \left(\frac{x-4}{3} \right)^2 $$