TITLE: Differentiating $\;y = x a^x$
QUESTION [5 upvotes]: My attempt:
$$\eqalign{
  y &= x{a^x}  \cr 
  \ln y &= \ln x + \ln {a^x}  \cr 
  \ln y &= \ln x + x\ln a  \cr 
  {1 \over y}{{dy} \over {dx}} &= {1 \over x} + \left(x \times {1 \over a} + \ln a \times 1\right)  \cr 
  {1 \over y}{{dy} \over {dx}} &= {1 \over x} + \left({x \over a} + \ln a\right)  \cr 
  {1 \over y}{{dy} \over {dx}} &= {1 \over x} + \left({{x + a\ln a} \over a}\right)  \cr 
  {1 \over y}{{dy} \over {dx}} &= {{a + {x^2} + ax\ln a} \over {ax}}  \cr 
  {{dy} \over {dx}} &= {{a + {x^2} + ax\ln a} \over {ax}} \times x{a^x}  \cr 
  {{dy} \over {dx}} &= {{x{a^{x + 1}} + {x^3}{a^x} + {a^{x + 1}}{x^2}\ln a} \over {ax}}  \cr 
  {{dy} \over {dx}} &= {a^x} + {x^2}{a^{x - 1}} + {a^x}x\ln a  \cr 
  {{dy} \over {dx}} &= {a^x}\left(1 + {x^2}{a^{ - 1}} + x\ln a\right)  \cr 
  {{dy} \over {dx}} &= {a^x}\left({{a + {x^2} + x\ln a} \over a}\right) \cr} $$
However the answer in the back of the book is:
$${dy \over dx} = a^x (1 + x\ln a)$$
What have I done wrong?

REPLY [5 votes]: When going from line
$$\ln y = \ln x + x \ln a$$
to
$$\frac{1}{y} \frac{dy}{dx} = \frac{1}{x} + (x \times \frac{1}{a} + \ln a \times 1)$$
you made a mistake: when you tried to differentiate $x \ln a$ with respect to x via the product rule, you differentiated $\ln a$ with respect to a, turning it into $\frac{1}{a}$, when you should have done so with respect to x, since you were differentiating the whole product with respect to x. With respect to x, $\ln a$ is a constant. Differentiating the constant (with respect to x) $\ln a$ yields $0$, and thus you'd have $(x \times 0 + \ln a \times 1) = \ln a$. So the above line should be
$$\frac{1}{y} \frac{dy}{dx} = \frac{1}{x} + \ln a$$.
Now multiply by $y = xa^x$ and you should have your answer.
Note, of course, that you don't actually need the product rule: since $\ln a$ is constant, you can just use the rule $\frac{d}{dx} k f(x) = k \frac{df}{dx}$. And this gives $\frac{d}{dx} x \ln a = \frac{d}{dx} (\ln a)x = \ln a \frac{d}{dx} x = \ln a$.
Edit: There's a second mistake in going from the second-to-last line to the last one. $a^x (1 + x^2 a^{-1} + x \ln a) = a^x (\frac{a + x^2 + ax \ln a}{a})$ and not $a^x (\frac{a + x^2 + x \ln a}{a})$ -- but the first mistake makes this irrelevant.