Question: We all know this rule:

> 
> $\text{If } y = a^{f(x)} \text{ then } y' = a^{f(x)} \: f'(x)\ln a$
> 
> 
> 

In my book there is the example:

Find $\frac{d}{dx}\left((x^{2} + 1)^{\sin x}\right)$

According to the rule, my answer is:

$(x^{2} + 1)^{\sin x} \cdot \cos x \cdot \ln(x^{2} + 1)$

But the answer of the book was:

$$(x^{2} + 1)^{\sin x}\left(\frac{2x \sin x}{x^{2} + 1} + \cos x \cdot \ln(x^{2} + 1)\right)$$

So, where did $\frac{2x \sin x}{x^{2} + 1}$ come from?

Answer: 
The rule that you quote is only valid if a is a constant.
The rule that you have given is for $\textit{constant}$ $a$, while the base of your function is a $\textit{function}$. So the rule does not apply here. 

To fix this, let $f(x) = (x^2 + 1)^{\sin(x)}$ and consider $\ln(f(x))$. Differentiate the new function, while also utilizing a nice property of exponents inside logarithmic functions, and try to deduce the derivative of the original function from this.

---