---
title: Tangent planes and error propagation
heading: How tolerances add up
eyebrow: A9 · Lesson 6 · Tangent planes
xp: 40
---

::: hook
Every resistor on a board is off by up to 1%, every capacitor by up to 10%, and every meter reading has its own uncertainty. How far off can the output of a divider be, or a filter's corner frequency, or a power you calculated from a voltage and a current? The answer comes from the same idea as A6's linearization, in more dimensions: near any point, a smooth function of several variables is a flat **tangent plane**, and small errors in the inputs pass through it as a weighted sum.
:::

::: play
- A divider gives $V_\text{out} = 10\frac{R_2}{R_1 + R_2}$ volts. The curve is $V_\text{out}$ against $R_2$, with $R_1$ fixed; the straight line is its tangent at the nominal $R_2$ = 10 kΩ.
- Close to the nominal value, line and curve agree. How far out does the line stay good?
- The readout is the slope, the sensitivity $\partial V/\partial R_2$.
:::
:::

```sim plot
view: graph
x: R2 = 2..30 kΩ
y: V = 0..10 V
slider: R1 = 2..30 step 0.5 = 10 kΩ
plot: 10*R2/(R1 + R2) | label: Vout
plot: 10*10/(R1 + 10) + 10*R1/(R1 + 10)^2*(R2 - 10) | label: tangent at 10 kΩ | color: ch2
readout: sensitivity, V per kΩ = 10*R1/(R1 + 10)^2 | digits: 4
```

::: predict
## You compute power from $V$ = 12 V known to 1% and $I$ = 2 A known to 1%. What's the worst-case uncertainty in $P = VI$?

- [ ] 1%
- [x] 2%
- [ ] 1.4%
- [ ] 0.5%

::: reveal
2%. For a product, relative errors add: $\frac{dP}{P} = \frac{dV}{V} + \frac{dI}{I}$, and in the worst case both are off in the same direction. If the two errors are independent and random, they usually partly cancel, and the typical error is $\sqrt{1^2 + 1^2} = 1.4\%$.
:::
:::

::: nameit
## The tangent plane

Near $(a, b)$, a smooth $f(x, y)$ is close to its **tangent plane**:

$$f(x, y) \approx f(a, b) + f_x(a, b)(x - a) + f_y(a, b)(y - b)$$

In differential form, $df = f_x\,dx + f_y\,dy$.

## Propagating errors

If each input is uncertain by $\Delta x$, $\Delta y$:

- **Worst case:** $|\Delta f| \le |f_x|\Delta x + |f_y|\Delta y$.
- **Independent random errors (root-sum-square):** $\Delta f \approx \sqrt{(f_x\Delta x)^2 + (f_y\Delta y)^2}$, which is what you usually see in production.

## Products and powers

For $f = x^my^n$, in relative terms

$$\frac{df}{f} = m\frac{dx}{x} + n\frac{dy}{y}$$

so percentage errors scale by the powers and add. $P = V^2/R$: twice the voltage's percentage plus the resistance's. $\tau = RC$: the two tolerances add. $f_c = \frac{1}{2\pi RC}$: the same, since negative powers flip the sign but not the size.

## Dividers

For $V_\text{out} = V_\text{in}\frac{R_2}{R_1 + R_2}$, the relative sensitivity to each resistor is $\frac{R_1}{R_1 + R_2}$ in size. With equal resistors that's $\frac{1}{2}$ each, so two 1% resistors give at worst a 1% error in the output.
:::

::: example
## $V = 12.0 \pm 0.1$ V and $I = 2.00 \pm 0.02$ A. How uncertain is $P = VI$?

::: solution
1. **Nominal power.**
   $$\begin{aligned} P &= VI \\ &= 24\ \text{W} \end{aligned}$$
2. **Relative errors.** The voltage's is 0.83% and the current's is 1%.
3. **Worst case.** The relative errors add:
   $$0.83\% + 1\% = 1.83\%$$
   so $\pm 0.44$ W.
4. **Root-sum-square.**
   $$\sqrt{0.83^2 + 1^2} = 1.30\%$$
   so $\pm 0.31$ W.

**Answer:** $P = 24$ W, uncertain by $\pm 0.44$ W in the worst case or $\pm 0.31$ W root-sum-square.
:::
:::

::: example
## A 10 V divider uses two 10 kΩ, 1% resistors. How far off can the 5 V output be?

::: solution
1. **Sensitivity to $R_2$.**
   $$\begin{aligned} \frac{\partial V}{\partial R_2} &= \frac{V_\text{in}R_1}{(R_1 + R_2)^2} \\ &= \frac{10 \times 10^4}{4 \times 10^8} \\ &= 2.5 \times 10^{-4}\ \text{V}/\Omega \end{aligned}$$
2. **Sensitivity to $R_1$.** $\frac{\partial V}{\partial R_1}$ is the same size with opposite sign.
3. **Worst case.** Each resistor may be off by 100 Ω, so the error is at most
   $$\begin{aligned} \Delta V &= 2 \times 2.5 \times 10^{-4} \times 100 \\ &= 0.05\ \text{V} \end{aligned}$$
   1% of the output.

**Answer:** the 5 V output can be off by up to 0.05 V, which is 1%.
:::
:::

::: example
## Use the tangent plane of $f = \sqrt{x^2 + y^2}$ at $(3, 4)$ to estimate $f(3.1, 3.9)$.

::: solution
1. **Value and slopes at $(3, 4)$.**
   $$\begin{aligned} f(3, 4) &= 5 \\ f_x &= x/f \\ &= 0.6 \\ f_y &= y/f \\ &= 0.8 \end{aligned}$$
2. **Linear approximation.**
   $$\begin{aligned} f &\approx 5 + 0.6(0.1) + 0.8(-0.1) \\ &= 4.98 \end{aligned}$$
3. **Compare with the exact value.**
   $$\begin{aligned} f(3.1, 3.9) &= \sqrt{24.82} \\ &= 4.98197 \end{aligned}$$
   so the estimate is off by 0.002, a second-order error from the curvature the plane leaves out.

**Answer:** the tangent plane estimates $f(3.1, 3.9) \approx 4.98$, against an exact 4.98197.
:::
:::

::: check
given: a = 2 | 3; b = 1 | 4; dx = 0.1 | -0.05; dy = 0.3 | 0.1; let x1 = a + dx; let y1 = b + dy
answer: a^2*b + 2*a*b*dx + a^2*dy
tolerance: 0.05%

## Use the tangent plane of $f = x^2y$ at $(\given{a}, \given{b})$ to estimate $f(\given{x1}, \given{y1})$.

::: right
Right. $f + f_x\,dx + f_y\,dy = a^2b + 2ab\,dx + a^2\,dy$ = {answer}.
:::

::: misses
- [a^2*b] Add the changes from both inputs.
- [any] Not yet. $f_x = 2xy$ and $f_y = x^2$ at the point.
:::
:::

::: check
given: pv = 0.5 | 1 | 2; pi = 1 | 0.25
answer: pv + pi

## $V$ is known to {pv}% and $I$ to {pi}%. What is the worst-case percentage error in $P = VI$?

::: right
Right. Relative errors of a product add: {answer}%.
:::

::: misses
- [sqrt(pv^2 + pi^2)] That's the typical (root-sum-square) error. The worst case adds them.
- [pv*pi] Errors add, not multiply.
- [any] Not yet. Add the percentages.
:::
:::

::: check
given: pr = 1 | 5; pc = 10 | 20
answer: sqrt(pr^2 + pc^2)
tolerance: 0.5%

## $R$ has a {pr}% tolerance and $C$ a {pc}% tolerance, independently. What is the typical (root-sum-square) percentage error in $\tau = RC$?

::: right
Right. $\sqrt{(\given{pr})^2 + (\given{pc})^2}$ = {answer}%: dominated by the worse part.
:::

::: misses
- [pr + pc] That's the worst case. Independent errors combine as a root-sum-square.
- [any] Not yet. Root of the sum of the squares.
:::
:::

::: check
given: pv = 1 | 2; pr = 1 | 5
answer: 2*pv + pr

## $V$ is uncertain by {pv}% and $R$ by {pr}%. What is the worst-case percentage error in $P = V^2/R$?

::: right
Right. The square doubles the voltage's share: $2 \times$ {pv} + {pr} = {answer}%.
:::

::: misses
- [pv + pr] $V$ appears squared, so its percentage counts twice.
- [2*pv - pr] Worst case: the error from $R$ can add either way, so take its size.
- [any] Not yet. $\frac{dP}{P} = 2\frac{dV}{V} - \frac{dR}{R}$, sizes added.
:::
:::

::: check
given: R1 = 10 | 4.7; R2 = 10 | 22; t = 1 | 5
answer: 2*R1/(R1 + R2)*t
tolerance: 0.5%

## A divider has $R_1$ = {R1} kΩ and $R_2$ = {R2} kΩ, both {t}%. What is the worst-case percentage error of its output ratio?

::: right
Right. Each resistor's relative sensitivity is $\frac{R_1}{R_1 + R_2}$, so the worst case is $2\frac{R_1}{R_1 + R_2}t$ = {answer}%.
:::

::: misses
- [2*t] Each resistor's effect is scaled by $\frac{R_1}{R_1 + R_2}$, less than 1.
- [any] Not yet. Find the relative sensitivity to each resistor.
:::
:::

::: check
given: pr = 1 | 2; pc = 5 | 10
answer: pr + pc

## What is the worst-case percentage error in $f_c = \frac{1}{2\pi RC}$ for a {pr}% resistor and a {pc}% capacitor?

::: right
Right. Powers of $-1$ don't change the size: {answer}%.
:::

::: misses
- [pc - pr] Worst case, the two errors push the same way.
- [any] Not yet. Add the sizes of the relative errors.
:::
:::

::: check
kind: parts
given: V = 5 | 12; dV = 0.05 | 0.1; R = 100 | 220; dR = 1 | 2

## $P = V^2/R$ with $V$ = {V} ± {dV} V and $R$ = {R} ± {dR} Ω.

::: part
answer: 2*V*dV/R + V^2*dR/R^2
unit: W
tolerance: 0.5%

### What is the worst-case error in $P$, from the linear approximation?

::: misses
- [sqrt((2*V*dV/R)^2 + (V^2*dR/R^2)^2)] That's the root-sum-square estimate; the worst case adds the sizes.
- [any] $|P_V|\Delta V + |P_R|\Delta R$.
:::
:::

::: part
answer: 2*dV/V + dR/R
tolerance: 0.5%

### What is that as a fraction of $P$?

::: misses
- [any] Relative errors add, weighted by the exponents: $2\frac{\Delta V}{V} + \frac{\Delta R}{R}$.
:::
:::
:::

::: check
kind: derivation
vars: x = 1..5, y = 1..5, h = -0.2..0.2

## Linearize $f = xy$ at $(x, y)$.

::: step
answer: y

### What is $f_x$?
:::

::: step
answer: x*y + y*h + x*h

### Estimate $f(x + h, y + h)$ with the tangent plane.
:::

::: right
Right. The neglected piece is $h^2$, the product of the two small changes.
:::
:::

::: explain
## Why do the relative errors of a product add, while those of a sum don't simply add?

::: model
For a product $f = xy$, $\frac{df}{f} = \frac{y\,dx + x\,dy}{xy} = \frac{dx}{x} + \frac{dy}{y}$: each input's percentage error passes straight through, so percentages add. For a sum $f = x + y$, it's the absolute errors that add, $df = dx + dy$, and the percentage of the result depends on how big $f$ is. A small difference of two large numbers can have a huge relative error, which is why subtracting nearly equal measurements is risky.
:::
:::

::: practice

::: check
given: p = 1 | 3; n = 2 | 3
answer: n*p

## A quantity goes as $x^{\given{n}}$ and $x$ is uncertain by {p}%. What is the percentage error in the quantity?

::: misses
- [p] The power multiplies the percentage.
- [any] $n \times p$%.
:::
:::

::: check
given: p1 = 1 | 3; p2 = 1 | 4
answer: sqrt(p1^2 + p2^2)
tolerance: 0.5%

## Two independent inputs are uncertain by {p1}% and {p2}%, and a result is their product. What is its typical (root-sum-square) error?

::: misses
- [p1 + p2] That's the worst case.
- [any] $\sqrt{p_1^2 + p_2^2}$.
:::
:::

::: check
given: Vin = 5 | 12; R1 = 10 | 20; R2 = 10 | 5
answer: Vin*R1/(R1 + R2)^2*1000
unit: mV/kΩ
tolerance: 0.5%

## For a divider with $V_\text{in}$ = {Vin} V, $R_1$ = {R1} kΩ and $R_2$ = {R2} kΩ, what is $\partial V_\text{out}/\partial R_2$ in mV per kΩ?

::: misses
- [any] $\frac{V_\text{in}R_1}{(R_1 + R_2)^2}$.
:::
:::
:::
