# Math 141, Lesson 31: Product and Quotient Rules II

The lesson page, with interactive tools and R in the browser: https://tangentspace.org/lessons/31/

This lesson is marked "Updates coming": parts of it are still being written.

Reading: MMAC Ch 4.4, pp 407-422

Practice: Optional HW 31 **[Q?? and Q??]**.

## Objectives

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

## 1. Derivatives by Hand

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

*Order of work.* Finding a derivative by hand combines the basic rules from sections 2 to 4 of the [Lesson 29](https://tangentspace.org/lessons/29/) Notes with the product and quotient rules from section 2 of the [Lesson 30](https://tangentspace.org/lessons/30/) Notes.

1. Rewrite roots and reciprocals of powers of $x$ as powers, as in $\sqrt{x} = x^{1/2}$ and $1/x^2 = x^{-2}$.
2. Identify the main operation: a sum, a constant multiple, a product, or a quotient.
3. For a sum, differentiate term by term. For a constant multiple, keep the constant and differentiate the function it multiplies. Apply steps 4 and 5 to each term or function that is a product or a quotient.
4. For a product or a quotient, name $u$ and $v$: the factors of a product, or the numerator and denominator of a quotient.
5. Find $u'$ and $v'$. When $u$ or $v$ is itself a product or a quotient, find its derivative by the same steps. Substitute $u$, $u'$, $v$, and $v'$, each in parentheses, into the product rule or the quotient rule.
6. Simplify the result.

### Example 1

For the function

$$y = \frac{x^4 - 3x^2 + 6}{x^2},$$

find $y'$ by simplifying first. Then find $y'$ by the quotient rule.

**Solution.**

To simplify first, divide each term of the numerator by $x^2$:

$$y = \frac{x^4}{x^2} - \frac{3x^2}{x^2} + \frac{6}{x^2} = x^2 - 3 + 6x^{-2}.$$

Differentiate term by term with the power, constant multiple, and sum rules:

$$y' = 2x - 0 + 6(-2)x^{-3} = 2x - 12x^{-3} = 2x - \frac{12}{x^3}.$$

For the quotient rule, find the derivatives of the numerator $u$ and the denominator $v$:

$$u = x^4 - 3x^2 + 6, \qquad u' = 4x^3 - 6x, \qquad v = x^2, \qquad v' = 2x.$$

Substitute $u$, $u'$, $v$, and $v'$ into the quotient rule, $\left(\dfrac{u}{v}\right)' = \dfrac{u'v - uv'}{v^2}$, and expand the numerator:

$$y' = \frac{(4x^3 - 6x)x^2 - (x^4 - 3x^2 + 6)(2x)}{(x^2)^2}
= \frac{4x^5 - 6x^3 - (2x^5 - 6x^3 + 12x)}{x^4}
= \frac{2x^5 - 12x}{x^4}
= 2x - \frac{12}{x^3}.$$

The two methods give the same derivative, and simplifying first takes fewer steps.

### Example 2

Find the derivative:

$$y = 4e^x 3^x - 2\ln(x) + 5x^3.$$

**Solution.**

The main operation is a sum. Its first term is 4 times the product $e^x 3^x$. Differentiate the product by substituting $u = e^x$, $u' = e^x$, $v = 3^x$, and $v' = 3^x\ln(3)$ into the product rule, $(uv)' = u'v + uv'$:

$$\frac{d}{dx}\big(e^x 3^x\big) = e^x 3^x + e^x 3^x\ln(3) = e^x 3^x\big(1 + \ln(3)\big).$$

Differentiate the whole sum term by term with the constant multiple, logarithm, and power rules:

$$y' = 4e^x 3^x\big(1 + \ln(3)\big) - 2 \cdot \frac{1}{x} + 5 \cdot 3x^2
= 4e^x 3^x\big(1 + \ln(3)\big) - \frac{2}{x} + 15x^2.$$

### Example 3

Find the derivative:

$$f(x) = \frac{x^5 - \sqrt{x}}{\cos(x)}.$$

**Solution.**

The main operation is a quotient. Rewrite $\sqrt{x}$ as $x^{1/2}$, and write the numerator $u$ and the denominator $v$ with their derivatives:

$$u = x^5 - x^{1/2}, \qquad u' = 5x^4 - \tfrac{1}{2}x^{-1/2}, \qquad v = \cos(x), \qquad v' = -\sin(x).$$

Substitute $u$, $u'$, $v$, and $v'$ into the quotient rule. Since $v' = -\sin(x)$, the term $-uv'$ becomes $+\bigl(x^5 - \sqrt{x}\bigr)\sin(x)$ in the numerator. In the second line, $x^{1/2}$ and $x^{-1/2}$ are written as roots again:

$$\begin{align*}
f'(x) &= \frac{\left(5x^4 - \tfrac{1}{2}x^{-1/2}\right)\cos(x) - \left(x^5 - x^{1/2}\right)\big(-\sin(x)\big)}{\cos^2(x)}\\
&= \frac{\left(5x^4 - \dfrac{1}{2\sqrt{x}}\right)\cos(x) + \left(x^5 - \sqrt{x}\right)\sin(x)}{\cos^2(x)}.
\end{align*}$$

### Example 4

Find the derivative:

$$y = \frac{\cos(x)}{(x^3 + 1)\,e^x}.$$

**Solution.**

The main operation is a quotient with $u = \cos(x)$, $u' = -\sin(x)$, and $v = (x^3 + 1)e^x$. The denominator is itself a product. Find $v'$ by the product rule, with factors $x^3 + 1$ and $e^x$ and their derivatives $3x^2$ and $e^x$:

$$v' = 3x^2 e^x + (x^3 + 1)e^x = e^x(x^3 + 3x^2 + 1).$$

Substitute $u$, $u'$, $v$, and $v'$ into the quotient rule:

$$y' = \frac{\big(-\sin(x)\big)(x^3 + 1)e^x - \cos(x)\,e^x(x^3 + 3x^2 + 1)}{(x^3 + 1)^2 (e^x)^2}.$$

Factor $e^x$ out of the numerator and cancel it against one factor of $(e^x)^2$:

$$y' = \frac{e^x\big(-(x^3 + 1)\sin(x) - (x^3 + 3x^2 + 1)\cos(x)\big)}{(x^3 + 1)^2 e^x e^x}
= \frac{-(x^3 + 1)\sin(x) - (x^3 + 3x^2 + 1)\cos(x)}{(x^3 + 1)^2 e^x}.$$

The product rule applied to $(uv)w$, and again to $uv$, gives the product rule for three functions.

**Rule 1** (Product rule for three functions).

Let $u(x)$, $v(x)$, and $w(x)$ be differentiable functions. Then

$$(uvw)' = u'vw + uv'w + uvw'.$$

### Example 5

Find the derivative:

$$y = x^2 e^x \sin(x).$$

**Solution.**

Name the three factors and their derivatives:

$$u = x^2, \quad u' = 2x, \qquad v = e^x, \quad v' = e^x, \qquad w = \sin(x), \quad w' = \cos(x).$$

Substitute the three factors and their derivatives into the product rule for three functions, and factor out $e^x$:

$$y' = 2x e^x\sin(x) + x^2 e^x\sin(x) + x^2 e^x\cos(x)
= e^x\big(2x\sin(x) + x^2\sin(x) + x^2\cos(x)\big).$$

*Matching answer choices.*

1. Substitute $u$, $u'$, $v$, and $v'$ into the product rule or the quotient rule.
2. Simplify the result.
3. Compare the result with each choice.

### Example 6

Determine which choice is the derivative of

$$f(x) = \frac{\ln(x)}{x^3 + x}.$$

| (a) $\dfrac{\ln(x)(3x^2 + 1) - \frac{1}{x}(x^3 + x)}{(x^3 + x)^2}$ | (b) $\dfrac{\frac{1}{x}(x^3 + x) + \ln(x)(3x^2 + 1)}{(x^3 + x)^2}$ |
| --- | --- |
| (c) $\dfrac{\frac{1}{x}(x^3 + x) - \ln(x)(3x^2 + 1)}{x^3 + x}$ | (d) $\dfrac{x^2 + 1 - (3x^2 + 1)\ln(x)}{(x^3 + x)^2}$ |

**Solution.**

Substitute $u = \ln(x)$, $u' = 1/x$, $v = x^3 + x$, and $v' = 3x^2 + 1$ into the quotient rule:

$$f'(x) = \frac{\frac{1}{x}(x^3 + x) - \ln(x)(3x^2 + 1)}{(x^3 + x)^2}.$$

Simplify the first term of the numerator, $\frac{1}{x}(x^3 + x) = x^2 + 1$:

$$f'(x) = \frac{x^2 + 1 - (3x^2 + 1)\ln(x)}{(x^3 + x)^2}.$$

Choice (d) matches this derivative. Choice (a) subtracts the numerator’s terms in the opposite order, choice (b) adds them, and choice (c) has no square in the denominator.

## 2. Derivatives in R

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

*Plotting a derivative.* The command `D()` from section 5 of the [Lesson 29](https://tangentspace.org/lessons/29/) Notes returns the derivative as a function. Give it a name, as in `df = D(f(x) ~ x)`, so that later commands can use it. To plot `df` for $a \le x \le b$, with the vertical axis from $c$ to $d$, use the command

`plotFun(df(x) ~ x, xlim = range(a, b), ylim = range(c, d))`

*Roots in R.* For positive $x$, the cube root of $x$ is `x^(1/3)`, with the exponent in parentheses. Without them, R reads `x^1/3` as $x^1$ divided by 3 and gives a wrong value with no error:

```r
> 8^(1/3)
[1] 2
> 8^1/3
[1] 2.666667
```

### Example 7

For the function

$$f(x) = \frac{x^5 - \sqrt{x}}{\cos(x)},$$

find $f'(1)$ in R. Then plot $f'$ for $0.2 \le x \le 1.2$, with the vertical axis from $-5$ to $40$.

**Solution.**

Define $f$, differentiate it with `D()`, evaluate the derivative at 1, and plot it over the requested window. Used R.

```r
f = makeFun((x^5 - sqrt(x)) / cos(x) ~ x)
df = D(f(x) ~ x)
df(1)
#> [1] 8.328671
plotFun(df(x) ~ x, xlim = range(0.2, 1.2), ylim = range(-5, 40))
```

To three decimals, $f'(1) \approx 8.329$. As a check by the quotient rule with $u = x^5 - \sqrt{x}$ and $v = \cos(x)$, the values $u(1) = 0$, $u'(1) = 5 - \tfrac{1}{2} = 4.5$, $v(1) = \cos(1)$, and $v'(1) = -\sin(1)$ give the same value:

$$f'(1) = \frac{u'(1)v(1) - u(1)v'(1)}{v(1)^2} = \frac{4.5\cos(1) - 0}{\cos^2(1)}
= \frac{4.5}{\cos(1)} \approx 8.329.$$

The plot is the graph of $f'$ over $0.2 \le x \le 1.2$. The value $f'(1) \approx 8.329$ is the height of that graph at $x = 1$, the marked point.

![Figure](https://tangentspace.org/lessons/fig/7e7e48009128.svg)

### Example 8

For the function

$$g(x) = x\cos(x),$$

determine which curve is the graph of $g'(x)$. Evaluate $g'(2)$ in R.

![Figure](https://tangentspace.org/lessons/fig/2ccea68dcf43.svg)

**Solution.**

Find $g'$ by the product rule, with $u = x$ and $v = \cos(x)$:

$$g'(x) = (1)\cos(x) + x\big(-\sin(x)\big) = \cos(x) - x\sin(x).$$

Evaluate $g'(2)$ to locate one point on the graph of $g'$. Used R.

```r
g = makeFun(x*cos(x) ~ x)
dg = D(g(x) ~ x)
dg(2)
#> [1] -2.234742
```

The formula for $g'$ found by the product rule gives the same value:

$$g'(2) = \cos(2) - 2\sin(2) \approx -0.416 - 1.819 = -2.235.$$

At $x = 2$, curve C is the only curve that passes through $(2, g'(2)) \approx (2, -2.235)$. The other three curves sit above $-1$ there. Curve C is therefore the graph of $g'$.

### Example 9

The concentration of a drug in the blood, in milligrams per liter, $t$ hours after a dose, is modeled by

$$C(t) = \frac{20t}{t^2 + 4}.$$

Find $C'(1)$ and $C'(3)$ in R. Give the units of $C'$. Determine whether the concentration is increasing or decreasing three hours after the dose.

**Solution.**

Define $C$, differentiate it with `D()`, and evaluate $C'$ at 1 and 3. Used R.

```r
C = makeFun(20*t / (t^2 + 4) ~ t)
dC = D(C(t) ~ t)
dC(1)
#> [1] 2.4
dC(3)
#> [1] -0.591716
```

The units of $C'$ are the units of $C$ per unit of $t$: milligrams per liter per hour.

One hour after the dose, the concentration is increasing at 2.4 milligrams per liter per hour, because $C'(1) = 2.4$ is positive. Three hours after the dose, the concentration is decreasing at about 0.592 milligrams per liter per hour, because $C'(3) \approx -0.592$ is negative. On the graph of $C$, the tangent line rises at $t = 1$ and falls at $t = 3$.

![Figure](https://tangentspace.org/lessons/fig/b2036c9e52e7.svg)
