Skip to contentSkip to lesson map

Product and Quotient Rules I

Status
Updates coming
Reading
MMAC Ch 4.4, pp 407-416, and Ch 4.3, pp 400-401
Lesson map

Objectives

  1. Use the derivative at a given input to obtain a linear approximation of the function there.
  2. Use basic derivative rules plus the product and quotient rules to find derivatives by hand.
  3. In R, use D() to find the derivative of a function.

1. Linear Approximation

Objective. Use the derivative at a given input to obtain a linear approximation of the function there.

Definition 1 (Linear approximation).

For a function f(x)f(x) differentiable at x=ax = a, the linear approximation of f(x)f(x) when x=ax = a is the tangent line to f(x)f(x) when x=ax = a, given by

L(x)=f(a)+f′(a)(x−a). L(x) = f(a) + f'(a)(x - a).

The line through (4,2)(4, 2) and (9,3)(9, 3), two points on the graph of f(x)=xf(x) = \sqrt{x}, is not the linear approximation of x\sqrt{x} when x=4x = 4, because the definition requires the tangent line. This line is a secant line with slope (3−2)/(9−4)=0.2(3 - 2)/(9 - 4) = 0.2, while the tangent line has slope f′(4)=12⋅4−1/2=0.25f'(4) = \tfrac{1}{2} \cdot 4^{-1/2} = 0.25 (Example 1).

For inputs near aa, the value L(x)L(x) is close to f(x)f(x), because LL has the same output f(a)f(a) and the same rate of change f′(a)f'(a) as ff at x=ax = a. The difference f(x)−L(x)f(x) - L(x) is the error of the approximation. Farther from aa, the graph of ff can bend away from the line, and the error can grow.

Example 1

Find the linear approximation of

f(x)=x f(x) = \sqrt{x}

at a=4a = 4. Estimate 4.1\sqrt{4.1} and 16\sqrt{16} with the linear approximation.

ShowHide solution

By the definition of the linear approximation, LL is the tangent line to ff when x=4x = 4. Substitute a=4a = 4 into the formula for the linear approximation:

L(x)=f(4)+f′(4)(x−4). L(x) = f(4) + f'(4)(x - 4).

Rewrite x\sqrt{x} as x1/2x^{1/2}. The power rule gives f′(x)=12x−1/2f'(x) = \tfrac{1}{2}x^{-1/2}. Evaluate ff and f′f' at 4:

f(4)=4=2,f′(4)=12⋅4−1/2=12⋅12=0.25. f(4) = \sqrt{4} = 2, \qquad f'(4) = \tfrac{1}{2} \cdot 4^{-1/2} = \tfrac{1}{2} \cdot \tfrac{1}{2} = 0.25.

Substitute both values into L(x)L(x):

L(x)=2+0.25(x−4). L(x) = 2 + 0.25(x - 4).

Estimate 4.1\sqrt{4.1} with LL at x=4.1x = 4.1:

L(4.1)=2+0.25(4.1−4)=2+0.25(0.1)=2.025. L(4.1) = 2 + 0.25(4.1 - 4) = 2 + 0.25(0.1) = 2.025.

For comparison, R computes the true value with sqrt(4.1): 4.1≈2.024846\sqrt{4.1} \approx 2.024846. The error f(4.1)−L(4.1)≈2.024846−2.025=−0.000154f(4.1) - L(4.1) \approx 2.024846 - 2.025 = -0.000154 is small, because 4.1 is close to a=4a = 4.

Estimate 16\sqrt{16} with LL at x=16x = 16:

L(16)=2+0.25(16−4)=2+0.25(12)=5. L(16) = 2 + 0.25(16 - 4) = 2 + 0.25(12) = 5.

The true value is 16=4\sqrt{16} = 4. The error f(16)−L(16)=4−5=−1f(16) - L(16) = 4 - 5 = -1 is far larger in size, because 16 is far from a=4a = 4. On the graph, the red line LL touches the curve at (4,2)(4, 2) and lies close to the curve for inputs near x=4x = 4. At x=16x = 16 the line lies above the curve.

Figure

Example 2

In R, find the linear approximation of

f(x)=x3−5x f(x) = x^3 - 5x

at a=1a = 1. Estimate f(1.1)f(1.1) with the linear approximation, compare the estimate with f(1.1)f(1.1), and plot ff with LL.

ShowHide solution

Build the linear approximation L(x)=f(1)+f′(1)(x−1)L(x) = f(1) + f'(1)(x - 1) as in Example 1, with f(1)f(1) and f′(1)f'(1) from R. Then compare L(1.1)L(1.1) with f(1.1)f(1.1), and plot ff with LL. Used R.

f = makeFun(x^3 - 5*x ~ x)
df = D(f(x) ~ x)
f(1)
[1] -4
df(1)
[1] -2
L = makeFun(f(1) + df(1)*(x - 1) ~ x)
L(1.1)
[1] -4.2
f(1.1)
[1] -4.169
plotFun(f(x) ~ x, xlim = range(-3, 3))
plotFun(L(x) ~ x, add = TRUE, col = "red")

The code stores the derivative f′f' under the name df. R prints f(1)=−4f(1) = -4 and f′(1)=−2f'(1) = -2. The linear approximation is therefore L(x)=−4−2(x−1)L(x) = -4 - 2(x - 1). The command that defines L is the formula L(x)=f(1)+f′(1)(x−1)L(x) = f(1) + f'(1)(x - 1) written in R. The error of the estimate is f(1.1)−L(1.1)=−4.169−(−4.2)=0.031f(1.1) - L(1.1) = -4.169 - (-4.2) = 0.031. In the plot, the red line LL touches the black curve ff at (1,f(1))=(1,−4)(1, f(1)) = (1, -4) with slope f′(1)=−2f'(1) = -2.

Figure

Example 3

For the function

g(x)=x2sin⁡(x)x+1, g(x) = \frac{x^2\sin(x)}{x + 1},

find g(2)g(2) and g′(2)g'(2) in R. Write the linear approximation of gg at a=2a = 2, and estimate g(1.9)g(1.9) with it.

ShowHide solution

Compute g(2)g(2) from g and g′(2)g'(2) from the derivative that D() returns, build LL as in Example 2, and evaluate L(1.9)L(1.9). Used R.

g = makeFun(x^2*sin(x)/(x + 1) ~ x)
dg = D(g(x) ~ x)
g(2)
[1] 1.212397
dg(2)
[1] 0.2534019
L = makeFun(g(2) + dg(2)*(x - 2) ~ x)
L(1.9)
[1] 1.187056

To three decimals, g(2)≈1.212g(2) \approx 1.212 and g′(2)≈0.253g'(2) \approx 0.253. The linear approximation is

L(x)=g(2)+g′(2)(x−2)≈1.212+0.253(x−2), L(x) = g(2) + g'(2)(x - 2) \approx 1.212 + 0.253(x - 2),

and the estimate is g(1.9)≈L(1.9)≈1.187g(1.9) \approx L(1.9) \approx 1.187.

Lesson map

2. Product and Quotient Rules

Objective. Use basic derivative rules plus the product and quotient rules to find derivatives by hand.

To differentiate a product of two functions, use the product rule below. For x2⋅x3x^2 \cdot x^3, combining the factors into one power first gives

ddx[x2⋅x3]=ddx[x5]=5x4, \dfrac{d}{dx}\left[x^2 \cdot x^3\right] = \dfrac{d}{dx}\left[x^5\right] = 5x^4,

and the product rule gives the same derivative without combining:

ddx[x2⋅x3]=x3⋅2x+x2⋅3x2=2x4+3x4=5x4. \dfrac{d}{dx}\left[x^2 \cdot x^3\right] = x^3 \cdot 2x + x^2 \cdot 3x^2 = 2x^4 + 3x^4 = 5x^4.

Rule 2 (Product rule).

Let f(x)f(x) and g(x)g(x) be differentiable functions. Then

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

Rule 3 (Quotient rule).

Let f(x)f(x) and g(x)g(x) be differentiable functions. When g(x)≠0g(x) \neq 0, the following holds:

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

The rules in words. The derivative of a product is the sum of two terms, each the derivative of one factor times the other factor. The derivative of a quotient is the denominator times the derivative of the numerator, minus the numerator times the derivative of the denominator, all divided by the square of the denominator.

Order in the quotient rule. In the quotient rule, the numerator is a difference. Reversing its two terms gives the negative of the derivative.

Squared sine notation. The expression sin⁡2(x)\sin^2(x) means (sin⁡(x))2(\sin(x))^2.

Example 4

Differentiate

f(x)=3x2ex. f(x) = 3x^2e^x.
ShowHide solution

By the product rule, the derivative of a product of two differentiable factors u(x)u(x) and v(x)v(x) is

ddx[u(x)⋅v(x)]=v(x)⋅u′(x)+u(x)⋅v′(x). \dfrac{d}{dx}\left[u(x) \cdot v(x)\right] = v(x) \cdot u'(x) + u(x) \cdot v'(x).

Here the factors are u(x)=3x2u(x) = 3x^2, with derivative 6x6x, and v(x)=exv(x) = e^x, with derivative exe^x. Substitute them into the product rule:

f′(x)=ex⋅6x+3x2⋅ex=6xex+3x2ex. f'(x) = e^x \cdot 6x + 3x^2 \cdot e^x = 6xe^x + 3x^2e^x.

Example 5

Differentiate

w(t)=t sin⁡(t). w(t) = \sqrt{t}\,\sin(t).
ShowHide solution

The two factors are t=t1/2\sqrt{t} = t^{1/2}, with derivative 12t−1/2\tfrac{1}{2}t^{-1/2} by the power rule, and sin⁡(t)\sin(t), with derivative cos⁡(t)\cos(t). By the product rule,

w′(t)=sin⁡(t)⋅12t−1/2+t1/2cos⁡(t)=sin⁡(t)2t+tcos⁡(t) w'(t) = \sin(t) \cdot \tfrac{1}{2}t^{-1/2} + t^{1/2}\cos(t) = \frac{\sin(t)}{2\sqrt{t}} + \sqrt{t}\cos(t)

for every tt with t>0t > 0, where both factors are differentiable.

Example 6

Differentiate

f(x)=sin⁡(x)x2. f(x) = \frac{\sin(x)}{x^2}.
ShowHide solution

By the quotient rule, the derivative of a quotient of a differentiable u(x)u(x) by a differentiable v(x)v(x), at each input xx with v(x)≠0v(x) \neq 0, is

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

Here the numerator is u(x)=sin⁡(x)u(x) = \sin(x), with derivative cos⁡(x)\cos(x), and the denominator is v(x)=x2v(x) = x^2, with derivative 2x2x. Substitute them into the quotient rule, then divide the numerator and the denominator by xx:

f′(x)=x2cos⁡(x)−sin⁡(x)⋅2x(x2)2=x2cos⁡(x)−2xsin⁡(x)x4=xcos⁡(x)−2sin⁡(x)x3 f'(x) = \frac{x^2\cos(x) - \sin(x) \cdot 2x}{(x^2)^2} = \frac{x^2\cos(x) - 2x\sin(x)}{x^4} = \frac{x\cos(x) - 2\sin(x)}{x^3}

for every xx with x≠0x \neq 0.

Example 7

Differentiate

r(x)=x2x+1. r(x) = \frac{x^2}{x + 1}.
ShowHide solution

The numerator is x2x^2, with derivative 2x2x, and the denominator is x+1x + 1, with derivative 1. By the quotient rule,

r′(x)=(x+1)⋅2x−x2⋅1(x+1)2=2x2+2x−x2(x+1)2=x2+2x(x+1)2 r'(x) = \frac{(x + 1) \cdot 2x - x^2 \cdot 1}{(x + 1)^2} = \frac{2x^2 + 2x - x^2}{(x + 1)^2} = \frac{x^2 + 2x}{(x + 1)^2}

for every xx with x≠−1x \neq -1.

Example 8

Differentiate

z(x)=cos⁡(x)sin⁡(x). z(x) = \frac{\cos(x)}{\sin(x)}.
ShowHide solution

The numerator is cos⁡(x)\cos(x), with derivative −sin⁡(x)-\sin(x), and the denominator is sin⁡(x)\sin(x), with derivative cos⁡(x)\cos(x). By the quotient rule,

z′(x)=sin⁡(x)(−sin⁡(x))−cos⁡(x)cos⁡(x)sin⁡2(x)=−(sin⁡2(x)+cos⁡2(x))sin⁡2(x)=−1sin⁡2(x) z'(x) = \frac{\sin(x)(-\sin(x)) - \cos(x)\cos(x)}{\sin^2(x)} = \frac{-\left(\sin^2(x) + \cos^2(x)\right)}{\sin^2(x)} = -\frac{1}{\sin^2(x)}

for every xx with sin⁡(x)≠0\sin(x) \neq 0, because sin⁡2(x)+cos⁡2(x)=1\sin^2(x) + \cos^2(x) = 1 for every input xx.

Example 9

Differentiate

y(x)=x2cos⁡(x)ln⁡(x). y(x) = \frac{x^2\cos(x)}{\ln(x)}.
ShowHide solution

The numerator x2cos⁡(x)x^2\cos(x) is a product. By the product rule, its derivative is

ddx[x2cos⁡(x)]=cos⁡(x)⋅2x+x2⋅(−sin⁡(x))=2xcos⁡(x)−x2sin⁡(x). \dfrac{d}{dx}\left[x^2\cos(x)\right] = \cos(x) \cdot 2x + x^2 \cdot (-\sin(x)) = 2x\cos(x) - x^2\sin(x).

The denominator is ln⁡(x)\ln(x), with derivative 1x\frac{1}{x}. By the quotient rule,

y′(x)=ln⁡(x)(2xcos⁡(x)−x2sin⁡(x))−x2cos⁡(x)⋅1x[ln⁡(x)]2=ln⁡(x)(2xcos⁡(x)−x2sin⁡(x))−xcos⁡(x)[ln⁡(x)]2 y'(x) = \frac{\ln(x)\left(2x\cos(x) - x^2\sin(x)\right) - x^2\cos(x) \cdot \frac{1}{x}}{[\ln(x)]^2} = \frac{\ln(x)\left(2x\cos(x) - x^2\sin(x)\right) - x\cos(x)}{[\ln(x)]^2}

for every xx with x>0x > 0 and x≠1x \neq 1.

Example 10

Determine which of these functions are differentiated with the product rule, which with the quotient rule, and which with only the basic derivative rules of Lesson 29:

4sin⁡(x),x3ex,x2+13,exx,x5x2,(x2+1)ln⁡(x). 4\sin(x), \qquad x^3e^x, \qquad \frac{x^2 + 1}{3}, \qquad \frac{e^x}{x}, \qquad \frac{x^5}{x^2}, \qquad (x^2 + 1)\ln(x).
ShowHide solution
  • Differentiate x3exx^3e^x and (x2+1)ln⁡(x)(x^2 + 1)\ln(x) with the product rule, because each is a product of two non-constant factors, and no algebra rewrites it as a linear combination of power functions and basic modeling functions (Lesson 29).
  • Differentiate exx\frac{e^x}{x} with the quotient rule, because its denominator is not constant, and no algebra rewrites the quotient as a linear combination of power functions and basic modeling functions.
  • Differentiate 4sin⁡(x)4\sin(x) with only the basic derivative rules, because the function is the constant 4 times sin⁡(x)\sin(x). Its derivative is 4cos⁡(x)4\cos(x).
  • Differentiate x2+13\frac{x^2 + 1}{3} with only the basic derivative rules, because the function is the constant 13\frac{1}{3} times x2+1x^2 + 1. Its derivative is 2x3\frac{2x}{3}.
  • Differentiate x5x2\frac{x^5}{x^2} with only the basic derivative rules, because the function simplifies to x3x^3. Its derivative is 3x23x^2. The simplified form x3x^3 equals x5x2\frac{x^5}{x^2} only for x≠0x \neq 0, the domain of x5x2\frac{x^5}{x^2}. The derivative 3x23x^2 applies on that domain.

Lesson map

3. Derivatives in R

Objective. In R, use D() to find the derivative of a function.

The command D() differentiates products and quotients with the same syntax as in Lesson 29, D(f(x) ~ x).

Checking a hand derivative. The derivative R prints can look different from the hand derivative and still be equal to it. To check, rewrite the printed form by algebra until it matches the hand derivative. To spot-check, evaluate both derivatives at one input: different outputs show that the two derivatives differ, and equal outputs show agreement at that input only.

Parentheses in a quotient. Type a quotient with parentheses around a numerator or a denominator that has more than one term, as in (3*x - 2)/(x^2 + 5). Without them, 3*x - 2/(x^2 + 5) divides only the 2, and R gives a wrong value with no error.

Products in R. Type every product with *. R rejects 3x^2, typed in place of 3*x^2, with an error:

> 3x^2
Error: unexpected symbol in "3x"

Example 11

Find the derivative of

f(x)=3x2ex f(x) = 3x^2e^x

in R. Check it against the hand derivative 6xex+3x2ex6xe^x + 3x^2e^x.

ShowHide solution

Define ff, differentiate it with D(), and print the derivative. Used R.

f = makeFun(3*x^2*exp(x) ~ x)
df = D(f(x) ~ x)
df
function (x)
3 * (x^2 * exp(x) + 2 * x * exp(x))

R prints the derivative as a function of xx, with its formula on the second line. The printed form 3(x2ex+2xex)=3x2ex+6xex3(x^2e^x + 2xe^x) = 3x^2e^x + 6xe^x matches the hand derivative. As a spot check at x=1x = 1, the hand derivative is

6(1)e1+3(1)2e1=6e+3e=9e. 6(1)e^1 + 3(1)^2e^1 = 6e + 3e = 9e.

Evaluate the R derivative and 9e9e. Used R.

df(1)
[1] 24.46454
9*exp(1)
[1] 24.46454

The two outputs are equal at x=1x = 1, consistent with the algebraic match.

Example 12

Find the derivative of

r(x)=x2x+1 r(x) = \frac{x^2}{x + 1}

in R. Check it against the hand derivative (x2+2x)/(x+1)2(x^2 + 2x)/(x + 1)^2.

ShowHide solution

Define rr with parentheses around the denominator, differentiate it with D(), and print the derivative. Used R.

r = makeFun(x^2/(x + 1) ~ x)
dr = D(r(x) ~ x)
dr
function (x)
{
.e1 <- 1 + x
x * (2 - x/.e1)/.e1
}

The line .e1 <- 1 + x stores the denominator x+1x + 1 under the name .e1, and the last line is the derivative written with that name:

x(2−xx+1)x+1=x⋅2(x+1)−xx+1x+1=x(x+2)(x+1)2=x2+2x(x+1)2. \frac{x\left(2 - \dfrac{x}{x + 1}\right)}{x + 1} = \frac{x \cdot \dfrac{2(x + 1) - x}{x + 1}}{x + 1} = \frac{x(x + 2)}{(x + 1)^2} = \frac{x^2 + 2x}{(x + 1)^2}.

The printed form matches the hand derivative. As a spot check at x=1x = 1, the hand derivative is

12+2(1)(1+1)2=34=0.75. \frac{1^2 + 2(1)}{(1 + 1)^2} = \frac{3}{4} = 0.75.

Evaluate the R derivative at 1. Used R.

dr(1)
[1] 0.75

The R value and the hand value are equal at x=1x = 1, consistent with the algebraic match.

Lesson map

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