Chain rule – examples

Required math: derivatives, trig functions, chain rule, product rule

Required physics: none

Here are a few examples of using the chain rule for derivatives. The general form of the chain rule is:

\displaystyle   \frac{df(g(x))}{dx} \displaystyle  = \displaystyle  \frac{df}{dg}\frac{dg}{dx}

Example 1. The chain rule applies when we need the derivative of a ‘function of a function’, as in {f(u)} where {u=g(x)}, so for the first example, we will make it explicit which is the first function and which is the second.

First (outer) function: {f(u)=6u-9}. Second (inner) function: {u=g(x)=\frac{1}{2}x^{4}}.

First take the derivative of the outer function with respect to its variable {u}:

\displaystyle   \frac{df(u)}{du} \displaystyle  = \displaystyle  \frac{d}{du}(6u-9)
\displaystyle  \displaystyle  = \displaystyle  6

Now take the derivative of the inner function with respect to {x}:

\displaystyle   \frac{dg(x)}{dx} \displaystyle  = \displaystyle  \frac{d}{dx}\left(\frac{1}{2}x^{4}\right)
\displaystyle  \displaystyle  = \displaystyle  \frac{1}{2}\times4x^{3}
\displaystyle  \displaystyle  = \displaystyle  2x^{3}

Finally, multiply the two together:

\displaystyle   \frac{df(g(x))}{dx} \displaystyle  = \displaystyle  \frac{df}{dg}\frac{dg}{dx}
\displaystyle  \displaystyle  = \displaystyle  (6)(2x^{3})
\displaystyle  \displaystyle  = \displaystyle  12x^{3}

This example could have been done by substituting {u=g(x)} before doing the derivative and in that case the chain rule isn’t needed. That is we could have said

\displaystyle   f(u) \displaystyle  = \displaystyle  f(g(x))
\displaystyle  \displaystyle  = \displaystyle  6g(x)-9
\displaystyle  \displaystyle  = \displaystyle  6\left(\frac{1}{2}x^{4}\right)-9
\displaystyle  \displaystyle  = \displaystyle  3x^{4}-9

We could then have taken the derivative directly to get {f'(x)=12x^{3}}. The next example will illustrate a case where the chain rule must be used.

Example 2. First function: {f(u)=\sin u}; Second function: {u=g(x)=3x+1} (so, effectively, {f(g(x))=\sin(3x+1)}).

First, the outer derivative:

\displaystyle   \frac{df(u)}{du} \displaystyle  = \displaystyle  \frac{d}{du}\sin u
\displaystyle  \displaystyle  = \displaystyle  \cos u

Then, the inner derivative:

\displaystyle   \frac{dg(x)}{dx} \displaystyle  = \displaystyle  \frac{d}{dx}(3x+1)
\displaystyle  \displaystyle  = \displaystyle  3

Then, the combination

\displaystyle   \frac{df(g(x))}{dx} \displaystyle  = \displaystyle  \frac{df}{dg}\frac{dg}{dx}
\displaystyle  \displaystyle  = \displaystyle  (\cos u)(3)
\displaystyle  \displaystyle  = \displaystyle  3\cos(3x+1)

Notice in the last step, we substituted for {u} in terms of {x}.

Example 3. The quotient rule is often stated as a separate rule for finding the derivative of the quotient of two functions, such as {f(x)/g(x)}. However, it is easily derived from the chain and product rules, as we’ll see here.

We can rewrite the quotient as a product:

\displaystyle  \frac{f(x)}{g(x)}=[f(x)][g(x)]^{-1}

We can now use the product rule to get

\displaystyle   \frac{d}{dx}\left(\frac{f(x)}{g(x)}\right) \displaystyle  = \displaystyle  \frac{df(x)}{dx}[g(x)]^{-1}+f(x)\frac{d}{dx}[g(x)]^{-1}
\displaystyle  \displaystyle  = \displaystyle  \frac{f'(x)}{g(x)}+f(x)\frac{d}{dx}[g(x)]^{-1}

We now need to use the chain rule to find the last derivative in the above formula. If we define {u=g(x)}, then

\displaystyle   \frac{d}{dx}[g(x)]^{-1} \displaystyle  = \displaystyle  \frac{d}{dx}(u^{-1})
\displaystyle  \displaystyle  = \displaystyle  (-1)(u^{-2})\frac{du}{dx}
\displaystyle  \displaystyle  = \displaystyle  -\frac{g'(x)}{g^{2}(x)}

where again we have replaced {u} by {g(x)} in the last line, just to get everything back in terms of {x}. We can now combine this result with the earlier one from the product rule to get:

\displaystyle   \frac{d}{dx}\left(\frac{f(x)}{g(x)}\right) \displaystyle  = \displaystyle  \frac{f'(x)}{g(x)}-f(x)\frac{g'(x)}{g^{2}(x)}
\displaystyle  \displaystyle  = \displaystyle  \frac{f'(x)g(x)-f(x)g'(x)}{g^{2}(x)}

which is the quotient rule.

Example 4. Find the derivative of {f(x)=(\sin x)/x^{2}}. This is a quotient, but rather than use the quotient rule directly, we will treat it as a product and use the procedure from example 3 to find the derivative using the product and chain rules.

\displaystyle   \frac{df}{dx} \displaystyle  = \displaystyle  \frac{d}{dx}[(\sin x)(x^{-2})]
\displaystyle  \displaystyle  = \displaystyle  \left(\frac{d}{dx}(\sin x)\right)(x^{-2})+\sin x\frac{d}{dx}(x^{-2})
\displaystyle  \displaystyle  = \displaystyle  (\cos x)(x^{-2})+(\sin x)(-2x^{-3})
\displaystyle  \displaystyle  = \displaystyle  \frac{\cos x}{x^{2}}-\frac{2\sin x}{x^{3}}
\displaystyle  \displaystyle  = \displaystyle  \frac{x\cos x-2\sin x}{x^{3}}

A good exercise for the reader is to check this result by using the quotient rule at the end of Example 3 directly and show you get the same answer.

Example 5. Find the derivative of {f(x)=\sin(\cos^{2}(x^{3}+4x))}. This is a four-level nested function, so we’ll need to use the chain rule several times. We can write this function as {f(x)=\sin(g(h(j(x)))} with {g(h)=h^{2}}, {h(j)=\cos j} and {j(x)=x^{3}+4x}. (You should take the time to write this out and verify that these substitutions work before proceeding.)

The chain rule can now be applied in the form

\displaystyle   \frac{df}{dx} \displaystyle  = \displaystyle  \frac{df}{dg}\frac{dg}{dh}\frac{dh}{dj}\frac{dj}{dx}

Seen broken down like this, the problem becomes much easier, since we need to work out four standard derivatives:

\displaystyle   \frac{df}{dg} \displaystyle  = \displaystyle  \cos g
\displaystyle  \frac{dg}{dh} \displaystyle  = \displaystyle  2h
\displaystyle  \frac{dh}{dj} \displaystyle  = \displaystyle  -\sin j
\displaystyle  \frac{dj}{dx} \displaystyle  = \displaystyle  3x^{2}+4

Combining all these, we get

\displaystyle   \frac{df}{dx} \displaystyle  = \displaystyle  (\cos g)(2h)(-\sin j)(3x^{2}+4)
\displaystyle  \displaystyle  = \displaystyle  (\cos g)(2h)(-\sin(x^{3}+4))(3x^{2}+4)
\displaystyle  \displaystyle  = \displaystyle  (\cos g)(2\cos j)(-\sin(x^{3}+4))(3x^{2}+4)
\displaystyle  \displaystyle  = \displaystyle  (\cos g)(2\cos(x^{3}+4))(-\sin(x^{3}+4))(3x^{2}+4)
\displaystyle  \displaystyle  = \displaystyle  (\cos h^{2})(2\cos(x^{3}+4))(-\sin(x^{3}+4))(3x^{2}+4)
\displaystyle  \displaystyle  = \displaystyle  (\cos(\cos^{2}(j))(2\cos(x^{3}+4))(-\sin(x^{3}+4))(3x^{2}+4)
\displaystyle  \displaystyle  = \displaystyle  (\cos(\cos^{2}((x^{3}+4)))(2\cos(x^{3}+4))(-\sin(x^{3}+4))(3x^{2}+4)
\displaystyle  \displaystyle  = \displaystyle  -2\cos(\cos^{2}((x^{3}+4))\cos(x^{3}+4)\sin(x^{3}+4)(3x^{2}+4)

Here, in the first line, we’ve just plugged in the derivatives as calculated above. Then in each succeeding line, we have worked backwards through the functions to put everything in terms of {x}. The last line just rearranges a couple of things to make it neater.

The final result is complex, but there are no tricks involved; we just apply the chain rule in the normal way.

About these ads
Post a comment or leave a trackback: Trackback URL.

Trackbacks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 288 other followers

%d bloggers like this: