\begin{align} y&=f(x)^{g(x)}\\\ \ln y&=g(x)\ln f(x)\\\ \dfrac{dy}{dx}\dfrac{1}{y}&=g'(x)\ln f(x)+g(x)\dfrac{f'(x)}{f(x)}\\\ \dfrac{dy}{dx}&=y[g'(x)\ln f(x)+g(x)\dfrac{f'(x)}{f(x)}]\\\ \dfrac{dy}{dx}&=f(x)^{g(x)}\left[g'(x)\ln f(x)+g(x)\dfrac{f'(x)}{f(x)}\right]\\\ \end{align}