# What is wrong with this derivative?

I have the simple function:

$$f=\ln(ka^k)$$

Here are two methods of taking the derivative with respect to $k$:

Method 1:

$$\frac{\partial f}{\partial k}=\frac{\partial}{\partial k}(\ln(ka^k))=\frac{1}{ka^k}(a^k+k^2a^{k-1})=\frac 1k+\frac ka$$

Method 2:

$$\frac{\partial f}{\partial k}=\frac{\partial}{\partial k}(\ln(ka^k))=\frac{\partial}{\partial k}(\ln(k)+k\ln a)=\frac 1k+\ln a$$

How come the result is not the same? Thanks a lot for explaining!

• Your derivative of $a^k$ with respect to $k$ is incorrect. You differentiated with respect to $a$. – Daniel Fischer Oct 24 '15 at 9:49
• @DanielFischer A-ha! Thank you. – space_voyager Oct 24 '15 at 9:50

Method 1 : Let $f(x) = xa^x$ we have $$f'(x) = a^x + x\frac{d}{dx}a^x = a^x + a^x \ln a$$ Hence if $g(x) = \ln (x)$ we have $$g'(f(x)) = g'(f(x))f'(x) = \frac{a^x + a^x \ln a}{xa^x} = \frac{1}{x} + \ln a$$ You computed the derivative of $f(x) = xa^x$ incorrectly.