This question already has an answer here:

I want to calculate the derivative of a function with respect to, not a variable, but respect to another function. For example: $$g(x)=2f(x)+x+\log[f(x)]$$ I want to compute $$\frac{\mathrm dg(x)}{\mathrm df(x)}$$ Can I treat $f(x)$ as a variable and derive "blindly"? If so, I would get $$\frac{\mathrm dg(x)}{\mathrm df(x)}=2+\frac{1}{f(x)}$$ and treat the simple $x$ as a parameter which derivative is zero. Or I should consider other derivation rules?


marked as duplicate by Namaste, Brian Borchers, JonMark Perry, Daniel McLaury, Claude Leibovici Mar 19 '18 at 8:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ This is a good question because it appears a lot, but for future people: This notation or question makes no sense. $g$ is a function with it's own domain and range. You can only take derivatives of $g$ with respect to it's domain. That's it. By writing $\frac{d}{df(x)}$ you are taking derivatives over what set? This notation has to mean that you are taking derivatives over the range set of $f$. Therefore this derivative, $\frac{d}{df(x)}$ only applies to functions whose domain set is this range set of $f$. $g$ is defined over the set $X$. $f$ is defined over the set $X$. You cannot apply $\endgroup$ – DWade64 Oct 19 '18 at 13:51
  • $\begingroup$ $\frac{d}{df(x)}$ to either of these functions! You can apply $\frac{d}{df(x)}$ to the inverse function of $f$, which is $f^{-1}$, because this function has the correct domain that the derivative is referring to. You can also apply $\frac{d}{df(x)}$ to the composition function $g \circ f^{-1}$, because this function also has the correct domain that the derivative is referring to. The answer given to this question is the chain rule applied to this composite function (you apply the chain rule to composite functions) $\endgroup$ – DWade64 Oct 19 '18 at 13:54

$$\frac{dg(x)}{df(x)} = \frac{dg(x)}{dx} \cdot \frac{1}{f'(x)} = \frac{g'(x)}{f'(x)}$$

In your example,

$$g'(x) = 2f'(x) + 1 + \frac{f'(x)}{f(x)}$$


$$\frac{dg(x)}{df(x)} = \frac{2f'(x) + 1 + \frac{f'(x)}{f(x)}}{f'(x)} = 2 + \frac{1}{f'(x)} + \frac{1}{f(x)}$$

  • 1
    $\begingroup$ Thanks, can you give me the name of the theorem for this property? Or a link so I can take a look to the proof? $\endgroup$ – Marco Oct 2 '14 at 13:29
  • 3
    $\begingroup$ It's all Chain Rule. It's easier to see in Leibniz notation. $\displaystyle \frac{dg}{df} = \frac{dg}{dx}\cdot \frac{dx}{df} = \frac{\frac{dg}{dx}}{\frac{df}{dx}}=\frac{g'(x)}{f'(x)}$. The other application of Chain Rule in differentiating $\ln f(x)$ should be quite obvious. $\endgroup$ – Deepak Oct 2 '14 at 14:39
  • $\begingroup$ What happens in the case $f(x) = 0$? Does the derivative simply not exist? My guess would be that the conclusion $\dfrac{dx}{df} = \dfrac{df}{dx}$ would be wrong here and thus the whole thing reduces to $2 + \dfrac{1}{f}$ $\endgroup$ – WorldSEnder Jan 20 '16 at 17:08
  • $\begingroup$ If $f(x)$ is identically zero over the domain, then $\frac{dg}{df}$ would not exist. In fact, even if $f(x)$ is a constant non-zero function, $\frac{dg}{df}$ would not exist because $f'(x) = 0$ (identically). If either $f(x)$ or $f'(x)$ (or both) are zero at a particular point $x_0$ then $\frac{dg}{df}$ would not exist at that point $x_0$. Also, what you wrote ($\frac{dx}{df} = \frac{df}{dx}$) is wrong in any case. The right hand side is the reciprocal of the left hand side, i.e. $\frac{dx}{df} = \frac{1}{\frac{df}{dx}}$ $\endgroup$ – Deepak Jan 20 '16 at 22:54
  • $\begingroup$ @Deepak Actually, I think that if $f'(x_0)=0$ and $f(x_0)=0$, $g'(x)$ might exist. $\endgroup$ – Simply Beautiful Art Oct 2 '16 at 0:31

You can not. You have to derivate $f(x)$ as function.

$g'(x) = 2f'(x) + 1 + {f'(x) \over f(x)}$

EDIT: Sorry, That would make $dg(x) \over dx$, Deepak is right.


You could if it were a function of $f(x)$ But it's not, due to the $x$ term.

  • $\begingroup$ So, is it true that the derivative of $g(x)=2f(x)+\log[f(x)]$ wrt $f(x)$ is equal to : $\frac{\mathrm dg(x)}{\mathrm df(x)}=2+\frac{1}{f(x)}$ ? Applying @deepak definition it seems so. $\endgroup$ – kalmanIsAGameChanger Feb 15 '18 at 10:20

Not the answer you're looking for? Browse other questions tagged or ask your own question.