---
title: Derivative rules, shown geometrically
heading: Products, quotients and chains
eyebrow: A5 · Lesson 10 · Derivative rules
xp: 40
---

::: hook
The power rule handles $x^5$. But engineering formulas are built from pieces multiplied, divided and nested: power is voltage times current, a gain is one impedance over another, and a signal inside a sine is often itself a function of time. Three rules cover all of them, and each has a picture behind it that makes it hard to forget.

::: play
- The curve is $y = g(x)^3$, a function inside a function, with the inside $g(x) = 1 + mx$. The strip compares the slope measured from the curve with the chain rule's prediction, $3g^2 \cdot g'$.
- Change the inside's steepness $m$. How does the slope of the whole thing respond?
- Move $x_0$ and check that the two slopes always agree.
:::
:::

```sim plot
view: graph
x: x = -2..2
y: y = -2..30
slider: m = 0.1..1.5 step 0.05 = 0.5
slider: x0 = -2..2 step 0.05 = 1
plot: (1 + m*x)^3 | label: y = g(x)³
plot: (1 + m*x0)^3 + 3*(1 + m*x0)^2*m*(x - x0) | dashed | color: ch2
point: x0, (1 + m*x0)^3
readout: slope from the curve = ((1 + m*(x0 + 0.000001))^3 - (1 + m*(x0 - 0.000001))^3)/0.000002
readout: chain rule 3g²·g′ = 3*(1 + m*x0)^2*m
```

::: predict
## You double the inner function's steepness $m$, keeping $x_0$ at 0. What happens to the slope of $g^3$ there?

- [ ] Nothing
- [x] It doubles
- [ ] It goes up eight times
- [ ] It halves

::: reveal
It doubles. At $x_0 = 0$, $g = 1$ whatever $m$ is, so the outer part's rate, $3g^2 = 3$, stays put, while the inner rate $g' = m$ doubles. Rates of nested functions multiply, like gears: the outer function's rate per unit of $g$ times $g$'s rate per unit of $x$.
:::
:::

::: nameit
## The three rules

**Product rule.** Think of $f(x)\,g(x)$ as the area of a rectangle with sides $f$ and $g$. Nudge $x$ and both sides grow, by $\Delta f$ and $\Delta g$. The area gains two thin strips, $f\,\Delta g$ and $g\,\Delta f$, plus a tiny corner $\Delta f\,\Delta g$ that vanishes faster than the strips. So

$$(fg)' = f'g + fg'$$

Electrical power $p = vi$ is a product, so its rate of change is $\dot v\, i + v\,\dot i$.

**Chain rule.** For a function inside a function, $f(g(x))$, the rates multiply:

$$\frac{d}{dx}f\big(g(x)\big) = f'\big(g(x)\big)\cdot g'(x)$$

Differentiate the outside as if the inside were a plain variable, then multiply by the derivative of the inside. For example, $\frac{d}{dx}(3x + 1)^5 = 5(3x + 1)^4 \cdot 3$, and $\frac{d}{dx}\sqrt{1 + x^2} = \frac{1}{2\sqrt{1 + x^2}} \cdot 2x = \frac{x}{\sqrt{1 + x^2}}$.

**Quotient rule.** Write $f/g$ as $f \cdot g^{-1}$ and use the other two rules:

$$\left(\frac{f}{g}\right)' = \frac{f'g - fg'}{g^2}$$

The order on top matters: derivative of the top first. A safe memory aid is to rederive it from the product and chain rules when in doubt.

With these, the power rule and the derivatives of $e^x$, $\sin$ and $\cos$ (next lesson), you can differentiate every formula in this course.
:::

::: example
## A device has $v = 3t^2$ volts and $i = 2t + 1$ amps. How fast is its power changing?

::: solution
1. **Product rule on $p = vi$.**
   $$\begin{aligned} p' &= v'i + vi' \\ &= 6t(2t + 1) + 3t^2 \cdot 2 \\ &= 18t^2 + 6t \end{aligned}$$
2. **Evaluate at $t = 1$ s.**
   $$\begin{aligned} p'(1) &= 18 + 6 \\ &= 24\ \text{W/s} \end{aligned}$$
3. **Check by expanding first.** $p = 6t^3 + 3t^2$, so $p' = 18t^2 + 6t$.

**Answer:** the power changes at $18t^2 + 6t$ watts per second, which is 24 W/s at $t = 1$ s.
:::
:::

::: example
## How sensitive is a divider's ratio $\frac{R_2}{R_1 + R_2}$ to $R_2$?

::: solution
1. **Quotient rule.** Call the ratio $k = \frac{R_2}{R_1 + R_2}$:
   $$\begin{aligned} \frac{dk}{dR_2} &= \frac{(R_1 + R_2) - R_2}{(R_1 + R_2)^2} \\ &= \frac{R_1}{(R_1 + R_2)^2} \end{aligned}$$
2. **Put in 10 kΩ and 10 kΩ.**
   $$\frac{dk}{dR_2} = \frac{1}{40\ \text{k}\Omega}$$
3. **A 100 Ω change in $R_2$.**
   $$\begin{aligned} \Delta k &\approx \frac{100\ \Omega}{40\ \text{k}\Omega} \\ &= 0.0025 \end{aligned}$$

**Answer:** the sensitivity is $R_1/(R_1 + R_2)^2$; with 10 kΩ and 10 kΩ that's $1/(40\text{ k}\Omega)$, so a 100 Ω change in $R_2$ moves the ratio by 0.0025.
:::
:::

::: example
## A source of EMF $E$ with internal resistance $r$ delivers $P = \dfrac{E^2R}{(R + r)^2}$ to a load $R$. Where is $dP/dR$ zero?

::: solution
1. **Quotient rule.**
   $$\begin{aligned} \frac{dP}{dR} &= E^2\frac{(R + r)^2 - R \cdot 2(R + r)}{(R + r)^4} \\ &= E^2\frac{r - R}{(R + r)^3} \end{aligned}$$
2. **Find the zero.** The top, $r - R$, is zero only at $R = r$.
3. **Read the sign.** $dP/dR$ is positive below $R = r$ and negative above, so the power rises to a peak at $R = r$ and falls after.

**Answer:** $dP/dR$ is zero only at $R = r$, where the power peaks. That's the maximum power transfer theorem, from one derivative.
:::
:::

::: check
kind: expression
answer: 2*x*(x + 1)^3 + 3*x^2*(x + 1)^2
vars: x = -2..2

## Differentiate $x^2(x + 1)^3$.

::: right
Right. Product rule: $(x^2)'(x + 1)^3 + x^2\big((x + 1)^3\big)'$, and the second factor needs the chain rule.
:::

::: misses
- [2*x*3*(x + 1)^2] The derivative of a product isn't the product of the derivatives. Use $f'g + fg'$.
- [2*x*(x + 1)^3] That's only half: add $x^2$ times the derivative of $(x + 1)^3$.
- [any] Not yet. Use the product rule, with $f = x^2$ and $g = (x + 1)^3$.
:::
:::

::: check
kind: expression
given: a = 2..6 int; n = 3..6 int
answer: n*a*(a*x + 1)^(n - 1)
vars: x = -0.5..0.5

## Differentiate $(\given{a}x + 1)^{\given{n}}$.

::: right
Right. Outside first, $\given{n}(\given{a}x + 1)^{\given{n}-1}$, times the inside's rate, {a}.
:::

::: misses
- [n*(a*x + 1)^(n - 1)] Multiply by the derivative of the inside, {a}.
- [n*a*(a*x + 1)^n] Lower the exponent by one.
- [any] Not yet. Chain rule: differentiate the power, then multiply by the derivative of $\given{a}x + 1$.
:::
:::

::: check
kind: expression
answer: (1 - x^2)/(1 + x^2)^2
vars: x = -2..2

## Differentiate $\dfrac{x}{1 + x^2}$.

::: right
Right. $\dfrac{1\cdot(1 + x^2) - x \cdot 2x}{(1 + x^2)^2} = \dfrac{1 - x^2}{(1 + x^2)^2}$.
:::

::: misses
- [(x^2 - 1)/(1 + x^2)^2] The top's order matters: derivative of the top times the bottom, minus the top times the derivative of the bottom.
- [1/(2*x)] You can't differentiate top and bottom separately.
- [any] Not yet. Use $(f/g)' = (f'g - fg')/g^2$.
:::
:::

::: check
given: v0 = 2 | 4 | 6 | 8 | 10; i0 = 2 | 4; dv = 1 | 3 | 5 | 7 | 9; di = 1 | 3 | 5 | 7 | 9
answer: dv*i0 + v0*di
unit: W/s
tolerance: 0.5%

## At some instant a device has $v$ = {v0} V and $i$ = {i0} A, with $v$ rising at {dv} V/s and $i$ at {di} A/s. How fast is the power $p = vi$ changing, in W/s?

::: right
Right. $\dot p = \dot v\,i + v\,\dot i = \given{dv}\cdot\given{i0} + \given{v0}\cdot\given{di}$ = {answer}.
:::

::: misses
- [dv*di] The rate of a product isn't the product of the rates. Use the product rule.
- [dv*i0] Add the second strip too: $v\,\dot i$.
- [any] Not yet. Use $\dot p = \dot v\, i + v\,\dot i$.
:::
:::

::: check
kind: parts
given: a = 2 | 3; b = 1 | 5; x0 = 1 | 2

## Differentiate these at $x$ = {x0}.

::: part
answer: (a*b - 1)/(x0 + b)^2
tolerance: 0.5%

### $\dfrac{\given{a}x + 1}{x + \given{b}}$

::: misses
- [(1 - a*b)/(x0 + b)^2] The quotient rule is (bottom × top′ − top × bottom′) over bottom²: check the order.
- [any] Quotient rule.
:::
:::

::: part
answer: 2*x0*(a*x0 + 1) + a*x0^2
tolerance: 0.5%

### $x^2(\given{a}x + 1)$

::: misses
- [2*x0*a] The product rule has two terms.
- [any] $(uv)' = u'v + uv'$.
:::
:::

::: part
answer: a/(2*sqrt(a*x0 + b))
tolerance: 0.5%

### $\sqrt{\given{a}x + \given{b}}$

::: misses
- [1/(2*sqrt(a*x0 + b))] The chain rule brings out the inside's derivative, {a}.
- [any] $\frac{d}{dx}\sqrt{u} = \frac{u'}{2\sqrt{u}}$.
:::
:::
:::

::: check
kind: derivation
vars: E = 1..20, R = 0.1..20, r = 0.1..10

## Differentiate the load power $P = \dfrac{E^2R}{(R + r)^2}$ with respect to $R$.

::: step
answer: E^2*(r - R)/(R + r)^3
form: simplified

### Apply the quotient rule and simplify.
:::

::: step
answer: r

### Where is $dP/dR$ zero?
:::

::: step
answer: E^2/(4*r)

### What is $P$ there?
:::

::: right
Right. The derivative changes sign at $R = r$, where the load gets $E^2/4r$.
:::
:::

::: explain
## Using the picture of a rectangle, explain why the derivative of $fg$ isn't $f'g'$.

::: model
Picture $fg$ as the area of a rectangle with sides $f$ and $g$. When $x$ changes a little, both sides grow, and the area grows by two long thin strips: one is the old side $f$ times the small growth in $g$, the other is $g$ times the small growth in $f$. Those strips give $fg' + f'g$. The product $f'g'$ only describes the tiny corner where both growths overlap, which becomes negligible as the change shrinks.
:::
:::

::: practice

::: check
kind: expression
given: a = 2..6 int; b = 1..6 int
answer: (a*(x + b) - (a*x))/(x + b)^2
vars: x = 0..3

## Differentiate $\dfrac{\given{a}x}{x + \given{b}}$.

::: misses
- [a] Don't differentiate top and bottom separately: use the quotient rule.
- [any] $(f/g)' = (f'g - fg')/g^2$ with $f = \given{a}x$, $g = x + \given{b}$.
:::
:::

::: check
kind: expression
given: a = 2..9 int
answer: a*x/sqrt(1 + a*x^2)
vars: x = -2..2

## Differentiate $\sqrt{1 + \given{a}x^2}$.

::: misses
- [1/(2*sqrt(1 + a*x^2))] Multiply by the derivative of the inside, $2\cdot\given{a}x$.
- [any] Chain rule: $\frac{1}{2\sqrt{u}}$ times $u'$.
:::
:::

::: check
kind: expression
given: n = 2..5 int
answer: (x + 1)^n + n*x*(x + 1)^(n - 1)
vars: x = -1..1

## Differentiate $x(x + 1)^{\given{n}}$.

::: misses
- [n*(x + 1)^(n - 1)] That's the derivative of a product treated as a product of derivatives. Use the product rule.
- [any] Product rule, with the chain rule inside.
:::
:::

::: check
given: x0 = 1 | 2 | 3; k = 2..5 int
answer: k*(x0^2 + 1)^(k - 1)*2*x0
tolerance: 0.5%

## What is the slope of $(x^2 + 1)^{\given{k}}$ at $x = \given{x0}$?

::: misses
- [k*(x0^2 + 1)^(k - 1)] Multiply by the derivative of the inside, $2x$.
- [any] Chain rule: $k(x^2 + 1)^{k-1} \cdot 2x$.
:::
:::
:::
