Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

3. Propagation of uncertainty

School of Engineering, Nazarbayev University

Track: core  ·  Prerequisites: Chapter 1, partial derivatives

Reading: Taylor, ch. 3 · Bevington & Robinson, ch. 3 · Fornasini, ch. 8.1–8.3 · Rouaud, ch. II.B · GUM, clause 5.1

Most quantities of interest are not measured directly. A density is computed from a mass and some lengths, a rate constant from concentrations and times, a viscosity from a falling time. If the inputs are uncertain, so is the output. Propagation of uncertainty is the rule that carries the input uncertainties through the formula.

In this notebook we

  1. derive the propagation formula for one and for several input quantities;

  2. obtain the familiar rules for sums, products and powers as special cases;

  3. work a complete example by hand, with the helper functions, and by simulation;

  4. organise the result as an uncertainty budget that shows which input matters;

  5. look at the classic trap of subtracting two nearly equal numbers.

3.1 One input quantity

Let y=f(x)y = f(x) and suppose the measured value xx differs from the true value by a small error δx\delta x. Expanding ff about the measured value,

f(x+δx)=f(x)+f′(x) δx+12f′′(x) δx2+…f(x + \delta x) = f(x) + f'(x)\,\delta x + \tfrac12 f''(x)\,\delta x^2 + \dots

If δx\delta x is small enough for the curve to be replaced by its tangent over the range of interest, the error in yy is

δy≈f′(x) δx.\delta y \approx f'(x)\,\delta x .

The error is simply multiplied by the slope. Taking the standard deviation of both sides gives the rule for one variable,

uy=∣f′(x)∣ ux.u_y = |f'(x)|\,u_x .

The derivative f′(x)f'(x) is called the sensitivity coefficient: it tells how strongly the output responds to the input. Panel (a) of the figure in Section 3.4 shows this geometrically.

Two examples. For the area of a circle, A=πr2A = \pi r^2, we have uA=2πr uru_A = 2\pi r\,u_r, or in relative terms uA/A=2 ur/ru_A/A = 2\,u_r/r: a 1 % uncertainty in the radius becomes 2 % in the area. For y=ln⁡xy = \ln x we have uy=ux/xu_y = u_x/x: the uncertainty of a logarithm is the relative uncertainty of its argument.

3.2 Several input quantities

Now let y=f(x1,x2,…,xn)y = f(x_1, x_2, \dots, x_n). The first-order expansion is

δy≈∑i=1n∂f∂xi δxi≡∑ici δxi,\delta y \approx \sum_{i=1}^{n} \frac{\partial f}{\partial x_i}\,\delta x_i \equiv \sum_i c_i\,\delta x_i ,

with sensitivity coefficients ci=∂f/∂xic_i = \partial f/\partial x_i evaluated at the measured values. We want the variance of δy\delta y, so we square and average over many imagined repetitions of the whole experiment:

⟨δy2⟩=∑ici2⟨δxi2⟩+∑i≠jcicj⟨δxi δxj⟩.\langle \delta y^2 \rangle = \sum_i c_i^2 \langle \delta x_i^2\rangle + \sum_{i \ne j} c_i c_j \langle \delta x_i\,\delta x_j\rangle .

The averages ⟨δxi2⟩=ui2\langle\delta x_i^2\rangle = u_i^2 are the input variances. The cross terms ⟨δxi δxj⟩\langle\delta x_i\,\delta x_j\rangle are the covariances. If the inputs are measured independently, a positive error in one is as likely to be accompanied by a negative as by a positive error in another, and the covariances vanish. We are left with the

Law of propagation of uncertainty (independent inputs)

uy2=∑i=1n(∂f∂xi)2ui2.u_y^2 = \sum_{i=1}^{n} \left(\frac{\partial f}{\partial x_i}\right)^{2} u_i^2 .

Each input contributes ∣ci∣ ui|c_i|\,u_i, and the contributions add in quadrature, just as in Section 1.4. Two assumptions went in, and both will be revisited in Chapter 12 (Chapter 12): the errors are small enough for the tangent approximation, and the inputs are independent.

3.3 The rules for sums, products and powers

Three special cases cover most everyday calculations.

Sums and differences. For y=a+by = a + b or y=a−by = a - b the sensitivity coefficients are ±1\pm 1, so

uy2=ua2+ub2.u_y^2 = u_a^2 + u_b^2 .

Absolute uncertainties add in quadrature, for a difference as well as for a sum. An uncertainty never subtracts.

Products and quotients. For y=aby = ab we have ∂y/∂a=b=y/a\partial y/\partial a = b = y/a and ∂y/∂b=y/b\partial y/\partial b = y/b, so uy2=(y/a)2ua2+(y/b)2ub2u_y^2 = (y/a)^2u_a^2 + (y/b)^2u_b^2. Dividing by y2y^2,

(uyy)2=(uaa)2+(ubb)2,\left(\frac{u_y}{y}\right)^{2} = \left(\frac{u_a}{a}\right)^{2} + \left(\frac{u_b}{b}\right)^{2} ,

and the same result holds for y=a/by = a/b. Relative uncertainties add in quadrature.

Powers. For y=any = a^n, ∂y/∂a=nan−1=ny/a\partial y/\partial a = n a^{n-1} = n y/a, so

uy∣y∣=∣n∣ ua∣a∣.\frac{u_y}{|y|} = |n|\,\frac{u_a}{|a|} .

Combining the last two: for a general product of powers y=C ap bq cr⋯y = C\,a^{p}\,b^{q}\,c^{r}\cdots with an exact constant CC,

(uyy)2=p2(uaa)2+q2(ubb)2+r2(ucc)2+…\left(\frac{u_y}{y}\right)^{2} = p^2\left(\frac{u_a}{a}\right)^{2} + q^2\left(\frac{u_b}{b}\right)^{2} + r^2\left(\frac{u_c}{c}\right)^{2} + \dots

This one formula handles a large share of the laboratory formulas in physics, chemistry and engineering. Quantities raised to high powers deserve the most careful measurement.

3.4 Worked example: the density of a metal cylinder

A cylinder is weighed on a balance and measured with a calliper:

QuantityValueStandard uncertainty
mass mm23.45 g0.01 g
diameter dd9.98 mm0.02 mm
height hh35.10 mm0.05 mm

The density is

ρ=mV=4mπd2h.\rho = \frac{m}{V} = \frac{4m}{\pi d^2 h} .

By hand. This is a product of powers with exponents +1, -2 and -1, so

(uρρ)2=(umm)2+4(udd)2+(uhh)2.\left(\frac{u_\rho}{\rho}\right)^{2} = \left(\frac{u_m}{m}\right)^{2} + 4\left(\frac{u_d}{d}\right)^{2} + \left(\frac{u_h}{h}\right)^{2} .
relative uncertainties: m 0.043%,  d 0.200%,  h 0.142%
rho = 8540.5 kg/m^3,  relative uncertainty 0.43%
rho = 8541 ± 37 kg/m^3

With the helper function. ep.propagate evaluates the same formula for any function, obtaining the partial derivatives numerically (by changing each input slightly and observing the change in the output). Nothing has to be differentiated by hand, which matters when the formula is long.

rho = 8541 ± 37 kg/m^3

Uncertainty budget. The total alone hides the most useful information: which input is responsible. A budget lists, for each input, the contribution ∣ci∣ui|c_i|u_i and its share of the output variance.

input             value           u    rel. u        |c| u    share
-------------------------------------------------------------------
m (kg)          0.02345       1e-05     0.04%         3.64     1.0%
d (m)           0.00998       2e-05     0.20%         34.2    87.9%
h (m)            0.0351       5e-05     0.14%         12.2    11.1%
-------------------------------------------------------------------
output           8540.5          37     0.43%

The diameter is responsible for almost 90 % of the variance, although its relative uncertainty (0.20 %) is not much larger than that of the height (0.14 %). The reason is the exponent: the diameter enters squared, so its relative uncertainty counts double, and in the variance four times. A better balance would improve nothing. A micrometer for the diameter would.

By simulation. The propagation formula is an approximation. A direct check is to simulate the experiment many times: draw each input from a distribution with the stated uncertainty, compute the density for each draw, and look at the spread of the results. This is the Monte Carlo method.

Monte Carlo : mean 8540.4, standard deviation 36.5 kg/m^3
Formula     : rho  8540.5, uncertainty        36.5 kg/m^3
<Figure size 1012x429 with 2 Axes>

Formula and simulation agree to within the statistical noise of the simulation. This is the normal situation when relative uncertainties are a fraction of a per cent: over such a small range every smooth function is practically a straight line. The agreement fails when uncertainties are large or the function is strongly curved, and Monte Carlo then becomes the method of choice (Chapter 12).

3.5 A trap: the difference of two nearly equal numbers

For a difference y=a−by = a - b the absolute uncertainty is ua2+ub2\sqrt{u_a^2 + u_b^2} whatever the values of aa and bb. The relative uncertainty, however, is

uy∣y∣=ua2+ub2∣a−b∣,\frac{u_y}{|y|} = \frac{\sqrt{u_a^2 + u_b^2}}{|a - b|} ,

and it grows without limit as aa and bb approach each other.

Example: the mass of a liquid sample is found by weighing a beaker full (152.36 g) and empty (150.21 g), each to ±0.01 g. Each weighing is good to 0.007 %. The sample mass is 2.15 g ± 0.014 g, which is 0.66 %: a hundred times worse in relative terms. The same thing happens when a small temperature rise is obtained from two thermometer readings, a reaction enthalpy from two large enthalpies of formation, or an adsorption energy from three large total energies.

<Figure size 1012x429 with 2 Axes>

The remedy is to design the measurement so that the small quantity is measured directly (weigh the sample on a tared balance, use a differential thermometer) or so that the errors of aa and bb are common to both and cancel, a case treated in Chapter 12.

Summary

  • To first order, each input contributes ∣∂f/∂xi∣ ui|\partial f/\partial x_i|\,u_i to the output, and independent contributions add in quadrature.

  • Sums and differences: absolute uncertainties in quadrature. Products and quotients: relative uncertainties in quadrature. Powers: multiply the relative uncertainty by ∣n∣|n|.

  • An uncertainty budget shows where the uncertainty comes from and where improvement would pay.

  • A Monte Carlo simulation is an independent check that needs no calculus.

  • Differences of nearly equal numbers lose relative precision.

Exercises

  1. The period of a pendulum is T=2πL/gT = 2\pi\sqrt{L/g}. With L=0.750±0.002L = 0.750 \pm 0.002 m and T=1.738±0.004T = 1.738 \pm 0.004 s, compute g=4π2L/T2g = 4\pi^2L/T^2 and its uncertainty by hand and with ep.propagate. Which measurement should be improved first?

  2. The resistance of a wire is R=V/IR = V/I and the power dissipated is P=VIP = VI. For V=5.02±0.02V = 5.02 \pm 0.02 V and I=0.251±0.002I = 0.251 \pm 0.002 A, find both with uncertainties. Why is it wrong to compute P=I2RP = I^2R from your RR and propagate as if II and RR were independent? (Try it, and compare.)

  3. The pH of a solution is −log⁡10[H+]-\log_{10}[\mathrm{H^+}]. Show that an uncertainty of 0.02 in pH corresponds to a relative uncertainty of 4.6 % in the concentration.

  4. Repeat the Monte Carlo check of Section 3.4 with every input uncertainty multiplied by 50. Does the formula still agree with the simulation? Is the histogram still symmetric?