I know this is a piece of elementary calculus but I just worked it out from (more or less) first principles (as I knew what the answer was but did not know why).
Let what is ?
where is some constant. Hence or
and so and so .
And , so
Applying the chain rule and so
Now I have written it all out I know there are redundant steps in there, but this is how I (re)discovered it…