$\newcommand{\diff}{\,\text{d}}$

Calculus Notes

⟵Section 2.3      Section 2.5 ⟶

Section 2.4: The Chain Rule

In section 2.3, we learned how to find the derivative of a product or quotient of two functions. In this section, we learn how to find the derivative of a function of a function. This kind of function is known as a composite function and is written as $f(g(x))$ or $f \circ g$.

According to the chain rule, the derivative of a composite function $f(g(x))$ is given by

$$ \boxed{\frac{\diff}{\diff x} f\left(g(x)\right) = f'\left(g(x)\right)g'(x)}$$

In other words, one must first take the derivative of the outside function $f$ with respect to the inside function $g$ (treating $g$ as a variable), and then multiply it by the derivative of the inside function $g$ with respect to $x$.

The chain rule can also be written as

$$\boxed{\frac{\diff f}{\diff x} = \frac{\diff f}{\diff g} \frac{\diff g}{\diff x} }$$

Notice how the $\diff g$s in the numerator and denominator appear to cancel out. Technically this is cannot happen because $\diff g$ is an infinitessimally small number (see section 3.9 for more about infinitessimals); however, the result works out the same as if it did.

To see how the chain rule works in practice, consider the the following example:

Differentiate: $f(x)=(x^2+3)^7$

Solution: One could expand this expression as a polynomial using the binomial theorem, and differentiate using the power rule; however this would be very tedious to calculate. The chain rule improves things immensely.

Begin by letting the inside function $g(x)$ be $x^2 + 3$, and the outside function $f(g)$ be $g^7$. Then,

$$ \frac{\diff f}{\diff g} = 7 g^6 \quad \text{and} \quad \frac{\diff g}{\diff x} = 2x$$

Applying the chain rule, we have:

$$\frac{\diff f}{\diff x} = \frac{\diff f}{\diff g} \frac{\diff g}{\diff x} = (7 g^6) (2 x)$$

Plugging in $g = x^2 + 3$, this becomes

$$7(x^2 + 3)^6(2x) = \boxed{ 14 x (x^2+3)^6}$$
Extending the chain
There is no limit to the number of times the chain rule may be applied. For example, one may find the derivative of the function $f(g(h(x)))$ using the formula $$\frac{\diff f}{\diff x} = \frac{\diff f}{\diff g} \frac{\diff g}{\diff h}\frac{\diff h}{\diff x}$$
The meaning of "with respect to"

Since the chain rule requires you to calculate the derivative of functions with respect to multiple variables, this is probably a good time to discuss the precise meaning of the phrase "with respect to." When one takes the derivative of a function $f$ with respect to a variable $x$, one is really asking the question, "How rapidly is $f$ changing when $x$ is varied?"

To show how the derivative depends on which variables you are taking the derivative with respect to, consider the following examples:

1) Suppose that $y = f(x)$ is a function that depends on $x$. Then the derivative of $y$ with respect to $x$ is by definition $y'$.

$$\frac{\diff}{\diff x} y = y'$$

2) On the other hand, the derivative of $y$ with respect to $y$ asks "How fast does $y$ change when you adjust $y$." Since the things be changed are the same, the ratio of the changes equals one. We may use the power rule to prove that

$$\frac{\diff}{\diff y} y = 1$$

3) Finally, if $z$ is some other variable that is independent of $y$, then $y$ doesn't change at all when $z$ is adjusted. Hence

$$\frac{\diff}{\diff z} y = 0$$

Suppose we have some expression involving $y$, such as $y^2$ where $y = f(x)$ is a function of $x$. In this case, $y^2$ is a composite function, so to calculate its derivative with respect to $x$, one must use the chain rule.

$$\frac{\diff}{\diff x} y^2 = \frac{\diff y^2}{\diff y} \frac{\diff y}{\diff x} = (2y)(y') = 2yy'$$

The additional factor $y'$ would not have been necessary if we were merely taking the derivative with respect to $y$

⟵Section 2.3      Section 2.5 ⟶