# differentiate with respect to a function

Let's say I have this function $f(x)=x$. I want to differentiate with respect to $x^2$. So I want to calculate $\large\frac{df(x)}{dx^2}$. In general, how can I calculate the derivative of a function $f(x)$ with respect to a function $g(x)$, so $\large\frac{df(x)}{dg(x)}$?

(I dont know whether this is a good notation)?

• Could you please define $\frac{df}{dx^2}$? – Siminore Jan 31 '13 at 14:58
• @Siminore I want to differentiate with respect to $x^2$, but I dont know if thats the good notation. – Badshah Jan 31 '13 at 15:01
• Possible duplicate: math.stackexchange.com/questions/54836/… – Felipe G. Nievinski Dec 7 '17 at 4:24

You can think about it in terms of "cancellation":

$$\frac{df(x)}{d (x^2)} = \frac{df(x)/dx}{d(x^2)/dx} = \frac{1}{2 x} \frac{df(x)}{dx}$$

More formally, let $y=x^2$, then consider $x=\sqrt{y}$ and differentiate $\,df(\sqrt{y})/dy$.

• @rlgordanma if $y=x^2$ then $x=\sqrt{y}$ or $x=-\sqrt{y}$. So how should I interpret this negative one? – Badshah Jan 31 '13 at 14:49
• @Badshah: interesting question. I guess it depends on the domain of $f$. – Ron Gordon Jan 31 '13 at 14:54
• When does this trick with operating on dx (multipling/dividing by it) works? Does it always valid or are there some invalid cases? – Trismegistos Jan 31 '13 at 14:55
• @Trismegistos: Another good question. You'd think that this trick which is just a play on formalism would break down at some point. But I have yet to see where it does - at least where the derivative is defined. It all holds together because the derivative is the limit of a fraction. – Ron Gordon Jan 31 '13 at 14:58

As mostly a follow-up to rlgordonma's answer, here's a way to explain the method that perhaps fits a bit closer to things you're probably used to seeing.

Let $u = x^2$ and use the chain rule as follows for the function $f(x)$:

$$\frac{df}{dx} \; = \; \frac{df}{du} \frac{du}{dx} \; = \; \frac{df}{du} \cdot 2x$$

$$\implies \;\; \frac{df}{du} \; = \; \frac{1}{2x} \cdot \frac{df}{dx}$$

For what it's worth, I've seen problems stated in exactly the way Badshah stated his question in old calculus texts, such as:

George Abbott Osborne, Differential and Integral Calculus (1908). [See page 60 for several neat examples.]

So it's true that the correct answer is that if we want to differentiate f(x) with respect to another g(x) that we take $$\frac{f'(x)}{g'(x)}$$, but I think just calling this chain rule cancellation is not exactly correct (though it is both intuitive and also gives the right answer... lol).

To formalize things, let's say we have (1) $$f(t) = h(t,g(t))$$, which for simplicity in applying the multivariate chain rule we can write as $$f(t) = h(x(t), y(t))$$

So then (2) $$\frac{df}{dy} = \frac{dh}{dx}\frac{dx}{dy} + \frac{dh}{dy}\frac{dy}{dy}$$. We know that $$\frac{dx}{dy} = \frac{dt}{dg} = \frac{1}{\frac{dg}{dt}} = \frac{1}{g'(t)}$$, by the inverse derivative theorem, and we know $$\frac{dy}{dy} = 1$$.

So in (1) if we multiply $$\frac{dh}{dy}$$ by $$1 = \frac{g'(t)}{g'(t)}$$, we get (3) $$\frac{df}{dy} = \frac{\frac{dh}{dx}*1 + \frac{dh}{dy}\frac{dy}{dt}}{g'(t)}$$, since y=g, and then since x=t, we can write $$1 = \frac{dx}{dt}$$, which gives us

$$\frac{df}{dy} = \frac{\frac{dh}{dx}*\frac{dx}{dt} + \frac{dh}{dy}\frac{dy}{dt}}{g'(t)}$$, which is just $$\frac{f'(t)}{g'(t)}$$.