Explain this chain rule for differentiating $y=xe^{-kx}$ I am asked to differentiate $$y=xe^{-kx}$$
The answer I am given is $$e^{-kx}(-kx+1)$$
I understand that when e is differentiated, it remains the same. 
I also see the product rule, but I'm not sure where the +1 comes from. 
The book has a habit of considering odd variables(K), to be a constant and not telling me. Is the +1 coming from -k being differentiated as a constant, or is it from the x out front?
Or, if I'm completely wrong, please walk me through it. 
 A: Usually, $k$ in the power, as I have seen through Calculus texts; is a constant. So we have $$y=x\exp(-kx)\longrightarrow y'=1\times \exp(-kx)+x\times(-k)\exp(-kx) $$ Now factor the term $\exp(-kx)$.
A: It comes from differentiating $x$ in front:
$$\frac{d(xe^{-kx})}{dx}=x\frac{de^{-kx}}{dx}+\frac{dx}{dx}e^{-kx}=-kxe^{-kx}+e^{-kx} $$
A: Maybe it's easier to see what happens if you split it a bit. Denote like this:
$$f(x) = x, \quad g(x) = e^x, \quad h(x) = -kx.$$
Then
$$y = f(x) g(h(x)).$$
Derive:
\begin{align}
y' &= \left( f(x) g(h(x)) \right)' = f'(x) g(h(x)) + f(x) \left( g(h(x)) \right)' \\
&= f'(x) g(h(x)) + f(x) g'(h(x)) h'(x) \\
&= 1 \cdot e^{-kx} + f(x) e^{-kx} \cdot (-k) = (1-kx) e^{-kx}.
\end{align}
A: The product rule tells us that to differentiate $$y=f(x)g(x)$$ we get $$y'=f'g+g'f$$ or in other notation $$\frac {dy}{dx}=g\frac{df}{dx}+f\frac{dg}{dx}$$
Here we take $f(x)=x$ so that $f'(x)=1$ and $g(x)=e^{-kx}$.
For $g$ we use the chain rule - to differentiate $g(x)=p(q(x))$ where we know how to differentiate $p$ and $q$. 
We can put $q(x)=-kx$ so that $q'=-k$ and $p(q)=e^q$ so that $\frac{dp}{dq}=e^q=p=e^{-kx}$. 
From this we deduce that $g'=-ke^{-kx}$
Putting the pieces carefully together, we obtain $$y'=e^{-kx}\cdot 1+(-ke^{-kx})\cdot x = e^{-kx} \cdot (1-kx)$$
You will find it useful to work through $\frac {d(e^{ax})}{dx}=ae^{ax}$ - which we applied here with $a=-k$. Though you can derive this every time using the chain rule, it is a standard fact which you should know - and knowing it greatly simplifies questions like this one.
