The Chain Rule

When do we need the Chain Rule?

We need the chain rule when our function $f(x)$ is actually a function nested inside of another function. For example $f(x) = \sin (3x^2 +2)$ has an inner function $3x^2+2$ and an outer function $\sin x$. In other words $f(x)$ is the composition of $g(x) = \sin x$ with $h(x)=3x^2 + 2.$ This can be written as $f(x) = g \circ h(x) = g(h(x))$. We take the function $g$ and rather than evaluating at $x$ we evaluate at $3x^2+2$.

Let’s look at a quick example of function composition.

Example

Let $g(x) = x^2+2$ and $h(x) = e^x$, what is $f(x) = g\circ h(x)$?

Solution

To write out $f(x)$ we need only put an $e^x$ in each place we see $x$ in the equation for $g(x).$ $$f(x) = (e^x)^2+2 = e^{2x} + 2.$$

So we have an example of what it means to do a function composition, now let’s try and identify when a function is a composite function (i.e. the composition of 2 or more functions). Remember that the inner function might be complicated or it might be quite simple. In either case we need the chain rule, so it’s important to be able to identify them.

Example

For each of the following functions identify the inner function and the outer function in the composition.

  1. $f(x) = \cos(3x)$
  2. $g(t) = \frac{1}{t^3-t}$
  3. $\ell(z) = e^{\sin z}$
  4. $F(u) = \sin^3 u$

Solution

  1. The inner function is $3x$ and the outer function is $\cos x$.
  2. The inner function is $t^3-t$ and the outer function is $\frac{1}{t}$.
  3. The inner function is $\sin z$ and the outer function is $e^z$
  4. The inner function is $\sin u$ and the outer function is $u^3$.

Example

Which of the following functions are function compositions?

  1. $f(x) = 3x^2\sin x$
  2. $g(x) = \sin (e^x)$
  3. $h(t) = e^{t^2}$
  4. $\ell(z) = z^2+1- z\ln z$

Solution

  1. This is a product of two functions, but not a composition.
  2. This is a composition. The inner function is $e^x$ and the outer function is $\sin x$.
  3. This is a composition. The inner function is $t^2$ and the outer function is $e^t$.
  4. This is a sum and product of functions, but not a composition.

Once we can reliably identify compositions we can see that the product rule doesn’t work for taking derivatives. What we need instead is the chain rule!

Check out Practice Problems here!

Chain rule basics below! Come back here when you’re ready to test your knowledge.

Like learning by solving problems? Try this and more in the Dogl Calculus app 😃

The Chain Rule Basics

 

The Chain Rule is what we use for taking derivatives of function compositions like $f(x) = \sqrt{3x^5-1}$. Before we get into the general form of the Chain Rule, let’s take a look at a couple of examples using the limit definition of the derivative to get an idea of why it takes the form it does.

Let $f(x) = g(3x)$, then $$\begin{eqnarray}f'(x) & = & \lim_{h\to 0} \frac{g(3(x+h)) – g(3x)}{h}\\ & = & \lim_{h\to 0} 3\frac{g(3x+3h)) – g(3x)}{3h}\\ & = & \lim_{s\to 0} 3\frac{g(3x+s) – g(3x)}{s}\\ & = & 3 \cdot g'(3x)\end{eqnarray}$$

Let $f(x) = g(x^2)$, then $$\begin{eqnarray}f'(x) & = & \lim_{h\to 0} \frac{g((x+h)^2) – g(x^2)}{h}\\ & = & \lim_{h\to 0} \frac{g(x^2 + 2xh + h^2) – g(x^2)}{2xh+h^2} \cdot (2x+h)\\ & = & \left(\lim_{s\to 0} \frac{g(x^2+s) – g(x^2)}{s}\right)\left(\lim_{h\to 0} 2x+h\right) \\ & = &  g'(x^2)\cdot 2x.\end{eqnarray}$$

In both cases what we see is that we have something close to the derivative of $g’$ evaluated at the inner function, but we then also need to adjust for having the $+h$ inside the inner function. We can do this by multiplying by the derivative of the inner function, which leads to…

The Chain Rule

Let $f(x) = h(g(x))$ where $h(x)$ and $g(x)$ are differentiable functions, then $$f'(x) = h'(g(x))\cdot g'(x).$$

Let’s look at an example of how this works with our function $f(x) = \sqrt{3x^5-1}$. We start by identifying the inner function, which in this case is $g(x) = 3x^5-1$, and the outer function, $h(x) =\sqrt{x}$.

We can use the power rule to compute that $h'(x) = \frac{1}{2\sqrt{x}}$, so $h'(3x^5 -1) = \frac{1}{2\sqrt{3x^5-1}}$. We can also use the power rule to compute $g'(x) = 15 x^4$. Putting this together we get $$f'(x) = \frac{1}{2\sqrt{3x^5-1}}\cdot 15 x^4.$$

Example

Use the chain rule to find the derivative of $f(x) = \sin^3 x$.

Solution

Note that in this case the inner function is $g(x)=\sin x$, and the outer function is $h(x)=x^3$. We have then that $h'(x) = 3x^2$ and so $h'(\sin x) = 3\sin^2 x$. Finally $g'(x) = \cos x$, so putting everything together we get $$f'(x) = 3\sin^2 x \cdot \cos x.$$

Before moving on to more complicated applications of the chain rule it’s worth taking a look at another notation that is sometimes used. Suppose that $f$ is a function of $u,$ which is a function of $x$, then $$\frac{df}{dx} = \frac{df}{du}\frac{du}{dx}.$$

The notation $\frac{dg}{dz}$ is short hand for saying “take the derivative of $g$ with respect to $z$.” What this means is that $z$ is your underlying “clock” when you compute the derivative. If $z=2x$ then time runs twice as fast in $z$ time than it does in $x$ time and $\frac{dz}{dx} = 2$, which means that $\frac{dg}{dx} = 2\frac{dg}{dz}$ or $\frac{dg}{dx} = \frac{dg}{dz} \frac{dz}{dx}$. With this notation there is much more thought required to understand what variable you’re “taking the derivative with respect to,” but it can be helpful in remembering that the chain rule should give you a product.

If all of this seems needlessly complicated, feel free to ignore it and use the original formulation.

$f'(x)$ is not $h'(x)g'(x)$ and other common mistakes

The two most common mistakes people seem to make when using the chain rule are the following:

If $f(x) = h(g(x))$ they will either write $f'(x) = h'(x)g'(x)$ or $f'(x) = h'(g'(x))$.

Don’t do this!

Tips

1) Remember that the outer function and its derivatives should both be evaluated at the inner function. In other words if you’ve got $h(g(x))$ then you should also have $h'(g(x))$.

2) You need to chain (multiply) the derivatives together (hence “Chain Rule”), so not $h'(g'(x))$, you need $h'(g(x)) \cdot  g'(x)$.

Let’s look at a few examples of what NOT to do.

Example

Take the derivative of $f(x) = \sqrt{\sin x + 1}$.

Proposed Solution

We can see that $f(x)$ is the composition of $\sqrt{x}$ and $\sin x + 1$, therefore we can apply the chain rule to get that $$f'(x) = \frac{1}{2\sqrt{x}} \cdot \cos x.$$

What if any error did we make in the proposed solution?

Solution

We correctly identified the function $f(x)$ as a composition of functions, but when we took the derivative of the outer function we didn’t evaluate at the inner function when we plugged it into the chain rule formula for $f'(x)$. In fact we should get $$f'(x) = \frac{1}{2\sqrt{\sin x+1}} \cdot \cos x.$$

Example

Take the derivative of $h(t) = e^{x^2+x+3}$.

Proposed Solution

We can see that $f(x)$ is the composition of $e^x$ and $x^2+x+3$, therefore we can apply the chain rule to get that $$f'(x) = e^{2x +1}.$$

What if any error did we make in the proposed solution?

Solution

We correctly identified the function $f(x)$ as a composition of functions, but rather than using the chain rule formula we just replace the outer function and inner function with their derivatives. In fact we should get $$f'(x) = e^{x^2+x+3}(2x+1).$$

When one rule is not enough

Up to this point we’ve mostly looked at fairly simple examples, but what happens when you have a composit function, but your inner or outer function is also a composition?  For example $$f(x) = \sin (\sqrt{x^3-1}).$$

Here we could say that our outer function was $\sin x$ and our inner function was $\sqrt{x^3-1}$, but this is also a composit function. Well there is nothing to stop us from applying the chain rule again to determine the derivative of $\sqrt{x^3-1}$!

The derivatvie of $\sqrt{x^3-1}$ using the chain rule is $$\frac{d}{dx} \left(\sqrt{x^3-1}\right) = \frac{1}{2\sqrt{x^3-1}}\cdot 3x^2.$$

Therefore we have $$f'(x) = \cos(\sqrt{x^3-1}) \cdot \frac{1}{2\sqrt{x^3-1}}\cdot 3x^2.$$

More generally, if you have $f(x) = h(g(\ell(x)))$ then $$f'(x) = h'(g(\ell(x)))g'(\ell(x))\ell'(x).$$

Now let’s finish by taking a look at a really messy example.

Example – mixing products and compositions

Find the derivative of $g(t) = (3x^2+2)e^{x\sin \sqrt{x}}$.

Solution

We need to start by noticing that $g(t)$ has many parts involving both products and compositions. Let’s start with an initial breakdown $g(t) = h(t) \ell(t)$ where $h(t)=3t^2+2$ and $\ell(t) = e^{t\sin \sqrt{t}}$. Then from the product rule rule we have

$$g'(t) = h'(t)\ell(t) + h(t)\ell'(t)$$

We can compute $h'(t) = 6t$ directly, but to compute $\ell'(t)$ we need to use the chain rule. In this case we can see that $\ell(t)$ is a composition with inner function $t\sin \sqrt{t}$ and outer function $e^t$. This inner function is again a product, so we get

$$\begin{eqnarray}\ell'(t)&=& e^{t\sin \sqrt{t}} \cdot \frac{d}{dt}\left( t\sin \sqrt{t}\right) \\ &=&e^{t\sin \sqrt{t}} \cdot \left(1 \cdot \sin \sqrt{t} + t\cdot \frac{d}{dt} \big(\sin \sqrt{t}}\big)\right) \end{eqnarray}$$

For this final derivative we again need the chain rule to compute

$$\frac{d}{dt} \big(\sin \sqrt{t}}\big) = \cos( \sqrt{t} ) \cdot \frac{1}{2\sqrt{t}}.$$

Putting all this together we get

$$\begin{eqnarray} g'(t) &=& h'(t)\ell(t) + h(t)\ell'(t) \\ &=& 6xe^{t\sin \sqrt{t}} + (3x^2+2)e^{t\sin \sqrt{t}}\left(\sin \sqrt{t} + t \cos( \sqrt{t} ) \cdot \frac{1}{2\sqrt{t}}\right).\end{eqnarray}$$

Calculus Posts

Limits and Continuity
Using Derivatives

Coming Soon

Integrals
Integration Techniques
Improper integrals

Coming Soon