Skip to contentSkip to lesson map

Chain Rule II

Status
Updates coming
Reading
MMAC Ch 4.5, pp 432-437
Lesson map

Objectives

  1. Use basic rules, the product/quotient rules, and the chain rule to find derivatives by hand.
  2. Using R, obtain and plot the derivative of a function.

1. Combining Derivative Rules

Objective. Use basic rules, the product/quotient rules, and the chain rule to find derivatives by hand.

Finding a derivative by hand combines the basic rules (Lesson 29 sections 2 to 4), the product and quotient rules (Lesson 30 section 2), and the chain rule (Lesson 32 section 3). The extended exponential rule, ddx[emx+b]=memx+b\frac{d}{dx}[e^{mx + b}] = me^{mx + b} for constants mm and bb, is one of the basic rules (Lesson 29 section 3).

Rule 1 (Chain rule for three functions).

Let f(x)f(x), g(x)g(x), and h(x)h(x) be differentiable functions. When the compositions are defined,

ddx[f(g(h(x)))]=f′(g(h(x)))⋅g′(h(x))⋅h′(x). \frac{d}{dx}[f(g(h(x)))] = f'(g(h(x)))\cdot g'(h(x))\cdot h'(x).

In the composition f(g(h(x)))f(g(h(x))), the middle function is the function gg, applied after the inside function hh and before the outside function ff.

Choosing the rules.

  1. Rewrite each root or reciprocal as a power (Lesson 29 section 2).
  2. Find the last operation performed when the function is evaluated at a number.
  3. When the last operation is a sum or a difference, differentiate term by term.
  4. When the last operation multiplies a function by a constant, keep the constant and differentiate the function (the constant multiple rule, a basic rule).
  5. When the last operation multiplies or divides two functions of xx, apply the product rule or the quotient rule.
  6. When the last operation applies one function to the output of another, name the outside function and the inside function, then apply the chain rule.
  7. Repeat steps 2 to 6 on each term, factor, and inside function until only basic rules remain.

Example 1

For each function, determine which rules apply in finding its derivative. The choices are the basic rules only, the product or quotient rule with the basic rules, the chain rule with the basic rules, and the product or quotient rule and the chain rule with the basic rules.

(3cos⁡(x)−ex)5,(2sin⁡(x)+5)(x3−4),ln⁡(x)−sin⁡(x)+4ex, (3\cos(x) - e^x)^5, \qquad (2\sin(x) + 5)(x^3 - 4), \qquad \ln(x) - \sin(x) + 4e^x,
ex2cos⁡(3x),−31+x2,cos⁡(ln⁡(x2+4)). e^{x^2\cos(3x)}, \qquad -3\sqrt{1 + x^2}, \qquad \cos(\ln(x^2 + 4)).
ShowHide solution
  • For (3cos⁡(x)−ex)5(3\cos(x) - e^x)^5: the chain rule with the basic rules, because the function is a composition, a power of the difference 3cos⁡(x)−ex3\cos(x) - e^x.
  • For (2sin⁡(x)+5)(x3−4)(2\sin(x) + 5)(x^3 - 4): the product or quotient rule with the basic rules, because the function is a product of two factors, and each factor is differentiated by the basic rules.
  • For ln⁡(x)−sin⁡(x)+4ex\ln(x) - \sin(x) + 4e^x: the basic rules only, because every term is a basic modeling function of xx or a constant times a basic modeling function.
  • For ex2cos⁡(3x)e^{x^2\cos(3x)}: the product or quotient rule and the chain rule with the basic rules, because the outside function exe^x takes the product x2cos⁡(3x)x^2\cos(3x) as input, and the factor cos⁡(3x)\cos(3x) is a composition.
  • For −31+x2-3\sqrt{1 + x^2}: the chain rule with the basic rules, because the function is the constant −3-3 times the composition 1+x2\sqrt{1 + x^2}.
  • For cos⁡(ln⁡(x2+4))\cos(\ln(x^2 + 4)): the chain rule with the basic rules, because the function is a composition of three functions: the outside function cos⁡(x)\cos(x), the middle function ln⁡(x)\ln(x), and the inside function x2+4x^2 + 4.

Example 2

Find the derivative:

p(x)=(3cos⁡(x)−ex)5. p(x) = (3\cos(x) - e^x)^5.
ShowHide solution

The inside function is g(x)=3cos⁡(x)−exg(x) = 3\cos(x) - e^x, with g′(x)=−3sin⁡(x)−exg'(x) = -3\sin(x) - e^x. The outside function is f(x)=x5f(x) = x^5, with f′(x)=5x4f'(x) = 5x^4. The chain rule, p′(x)=f′(g(x))⋅g′(x)p'(x) = f'(g(x))\cdot g'(x), then gives

p′(x)=5(3cos⁡(x)−ex)4(−3sin⁡(x)−ex). p'(x) = 5(3\cos(x) - e^x)^4(-3\sin(x) - e^x).

Example 3

Find the derivative:

s(x)=(2sin⁡(x)+5)(x3−4). s(x) = (2\sin(x) + 5)(x^3 - 4).
ShowHide solution

The derivatives of the two factors are

ddx[2sin⁡(x)+5]=2cos⁡(x),ddx[x3−4]=3x2. \frac{d}{dx}[2\sin(x) + 5] = 2\cos(x), \qquad \frac{d}{dx}[x^3 - 4] = 3x^2.

The product rule (Lesson 30 section 2) is

ddx[f(x)⋅g(x)]=g(x)⋅f′(x)+f(x)⋅g′(x). \frac{d}{dx}\left[f(x) \cdot g(x)\right] = g(x) \cdot f'(x) + f(x) \cdot g'(x).

With the first factor 2sin⁡(x)+52\sin(x) + 5 in place of f(x)f(x) and the second factor x3−4x^3 - 4 in place of g(x)g(x),

s′(x)=(x3−4)(2cos⁡(x))+(2sin⁡(x)+5)(3x2). s'(x) = (x^3 - 4)(2\cos(x)) + (2\sin(x) + 5)(3x^2).

Example 4

Find the derivative:

y=7sin⁡(4x) e−2x. y = 7\sin(4x)\,e^{-2x}.
ShowHide solution

The function is the product of 7sin⁡(4x)7\sin(4x) and e−2xe^{-2x}. Differentiate each factor, then apply the product rule. The first factor is differentiated by the chain rule, with inside function 4x4x and outside function 7sin⁡(x)7\sin(x). The second factor is differentiated by the extended exponential rule:

ddx[7sin⁡(4x)]=7cos⁡(4x)⋅4=28cos⁡(4x),ddx[e−2x]=−2e−2x. \frac{d}{dx}[7\sin(4x)] = 7\cos(4x)\cdot 4 = 28\cos(4x), \qquad \frac{d}{dx}[e^{-2x}] = -2e^{-2x}.

Substitute both factors and their derivatives into the product rule, and factor out 14e−2x14e^{-2x}:

y′=28cos⁡(4x) e−2x+7sin⁡(4x)(−2e−2x)=28cos⁡(4x) e−2x−14sin⁡(4x) e−2x=14e−2x(2cos⁡(4x)−sin⁡(4x)). y' = 28\cos(4x)\,e^{-2x} + 7\sin(4x)\big({-}2e^{-2x}\big) = 28\cos(4x)\,e^{-2x} - 14\sin(4x)\,e^{-2x} = 14e^{-2x}\big(2\cos(4x) - \sin(4x)\big).

Example 5

Find the derivative:

q(x)=cos⁡(x2)e2x. q(x) = \frac{\cos(x^2)}{e^{2x}}.
ShowHide solution

The function is a quotient. Differentiate the numerator and the denominator, then apply the quotient rule. The numerator is differentiated by the chain rule, with inside function x2x^2 and outside function cos⁡(x)\cos(x). The denominator is differentiated by the extended exponential rule:

ddx[cos⁡(x2)]=−sin⁡(x2)⋅2x=−2xsin⁡(x2),ddx[e2x]=2e2x. \frac{d}{dx}[\cos(x^2)] = -\sin(x^2)\cdot 2x = -2x\sin(x^2), \qquad \frac{d}{dx}[e^{2x}] = 2e^{2x}.

The quotient rule (Lesson 30 section 2) is

ddx[f(x)g(x)]=g(x)⋅f′(x)−f(x)⋅g′(x)[g(x)]2. \frac{d}{dx}\left[\frac{f(x)}{g(x)}\right] = \frac{g(x) \cdot f'(x) - f(x) \cdot g'(x)}{[g(x)]^2}.

Substitute the numerator cos⁡(x2)\cos(x^2) for f(x)f(x) and the denominator e2xe^{2x} for g(x)g(x), then cancel the factor e2xe^{2x} common to every term:

q′(x)=e2x(−2xsin⁡(x2))−cos⁡(x2)⋅2e2x(e2x)2=−2xsin⁡(x2)−2cos⁡(x2)e2x=−2xsin⁡(x2)+2cos⁡(x2)e2x. q'(x) = \frac{e^{2x}\big({-}2x\sin(x^2)\big) - \cos(x^2)\cdot 2e^{2x}}{(e^{2x})^2} = \frac{-2x\sin(x^2) - 2\cos(x^2)}{e^{2x}} = -\frac{2x\sin(x^2) + 2\cos(x^2)}{e^{2x}}.

Example 6

Find the derivative:

r(x)=−6x2−4x+93. r(x) = -6\sqrt[3]{x^2 - 4x + 9}.
ShowHide solution

Rewrite the cube root as a power:

r(x)=−6(x2−4x+9)1/3. r(x) = -6(x^2 - 4x + 9)^{1/3}.

The inside function is g(x)=x2−4x+9g(x) = x^2 - 4x + 9, with g′(x)=2x−4g'(x) = 2x - 4. The outside function is f(x)=−6x1/3f(x) = -6x^{1/3}, with

f′(x)=−6⋅13x−2/3=−2x−2/3. f'(x) = -6 \cdot \frac{1}{3}x^{-2/3} = -2x^{-2/3}.

The constant −6-6 stays in the outside function, as in section 2 of the Lesson 32 Notes. Substitute into the chain rule, distribute −2-2, and move the negative power to the denominator:

r′(x)=−2(x2−4x+9)−2/3(2x−4)=−4x+8(x2−4x+9)2/3. r'(x) = -2(x^2 - 4x + 9)^{-2/3}(2x - 4) = \frac{-4x + 8}{(x^2 - 4x + 9)^{2/3}}.

Example 7

Find the derivative:

k(x)=cos⁡((3ln⁡(x)+2)4). k(x) = \cos\big((3\ln(x) + 2)^4\big).
ShowHide solution

The inside function is h(x)=3ln⁡(x)+2h(x) = 3\ln(x) + 2, with h′(x)=3xh'(x) = \frac{3}{x}. The middle function is g(x)=x4g(x) = x^4, with g′(x)=4x3g'(x) = 4x^3. The outside function is f(x)=cos⁡(x)f(x) = \cos(x), with f′(x)=−sin⁡(x)f'(x) = -\sin(x). In the diagram, the arrows run from xx through hh, gg, and ff in turn. Under each function is its factor in the derivative.

Figure

By the chain rule for three functions, k′(x)k'(x) is the product of the three factors:

k′(x)=f′(g(h(x)))⋅g′(h(x))⋅h′(x), k'(x) = f'(g(h(x)))\cdot g'(h(x))\cdot h'(x),

which gives

k′(x)=−sin⁡((3ln⁡(x)+2)4)⋅4(3ln⁡(x)+2)3⋅3x=−12x(3ln⁡(x)+2)3sin⁡((3ln⁡(x)+2)4). k'(x) = -\sin\big((3\ln(x) + 2)^4\big)\cdot 4(3\ln(x) + 2)^3\cdot\frac{3}{x} = -\frac{12}{x}(3\ln(x) + 2)^3\sin\big((3\ln(x) + 2)^4\big).

Example 8

Find the derivative:

w(x)=ex2cos⁡(3x). w(x) = e^{x^2\cos(3x)}.
ShowHide solution

The inside function is the product g(x)=x2cos⁡(3x)g(x) = x^2\cos(3x). Find g′g' by the product rule, then substitute g′g' into the chain rule for eg(x)e^{g(x)}. The factor x2x^2 has derivative 2x2x. The factor cos⁡(3x)\cos(3x) is itself a composition, with derivative −sin⁡(3x)⋅3=−3sin⁡(3x)-\sin(3x)\cdot 3 = -3\sin(3x) by the chain rule. By the product rule,

g′(x)=2xcos⁡(3x)+x2(−3sin⁡(3x))=2xcos⁡(3x)−3x2sin⁡(3x). g'(x) = 2x\cos(3x) + x^2\big({-}3\sin(3x)\big) = 2x\cos(3x) - 3x^2\sin(3x).

The outside function is f(x)=exf(x) = e^x, with f′(x)=exf'(x) = e^x. Substitute into the chain rule:

w′(x)=ex2cos⁡(3x)(2xcos⁡(3x)−3x2sin⁡(3x)). w'(x) = e^{x^2\cos(3x)}\big(2x\cos(3x) - 3x^2\sin(3x)\big).

Lesson map

2. Derivatives in R

Objective. Using R, obtain and plot the derivative of a function.

The commands D() and plotFun() work as in section 2 of the Lesson 31 Notes. In a model whose input is MM, the formula in D() ends in ~ M, the same input variable as in makeFun().

To check a hand derivative from section 1, evaluate it and the D() result (Lesson 30 section 3) at two inputs. Matching values support the hand derivative.

Example 9

The average maximum temperature, in degrees Fahrenheit, in central Kentucky at the beginning of each month MM since January 2006 (month 0) is modeled by

Temp(M)=23.3sin⁡ ⁣[2π11.98(M−3.16)]+65.4. \text{Temp}(M) = 23.3\sin\!\left[\frac{2\pi}{11.98}(M - 3.16)\right] + 65.4.

Evaluate Temp(28)\text{Temp}(28) and Temp′(28)\text{Temp}'(28) in R, and interpret each value.

ShowHide solution

Define Temp and differentiate it with D() to get dTemp, R’s name for Temp′\text{Temp}'. Evaluate both at month 28, and evaluate Temp at months 27 and 29. Used R.

Temp = makeFun(23.3*sin(2*pi/11.98*(M - 3.16)) + 65.4 ~ M)
dTemp = D(Temp(M) ~ M)
Temp(28)
[1] 75.77605
dTemp(28)
[1] 10.94161
Temp(27)
[1] 63.93454
Temp(29)
[1] 84.82823

Month 28 is May 2008, since month 24 is January 2008. At the beginning of May 2008, the model gives an average maximum temperature in central Kentucky of about 75.776 degrees Fahrenheit: Temp(28)≈75.776\text{Temp}(28) \approx 75.776.

At month 28, the model’s average maximum temperature is increasing at about 10.942 degrees Fahrenheit per month: Temp′(28)≈10.942\text{Temp}'(28) \approx 10.942.

As a check, the rate lies between the model’s changes over the months before and after month 28:

Temp(28)−Temp(27)≈11.842>10.942>9.052≈Temp(29)−Temp(28). \text{Temp}(28) - \text{Temp}(27) \approx 11.842 > 10.942 > 9.052 \approx \text{Temp}(29) - \text{Temp}(28).

It should, because Temp′\text{Temp}' falls toward zero on the approach to the next peak.

Example 10

In R, plot the function

Temp(M)=23.3sin⁡ ⁣[2π11.98(M−3.16)]+65.4 \text{Temp}(M) = 23.3\sin\!\left[\frac{2\pi}{11.98}(M - 3.16)\right] + 65.4

and its derivative Temp′\text{Temp}' on 0≤M≤600 \le M \le 60.

ShowHide solution

Define Temp and differentiate it with D() to get dTemp, R’s name for Temp′\text{Temp}'. Plot each on 0≤M≤600 \le M \le 60. Used R.

Temp = makeFun(23.3*sin(2*pi/11.98*(M - 3.16))
+ 65.4 ~ M)
dTemp = D(Temp(M) ~ M)
plotFun(Temp(M) ~ M, xlim = range(0, 60))
plotFun(dTemp(M) ~ M, xlim = range(0, 60))
The derivative Temp′\text{Temp}' is zero at each peak and trough of Temp, because the tangent line to the graph of Temp is horizontal at each peak and trough. Sine reaches its maximum, 1, when its input is π/2\pi/2. The first peak of Temp with M≥0M \ge 0 comes where

2π11.98(M−3.16)=π2. \frac{2\pi}{11.98}(M - 3.16) = \frac{\pi}{2}.

Multiply both sides by 11.982π\frac{11.98}{2\pi}, then add 3.16:

M−3.16=11.984,M=3.16+2.995=6.155. M - 3.16 = \frac{11.98}{4}, \qquad M = 3.16 + 2.995 = 6.155.

The input π/2−2π\pi/2 - 2\pi gives M=6.155−11.98<0M = 6.155 - 11.98 < 0. The peak value of Temp is 23.3(1)+65.4=88.723.3(1) + 65.4 = 88.7. Each of R’s two plots appears here with a dashed line and a marked point added. The dashed line marks M=6.155M = 6.155 on both graphs: Temp is at its peak, and Temp′\text{Temp}' is zero. The derivative Temp′\text{Temp}' is positive just to the left of the line, where Temp rises, and negative just to the right, where Temp falls.

Figure
Figure

Example 11

The quotient rule and the chain rule give the hand derivative q′q' of the function qq:

q(x)=cos⁡(x2)e2x,q′(x)=−2xsin⁡(x2)+2cos⁡(x2)e2x. q(x) = \frac{\cos(x^2)}{e^{2x}}, \qquad q'(x) = -\frac{2x\sin(x^2) + 2\cos(x^2)}{e^{2x}}.

Check this derivative against D() at x=0x = 0 and at x=1x = 1.

ShowHide solution

Evaluate the hand derivative at each input, using sin⁡(1)≈0.841471\sin(1) \approx 0.841471, cos⁡(1)≈0.540302\cos(1) \approx 0.540302, and e2≈7.389056e^2 \approx 7.389056, with sine and cosine in radians.

q′(0)=−2(0)sin⁡(02)+2cos⁡(02)e2(0)=−0+21=−2,q′(1)=−2(1)sin⁡(12)+2cos⁡(12)e2(1)≈−2(0.841471)+2(0.540302)7.389056=−2.7635467.389056≈−0.374.\begin{align*} q'(0) &= -\frac{2(0)\sin(0^2) + 2\cos(0^2)}{e^{2(0)}} = -\frac{0 + 2}{1} = -2,\\ q'(1) &= -\frac{2(1)\sin(1^2) + 2\cos(1^2)}{e^{2(1)}} \approx -\frac{2(0.841471) + 2(0.540302)}{7.389056} = -\frac{2.763546}{7.389056} \approx -0.374. \end{align*}

Define qq and differentiate it with D() to get dq, R’s name for q′q'. Evaluate dq at the same inputs. Used R.

q = makeFun(cos(x^2) / exp(2*x) ~ x)
dq = D(q(x) ~ x)
dq(0)
[1] -2
dq(1)
[1] -0.3740054

At x=0x = 0, R gives the hand value −2-2 exactly. At x=1x = 1, R’s value rounds to the hand value −0.374-0.374. The agreement at both inputs supports the hand derivative.

Lesson map

Found a mistake, a broken tool or something unclear? Report a problem