Why does the derivative rule $a^x = \ln(a)\cdot a^x$ fail for $e^{-x}$? In my textbook there is a derivative rule stated as folows:
$$f(x)=a^x \implies f'(x)=\ln(a) \cdot  \ a^x$$
But when I try to apply this rule to $e^{-x}$ I get:
$$\ln(e) \cdot \  e^{-x} = e^{-x}$$
Which is not correct because the derivative of $e^{-x}$ is $-e^{-x}$.
What's going wrong here?
 A: The thing you have overlooked is that there should be a minus sign because the derivative of $-x$ is $-1$. The correct formula is
$$\frac{d}{dx}a^{f(x)}= \frac{d}{dx}e^{f(x)\ln a}=f'(x)(\ln a) e^{f(x)\ln a}= f'(x)(\ln a )a^{f(x)}$$
This follows from the chain rule.
A: That rule applies for functions of the form $a^x$.  The function $e^{-x}$ is not in that form, because it has  $-x$ in the exponent, not  $x$.
If you want, you can write $e^{-x}$ as $\left(\frac 1e\right)^x$ and then it does have the form $a^x$, with $a=\frac 1e$.  Then if you apply the rule you get  $$\frac{d}{dx}\left(\frac 1e\right)^x = \left(\ln \frac 1e \right)\cdot \left(\frac 1e\right)^x = -1\cdot \left(\frac 1e\right)^x  = -e^{-x}$$ which is correct.

Another thing you could do is to consider a generalization of the $a^x$ rule,  that $$\frac d{dx} a^{f(x)} = \color{darkred}{\frac{df}{dx}}\cdot \color{darkblue}{\ln a }\cdot a^{f(x)}$$ which follows by applying the chain rule to your rule for $a^x$.  Then taking $f(x) = -x$ and $a=e$ we obtain $$\frac d{dx} e^{-x} = \color{darkred}{\left(\frac d{dx} (-x)\right)} \cdot \color{darkblue}{\ln e }\cdot e^{-x} = \color{darkred}{-1}\cdot \color{darkblue}{1} \cdot e^{-x} = -e^{-x}.$$
