Derivatives of compositions of functions:   f(g(x))


The chain rule is one of the most useful tools in differential calculus. Equipped with your knowledge of specific derivatives, and the power, product and quotient rules, the chain rule will allow you to find the derivative of any function.

The chain rule is a bit tricky to learn at first, but once you get the hang of it, it's really easy to apply, even to the most stubborn of functions. Knowing it will also allow you to forego the more cumbersome quotient rule in many cases, because any denominator h(x) can be expressed as a multiple, [h(x)]-1.

Each of the functions in the box on the right is a composition of functions, f(x) = g(h(x)). For example, in the first, h(x) = x2 - 4 and the outer function is g(x) = sin(x): g(h(x)) = sin(x2 - 4).


Derivation of the chain rule


To derive the chain rule, consider a function y(t) that is actually a composition of functions, y(x) and x(t). It might be something like y(t) = cos(3t2), where y(x) = cos(x) and x(t) = 3t2. In terms of the changes in y and x, we have:

,

where the Δx terms cancel to give the overall change in y with respect to t. We can use the same cancellation in terms of differentials, but a word about that is in order:

While Leibniz, who invented the df/dx notation, never intended it to be used as such, we can safely consider df/dx to be simply a ratio of differentials, making the analogous cancellation possible:

Thus the derivative of a composition of functions can be expanded as a product of derivatives, the first the derivative of the outer function with respect to the full inner function (e.g. by treating it like a single "placeholder" variable), the second just the derivative of the inner function with respect to its independent variable.

The Chain Rule

If a function can be expressed as a composition of two functions, f(x) and g(x), such as f(g(x)), then its derivative is:



Learning the chain rule


It's easiest to learn the chain rule by working through examples. In the first two examples below, we'll substitute a "dummy variable" for the inner function, but you'll find that in no time you wont need to do that any more.


Example 1

Find the derivative of   $f(x) = sin(x^2)$


Solution: The outer function is $f(x) = sin(x)$ and the inner function is $g(x) = x^2$. Let's let $a = x^2$ and differentiate the outer function as $f(a) = sin(a)$:

$$f'(a) = cos(a)$$

Then we differentiate the inner function, $g'(x) = 2x$, and multiply it by $f'(a)$:

$$f' = 2x\cdot cos(a)$$

I didn't write a variable behind $f'$ above because at the moment I've got a weird hybrid function of x and a. The last step is to re-substitute x2 for a:

$$f'(x) = 2x\cdot cos(x^2)$$

Pro tip:

This method of making a substitution for the inner function is a good way to learn the chain rule, but eventually, you'll want to do it without substitution. Learn to ignore the inner function(s), leaving them intact while you write down the derivative of the outer function.


Example 2

Find the derivative of   $f(x) = (x^2 - 5)^3$


Solution: We'll do this one by making a substitution again. The outer function is $f(x) = x^3$ and the inner function is $g(x) = x^2 - 5$. Let's let $a = x^2 - 5$ and differentiate the outer function as $f(a) = a^3$:

$$f'(a) = 3 a^2$$

Then we differentiate the inner function, $g'(x) = x^2 - 5$ with respect to $x$, and multiply it by $f'$:

$$f' = 2x\cdot 3a^2 = 6x\cdot a^2$$

The last step is to re-substitute $(x^2 - 5)$ for $a$:

$$f'(x) = 6x\cdot (x^2 - 5)^2$$


Example 3

Find the derivative of   $f(x) = (x^2 + x)^{1/2}$


Solution: Let's do this one without substitution of a placeholder variable and use the chain rule directly. The first step is to take the derivative of the whole outer function, treating the inner function $(x^2 + x)$ as a single unit.

(This is just an intermediate step; we're not finished yet:)

$$\frac{1}{2} (x^2 + x)^{\frac{1}{2}}$$

Then multiply by the derivative of the inner function, $x^2 + x$

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


Example 4

Find the derivative of   $f(x) = (x^2 - 4)^{-1}$


Solution: The outer function is $x^{-1}$ and the inner is $x^2 - 4$. The derivative is $f'(x) = -(x^2 - 4)^{-2}(2x)$, which can be simplified a bit, but I'll leave that to you.


Practice problems

Find the derivatives of these compound functions using the chain rule. You may have to also use the product or quotient rules.

1.
$$f(x) = (x^3 + x^2 - x + 1)^3$$
2. $$f(x) = \sqrt{1 - 3x}$$
3. $$f(x) = \frac{1}{x^2 - 1}$$
4. $$f(x) = \frac{1}{1 + cos(x)}$$
5. $$f(x) = \frac{1}{cos^2(x)}$$
6. $$f(x) = x^2 + cos^2(x)$$
7. $$f(\theta) = 3 cot (n\theta)$$
8. $$f(x) = (2x - 3)^4(x^2 + x + 1)^4$$
9. $$f(x) = \left(\frac{x^2 + 1}{x^2 - 1}\right)^3$$
10. $$f(x) = \sqrt{\frac{x^2 + 1}{x^2 + 4}}$$

11. $$f(x) = \frac{x}{\sqrt{7 - 3x}}$$
12. $$f(x) = \frac{(x - 1)^4}{(x^2 + 2x)^5}$$
13. $$f(x) = sin(cos(2x))$$
14. $$f(x) = \left(\frac{1 - cos(2x)}{1 + cos(2x)}\right)^4$$
15. $$f(x) = [x^2 + (1 - 3x)^5]^3$$
16. $$f(x) = \frac{cos(x)}{sin(x) + cos(x)}$$
17. $$f(x) = x \cdot sin \left( \frac{1}{x}\right)$$
18. $$f(x) = sin(sin(sin(x)))$$
19. $$f(\theta) = 2 cot(n\theta)$$
20. $$f(x) = \sqrt{\frac{x}{x^2 + 4}}$$


Video examples

Here are eight examples (four videos) of chain rule derivatives. Enjoy! (OK, maybe that's overdoing it. I do hope they're helpful, though).


Example 1

Here are two examples of using the chain rule where the inner function [ g(x) in f(g(x)) ] is a polynomial, and f(x) is a simple power function like f(x) = x2.

Minutes of your life: 0:00


Example 2

In the second of these two examples, the outer function, f(x), is a squared trig. function, sin2(x).

Minutes of your life: 0:00


Example 3

The first of these two examples involves a polynomial function that is the exponent of an exponential function, the second a polynomial inside a sine function.

Minutes of your life: 0:00


Example 4

Here are two trickier chain rule problems, three nested functions like f(g(h(x))).

Minutes of your life: 0:00


Creative Commons License   optimized for firefox
xaktly.com by Dr. Jeff Cruzan is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. © 2012, Jeff Cruzan. All text and images on this website not specifically attributed to another source were created by me and I reserve all rights as to their use. Any opinions expressed on this website are entirely mine, and do not necessarily reflect the views of any of my employers. Please feel free to send any questions or comments to jeff.cruzan@verizon.net.