# Partial derivative: Why does substitution order matter?

Simple example:

$f(x) = x \cdot g(x) \cdot h(x)$

$g(x) = 5x^2$

$h(x) = 2x^3$

First, derive $f$ by $x$, then substitute $g$ and $h$:

$\frac{\partial f}{\partial x} = g(x) \cdot h(x) = 10x^5$

And now the other way round, substitute and then derive:

$\frac{\partial f}{\partial x} = \frac{\partial (10 x^6)}{\partial x} = 60 x^5$

What's wrong here? Why does it matter in which order I subsitute known functions in a partial derivative? What is the meaning of this?

The problem is that you treated $g(x)$ and $h(x)$ as constants. They're not, they depend on $x$. If you take that into account and write $g'(x)$ and $h'(x)$ for their derivatives with respect to $x$, respectively, you'll get the same result regardless of when you substitute for them.

• But I thought the partial derivative does exactly this: take everything as constant but the variable that shows up directly itself. Nov 2, 2012 at 15:50
• @FooBar: that is what I call the "first fundamental mistake of multivariable calculus". Partial derivatives don't "take everything as constant". A partial derivative is the derivative taken with respect to one chosen independent variable while other independent variables are held to be fixed. If you declare $g$ and $h$ to be independent variables, then $f$, the dependent variable, is a function of $x$, $g$, and $h$. This is different from the case where you declare only $x$ as the independent variable and make $g$ and $h$ dependent variables. In performing the partial differentiation ... Nov 2, 2012 at 15:54
• @FooBar: The potential for confusion surrounding partial derivatives is endless because our notation for them is so ambiguous. You might want to search for some of my other answers to questions about partial derivatives. In a nutshell, when you use partial derivatives you need to have very clear in your mind what you're treating as independent variables, what you're changing and what you're keeping constant. As a rule, if you have a function $g(x)$, then $g$ depends on $x$ and you can't use both $x$ and $g$ as independent variables simultaneously, i.e. you can't keep $g$ fixed as $x$ varies. Nov 2, 2012 at 15:56
• ... you can only take other independent variables as fixed. You are not allowed to hold other dependent variables as fixed. Incidentally, this leads to the "second fundamental mistake of multivariable calculus": to specify a partial derivative, you must specify what are the independent and dependent variables. There are times when it is not clear from context (for example in studying thermodynamics). If one is not clear about which are precisely the independent and dependent variables, the notation $\partial/\partial x$ is meaningless. Nov 2, 2012 at 15:57
• Thanks all of you. I chose this answer as the correct one in combination with Willies comment which solved my problem fully ("independent" was the keyword, I was not aware of this). Nov 2, 2012 at 16:03

It doesn't appear that you're applying the product rule correctly in the first case.

If you apply the product rule on $f(x)=xg(x)h(x)$ you should get

$$\frac{df}{dx} = xg(x)h'(x)+xg'(x)h(x)+g(x)h(x).$$

• partial derivative of f(x, g(x), h(x)) by x treats g and h as constant, I thought? Or the other way round: Then why partial derive at all if I'm not allowed to treat something as constant? Nov 2, 2012 at 15:52
• Nope, there is no "partial" derivative of $f$ in this sense. Partial derivatives are taken with respect to independent variables, but $g$ and $h$ are dependent variables with respect to $x$. Nov 2, 2012 at 15:55
• Another way of looking at it is $\frac{df}{dx}$ is the change in $f$ as a result of a small change in $x$. If $x$ changes, then as you have written it, so too does $g(x)$ and $h(x)$. Therefore, we must account for the effects of changes of $g(x)$ and $h(x)$ as a consequence of small changes of $x$. Nov 2, 2012 at 15:56