---
title: The chain rule in depth
heading: Rates passed along a chain
eyebrow: A5 · Lesson 14 · The chain rule
xp: 40
---

::: hook
A thermistor's resistance depends on temperature, the voltage across it depends on its resistance, and the temperature itself is rising with time. How fast is the voltage changing? Each link has its own rate, and the chain rule says the overall rate is their product. This one rule handles every nested formula in engineering, from $e^{-t/\tau}$ to $\sin(\omega t + \varphi)$ to the power dissipated in a part whose resistance drifts with its own heat.
:::

::: play
- The curve is $y = \sin(\omega t)$ and the dashed line is its tangent at $t_0$.
- Double $\omega$. How does the slope at the same point in the cycle change?
- Compare the slope readout with the chain rule's prediction, $\omega\cos(\omega t_0)$.
:::
:::

```sim plot
view: graph
x: t = 0..6.3
y: y = -2.5..2.5
slider: w = 0.5..3 step 0.25 = 1
slider: t0 = 0..6.3 step 0.05 = 0.5
plot: sin(w*t) | label: sin(ωt) | samples: 1000
plot: sin(w*t0) + w*cos(w*t0)*(t - t0) | dashed | color: ch2 | label: tangent
point: t0, sin(w*t0)
readout: slope measured = (sin(w*(t0 + 1e-6)) - sin(w*(t0 - 1e-6)))/2e-6 | digits: 5
readout: ω cos(ωt₀) = w*cos(w*t0) | digits: 5
```

::: predict
## A voltage is $v = 5\sin(2t)$. What is its largest rate of change, in volts per unit time?

- [ ] 5
- [x] 10
- [ ] 2
- [ ] 20

::: reveal
10. The chain rule gives $\frac{dv}{dt} = 5\cos(2t) \cdot 2 = 10\cos(2t)$, whose largest value is 10. The inner function $2t$ runs twice as fast, so the whole waveform's slopes are twice as steep. That's why higher-frequency signals need faster amplifiers: the slew rate grows with $\omega$.
:::
:::

::: nameit
## The rule, two ways

If $y = f(u)$ and $u = g(x)$, then

$$\frac{dy}{dx} = \frac{dy}{du}\cdot\frac{du}{dx} \qquad\text{or}\qquad \big(f(g(x))\big)' = f'(g(x))\,g'(x)$$

The first form (Leibniz's) reads like canceling $du$, which isn't literally true but always gives the right answer and keeps the units straight: (V/Ω) × (Ω/°C) × (°C/s) = V/s.

**Longer chains** multiply more rates: $\frac{d}{dx}f(g(h(x))) = f'(g(h(x)))\,g'(h(x))\,h'(x)$. Work from the outside in, differentiating each layer and leaving its inside alone.

## Patterns worth recognizing

| Function | Derivative |
|---|---|
| $\big(g(x)\big)^n$ | $n\,g^{n-1}\,g'$ |
| $e^{g(x)}$ | $e^{g}\,g'$ |
| $\sin(g(x))$, $\cos(g(x))$ | $\cos g \cdot g'$, $-\sin g \cdot g'$ |
| $A\sin(\omega t + \varphi)$ | $A\omega\cos(\omega t + \varphi)$ |
| $V_0e^{-t/\tau}$ | $-\frac{V_0}{\tau}e^{-t/\tau}$ |
| $\sqrt{g(x)}$ | $\frac{g'}{2\sqrt{g}}$ |

The last two lines are the reason every rate in this course carries a $\omega$ or a $1/\tau$: the inside of the function sets the time scale.

## Chains of physical quantities

When a quantity depends on another that depends on time, its rate of change is a chain:

$$\frac{dP}{dt} = \frac{dP}{dR}\cdot\frac{dR}{dT}\cdot\frac{dT}{dt}$$

Each factor is a sensitivity you can look up or measure separately, which is how engineers budget drift: the temperature coefficient times the heating rate times the circuit's sensitivity.
:::

::: example
## Differentiate $y = e^{-3t}\sin(5t)$.

::: solution
1. **Product rule.** Each factor needs the chain rule:
   $$y' = \big(e^{-3t}\big)'\sin 5t + e^{-3t}\big(\sin 5t\big)'$$
2. **Differentiate each factor.**
   $$\begin{aligned} y' = &-3e^{-3t}\sin 5t \\ &+ 5e^{-3t}\cos 5t \end{aligned}$$
3. **Factor out the exponential.**
   $$y' = e^{-3t}(5\cos 5t - 3\sin 5t)$$
4. **Where it shows up.** This is the shape of every damped oscillation (A3's $e^{st}$), so its derivative is the current through a capacitor in a ringing circuit.

**Answer:** $y' = e^{-3t}(5\cos 5t - 3\sin 5t)$.
:::
:::

::: example
## A 1 kΩ thermistor-like part changes resistance at −40 Ω/°C, and it's warming at 0.5 °C/s. It carries a constant 2 mA. How fast is its voltage changing?

::: solution
1. **Voltage per ohm.** $v = IR$, so
   $$\begin{aligned} \frac{dv}{dR} &= I \\ &= 0.002\ \text{V}/\Omega \end{aligned}$$
2. **Chain the rates.**
   $$\begin{aligned} \frac{dv}{dt} &= \frac{dv}{dR}\cdot\frac{dR}{dT}\cdot\frac{dT}{dt} \\ &= 0.002 \times (-40) \times 0.5 \\ &= -0.04\ \text{V/s} \end{aligned}$$
3. **Check the units.** They multiply through: V/Ω × Ω/°C × °C/s = V/s.

**Answer:** the voltage falls at 0.04 V/s, 40 mV every second.
:::
:::

::: example
## A sensor's output is $V = 0.01T^2$ volts, and its temperature follows $T(t) = 20 + 5\sin(0.1t)$ °C, with $t$ in seconds. How fast is $V$ changing at $t = 0$?

::: solution
1. **Chain rule.**
   $$\frac{dV}{dt} = \frac{dV}{dT}\cdot\frac{dT}{dt}$$
2. **Volts per degree.** At $t = 0$, $T = 20$, so
   $$\begin{aligned} \frac{dV}{dT} &= 0.02T \\ &= 0.4\ \text{V/°C} \end{aligned}$$
3. **Degrees per second.**
   $$\begin{aligned} \frac{dT}{dt} &= 0.5\cos 0 \\ &= 0.5\ \text{°C/s} \end{aligned}$$
4. **Multiply.** Each link in the chain multiplies: volts per degree times degrees per second.
   $$\begin{aligned} \frac{dV}{dt} &= 0.4 \times 0.5 \\ &= 0.2\ \text{V/s} \end{aligned}$$

**Answer:** at $t = 0$, $V$ is rising at 0.2 V/s.
:::
:::

::: check
given: A = 2 | 5 | 10; w = 100 | 377 | 1000
answer: A*w

## What is the largest rate of change of $\given{A}\sin(\given{w}t)$, in units per second?

::: right
Right. The derivative is $\given{A} \cdot \given{w}\cos(\given{w}t)$, with peak $A\omega$ = {answer}.
:::

::: misses
- [A] Multiply by the inside's rate, {w}.
- [w] Include the amplitude.
- [A*w/(2*pi)] $\omega$ is already in radians per second; don't divide by $2\pi$.
- [any] Not yet. Chain rule: derivative of the outside times the derivative of $\given{w}t$.
:::
:::

::: check
kind: expression
given: k = 2 | 3 | 5
answer: 2*k*x*exp(k*x^2)
vars: x = -1..1

## Differentiate $e^{\given{k}x^2}$.

::: right
Right. $e^{\given{k}x^2}$ times the derivative of the exponent, $2 \cdot \given{k}x$.
:::

::: misses
- [exp(k*x^2)] Multiply by the derivative of the exponent.
- [k*x^2*exp(k*x^2 - 1)] The power rule doesn't apply to $e^u$: $\frac{d}{du}e^u = e^u$.
- [any] Not yet. $\frac{d}{dx}e^{g} = e^{g}g'$.
:::
:::

::: check
kind: expression
given: a = 2 | 3; n = 3 | 4
answer: n*(sin(a*x))^(n - 1)*cos(a*x)*a
vars: x = 0.1..1.2

## Differentiate $\sin^{\given{n}}(\given{a}x)$, meaning $\big(\sin(\given{a}x)\big)^{\given{n}}$.

::: right
Right. Three layers: the power, the sine, then the $\given{a}x$.
:::

::: misses
- [n*(sin(a*x))^(n - 1)*cos(a*x)] One layer short: multiply by the derivative of $\given{a}x$ too.
- [n*(sin(a*x))^(n - 1)] Differentiate the sine as well.
- [any] Not yet. Outside in: power, then sine, then the inside.
:::
:::

::: check
given: I = 1 | 2 | 5; dR = -40 | -20 | 10; dT = 0.2 | 0.5
answer: I*1e-3*dR*dT
unit: V/s

## A part carries a constant {I} mA. Its resistance changes at {dR} Ω/°C and it warms at {dT} °C/s. How fast is its voltage changing, in V/s?

::: right
Right. $I \cdot \frac{dR}{dT} \cdot \frac{dT}{dt}$ = {answer}.
:::

::: misses
- [I*dR*dT] Put the current in amperes.
- [I*1e-3*dR] Multiply by the heating rate as well.
- [any] Not yet. Chain: $\frac{dv}{dR}\frac{dR}{dT}\frac{dT}{dt}$, with $\frac{dv}{dR} = I$.
:::
:::

::: check
given: V0 = 5 | 12; tau = 2 | 10; t = 1 | 5
answer: -V0/tau*exp(-t/tau)
unit: V/ms

## $v = \given{V0}e^{-t/\given{tau}}$ volts, with $t$ in ms. What is $dv/dt$ at $t$ = {t} ms, in V/ms?

::: right
Right. $-\frac{V_0}{\tau}e^{-t/\tau}$ = {answer}.
:::

::: misses
- [V0/tau*exp(-t/tau)] The derivative of $-t/\tau$ is negative: the voltage is falling.
- [-V0*exp(-t/tau)] Multiply by $1/\tau$ from the inside.
- [any] Not yet. Chain rule with the inside $-t/\tau$.
:::
:::

::: check
kind: parts
given: a = 2 | 3; k = 0.5 | 2; x0 = 0.5 | 1

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

::: part
answer: -2*k*x0*exp(-k*x0^2)
tolerance: 0.5%

### $e^{-\given{k}x^2}$

::: misses
- [exp(-k*x0^2)] The chain rule multiplies by the inside's derivative, $-2kx$.
- [any] $\frac{d}{dx}e^{u} = e^{u}u'$.
:::
:::

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

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

::: misses
- [5*(a*x0 + 1)^4] Multiply by the inside's derivative, {a}.
- [any] Power rule, then chain rule.
:::
:::

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

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

::: misses
- [1/(1 + a*x0^2)] Multiply by the inside's derivative, $2ax$.
- [any] $\frac{d}{dx}\ln u = u'/u$.
:::
:::
:::

::: check
kind: derivation
vars: V = 1..10, tau = 0.5..5, w = 1..10, t = 0..3

## Differentiate a decaying oscillation, $v = Ve^{-t/\tau}\sin(\omega t)$.

::: step
answer: -V/tau*exp(-t/tau)

### What is the derivative of the envelope $Ve^{-t/\tau}$?
:::

::: step
answer: V*exp(-t/tau)*(w*cos(w*t) - sin(w*t)/tau)

### Use the product rule for $v'$, and factor out $Ve^{-t/\tau}$.
:::

::: right
Right. $v' = Ve^{-t/\tau}\left(\omega\cos\omega t - \frac{\sin\omega t}{\tau}\right)$: the decay pulls each peak a little earlier.
:::
:::

::: explain
## Why does the derivative of $\sin(\omega t)$ get bigger when $\omega$ gets bigger, even though the sine's height stays the same?

::: model
The chain rule multiplies the outer derivative, $\cos(\omega t)$, by the rate of the inside, $\omega$. A larger $\omega$ means the angle sweeps faster, so the wave goes through each rise and fall in less time. The same change in height over a shorter time is a steeper slope, so every rate of change is scaled up by $\omega$ even though the amplitude hasn't changed.
:::
:::

::: practice

::: check
kind: expression
given: a = 2 | 4; b = 1 | 3
answer: a*cos(a*x + b)
vars: x = -2..2

## Differentiate $\sin(\given{a}x + \given{b})$.

::: misses
- [cos(a*x + b)] Multiply by {a}.
- [any] $\cos(\text{inside})$ times the inside's derivative.
:::
:::

::: check
kind: expression
given: n = 3 | 5; c = 1 | 2
answer: n*(x^2 + c)^(n - 1)*2*x
vars: x = -1.5..1.5

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

::: misses
- [n*(x^2 + c)^(n - 1)] Multiply by $2x$.
- [any] General power rule.
:::
:::

::: check
given: A = 3 | 8; w = 50 | 200; t = 0.002 | 0.01
answer: A*w*cos(w*t)
tolerance: 0.5%

## $v = \given{A}\sin(\given{w}t)$. What is $dv/dt$ at $t$ = {t} s?

::: misses
- [A*cos(w*t)] Multiply by {w}.
- [any] $A\omega\cos(\omega t)$.
:::
:::
:::
