# How to differentiate with respect to f(x)? (chain rule intuition)

Chain rule question here. I learned that, given a function $f(g(x))$, its derivative with respect to x is $\frac{df}{dg} \frac{dg}{dx}$. On the surface, that makes sense to me.

But when I try to work step-by-step through an example, say, $f(g(x)) = (2x+1)^2$, where $f(z) = z^2$ and $g(x) = 2x + 1$, I get stuck....

The literal translation of the first part above, $\frac{df}{dg}$, I believe becomes $\frac{d}{d(2x+1)}(2x+1)^2$, which if I try to insert into the derivative formula, seems like it could be:

$$\lim_{\Delta (2x+1) \to 0} \frac{(2(x+\Delta (2x+1))+1)^2 - (2x+1)^2}{\Delta(2x+1)}$$

and maybe (?) that can be factored into:

$$\lim_{\Delta x \to 0} \frac{(2(x+ 2\Delta x+1)+1)^2 - (2x+1)^2}{2\Delta x+1}$$

Anyway, neither version gives me the correct answer of $4x+2$ when I work the math out, but I think there should be some way to plug in something besides $\Delta x$ into the derivative formula, I'm just not sure how.

-
The correct answer is not $4x+2$; perhaps that is the problem. – robjohn Jun 1 '13 at 3:33

Since $f(g)=g^2$, we have $\frac{\mathrm{d}}{\mathrm{d}g}f(g)=\color{#C00000}{2g}$.

Since $g(x)=2x+1$, we have $\frac{\mathrm{d}}{\mathrm{d}x}g(x)=\color{#00A000}{2}$.

The chain rule then says \begin{align} \frac{\mathrm{d}}{\mathrm{d}x}f(g(x)) &=\color{#C00000}{2g(x)}\color{#00A000}{2}\\ &=4(2x+1) \end{align}

-
Ah! So much simpler than I thought, thanks. – Jon Jun 1 '13 at 3:33
@Jon: Indeed. The purpose of the chain rule is to simplify differentiation of composite functions. – robjohn Jun 1 '13 at 6:02

It appears you are trying to intuit how the chain rule relates to the definition of the derivative (the difference quotient). I believe this is where your calculations are going wrong:

\begin{align}\Delta(2x+1)&=\Delta{y}\\ &=y_1-y_0\\ &=(2x_1+1)-(2x_0+1)\\ &=2x_1-2x_0\\ &=2(x_1-x_0)\\ &=2\Delta{x} \end{align}

$$\lim_{\Delta{x}\to0}\frac{(2(x+2\Delta{x})+1)^2-(2x+1)^2}{2\Delta{x}}$$