I've hit a wall on the above question and was unable to find any online examples that also contain trig in $f(g(x))$. I'm sure I am missing something blatantly obvious but I can't quite get it.
$$ g(x)=3x+4 , \quad f(g(x)) = \cos\left(x^2\right)$$
So far I've managed to get to the point where I have $f(x+8) = \cos\left(x^2\right)$, by solving $g^{-1}(g(x))$ (loosely based on the last bit of advice here), but I can't make that final connection.
My best attempt so far was $f(x)=\cos(x^2-16x+64)$, but while that does result in $x^2$, it still ends up wrong due to it being cosine.