Propagation of Error with Single and Multiple Independent Variables

Summary

Often it is necessary to calculate the uncertainty of derived quantities. This procedure and convention is called propagation of error. Calculating the propagation of error formula requires knowing how to take derivatives/ We give the propagation of error formulas for a single variable and multiple independent variable functions. We list some common error propagation formulas that work in most cases. Step by step error propagation can often be used as a shortcut to calculate the uncertainty.
If we know the error propagation formula we can find the terms that are causing the most uncertainty and try to reduce these dominant errors. It is useful to write a short MATLAB script to calculate error propagation, especially when the formula is complex or a lot of significant digits are involved.

How error propagates

As a math problem, I ask you to add 5.2 and 10.11. The result is straightforward 15.31. The numbers have different numbers of digits and precision. 5.2 is precise to the tenths while 10.11 is precise to the hundredths. This is not a problem in mathematics, but the situation is more subtle in error analysis. To see what is going on you need to look at the uncertainties.

Now, if I ask you to add 5.2 \pm 1.2 and 10.11 \pm 0.76 then what do you do? The first thing you want to ask yourself is if these numbers are properly reported measurements. After a quick check, we see there are two digits of uncertainty that match the precision of the measurement. In error analysis, you still add the numbers to find the sum, but to find the combined error we need a propagation of error formula. In this situation, the rule is

    \[{\sigma}_{A + B} = \sqrt{ {\sigma}_A^2 + {\sigma}_B^2 } = 1.4204\ldots\]

This chapter is all about finding the rules like this. We can now calculate the uncertainty {\sigma}_{A+B} = 1.4204 \to 1.4 and round to two significant digits. Then we match the precision of the calculated quantity to the uncertainty. Our final result is that

    \[(5.2 \pm 1.2) + (10.11 \pm 0.76) = 15.31 \pm 1.4204 \to 15.3 \pm 1.4\]

Notice that if you always start with uncertainties that have two significant digits, you get out a result that has two significant digits of uncertainty. You don’t have to worry that the first number 5.2 has only two significant digits, but the final result 15.3 has three significant digits. This comes about naturally by the golden rule of two significant digits of uncertainty.

There are error propagation rules for single variable functions and multiple variable functions. The single variable situation is not too complicated. You just need to understand differential calculus. For the situation with multiple variables functions, you have to worry if the variables are correlated or independent. In most cases, we don’t have to worry about correlations and the formulas are straightforward.

Rules of differential calculus refresher

We now do a little review of differentiation because we need derivatives for error propagation. Ordinary derivatives are needed for a single variable function, and partial derivatives are needed for multiple variable functions. The derivative is defined in calculus as

    \begin{align*} f'(x) = \cfrac{df}{dx} = \lim_{\Delta x \to 0} \cfrac{ f( x + \Delta x) - f(x)}{\Delta x} \end{align*}

The following list contains the basic formulas to master differential calculus.

    \[c' = 0 \qquad x' = 1 \qquad (x^n)' = nx^{n-1} \qquad |x|' = \cfrac{|x|}{x}\]

    \[(cu)' = cu' \qquad (c_1u +c_2 v)' = c_1u' + c_2v'\]

    \[(uv)' = u'v + uv' \qquad (1/u)' = -u'/u^2 \qquad (u/v)' = \cfrac{ u'v - uv'}{v^2}\]

    \[f(u(x))' = \cfrac{df}{du}\cfrac{du}{dx} = f'(u)u'(x)\]

    \[(e^x)' = e^x \qquad (a^x)' = a^x \ln a \qquad (\ln x)' = \cfrac{1}{x} \qquad (\log_a x)' = \cfrac{1}{x \ln a}\]

    \[\cfrac{d}{dx} \sin x = +\cos x \quad \cfrac{d}{dx} \tan x = +\sec^2 x \quad \cfrac{d}{dx} \sec x = +\sec x \tan x\]

    \[\cfrac{d}{dx} \cos x = -\sin x \quad \cfrac{d}{dx} \cot x = -\csc^2 x \quad \cfrac{d}{dx} \csc x = -\csc x \cot x\]

    \[\cfrac{d}{dx} \sinh x = +\cosh x \quad \cfrac{d}{dx} \tanh x = +\sech\!^2 x \quad \cfrac{d}{dx} \sech x = - \sech x \,\tanh x\]

    \[\cfrac{d}{dx} \cosh x =+\sinh x \quad \cfrac{d}{dx} \coth x = -\csch\!^2 x \quad \cfrac{d}{dx} \csch x = - \csch x \,\coth x\]

    \[\cfrac{d}{dx} \arcsin x = +\cfrac{1}{\sqrt{ 1 - x^2}} \quad \cfrac{d}{dx} \arctan x = +\cfrac{1}{1 + x^2} \quad \cfrac{d}{dx} \arcsec x = +\cfrac{1}{|x| \sqrt{ x^2-1}}\]

    \[\cfrac{d}{dx} \arccos x = -\cfrac{1}{\sqrt{ 1 - x^2}} \quad \cfrac{d}{dx} \arccot x = -\cfrac{1}{1 + x^2} \quad \cfrac{d}{dx} \arccsc x = -\cfrac{1}{|x| \sqrt{ x^2-1}}\]

    \[\cfrac{d}{dx} \arcsinh x = +\cfrac{1}{\sqrt{ x^2+1}} \quad \cfrac{d}{dx} \arctanh x = +\cfrac{1}{1-x^2} \quad \cfrac{d}{dx} \arcsech x = -\cfrac{1}{x \sqrt{ 1-x^2}}\]

    \[\cfrac{d}{dx} \arccosh x = +\cfrac{1}{\sqrt{ x^2-1}} \quad \cfrac{d}{dx} \arccoth x = +\cfrac{1}{1-x^2} \quad \cfrac{d}{dx} \arccsch x = -\cfrac{1}{|x| \sqrt{1+x^2}}\]

The partial derivative is like the normal derivative except you hold the other variables constant when you take it. Here is the definition

    \[\cfrac{ \partial f(x,y)}{ \partial x} = \lim_{\Delta x \to 0} \cfrac{f(x + \Delta x, y) - f(x,y)}{\Delta x}\]

    \[\cfrac{ \partial f(x,y)}{ \partial y} = \lim_{\Delta y \to 0} \cfrac{f(x, y+ \Delta y) - f(x,y)}{\Delta y}\]

For example, if we wanted to find all the partial derivatives of f(x,y,z) = xy^2z^3 we would use the power rule (x^n)' = nx^{n-1}.
There are three possible partial derivatives

    \[\cfrac{ \partial f}{ \partial x} = y^2 z^3 \quad \cfrac{ \partial f}{ \partial y} = 2xyz^3 \qquad \cfrac{ \partial f}{\partial z} = 3xy^2 z^2\]

Error propagation with one variable

If we have measured Q \pm \sigma_Q then the uncertainty in Q(A) is given by

    \[{\sigma}_Q = \left | Q'({A}) \right | {\sigma}_A\]

I assume you are familiar with differentiation. One can use a program like Mathematica or your graphing CAS calculator to find derivatives.

Example. The volume of a cube from error propagation.
Suppose a machinist has constructed a precise cube on a milling machine, and you want to find its volume. You repeatedly measure one of the sides to be

    \[s = 1.053 \pm 0.010 \, \mathrm{cm}\]

What is the volume and its uncertainty assuming the length, width, and height are identical?

We calculate the volume as V = s^3 and wait to round until we know the uncertainty.

    \[V = (1.053\, \mathrm{cm})^3 = 1.16757587\ldots \, \mathrm{cm}^3\]

To find the uncertainty we use the error propagation formula

    \begin{align*} {\sigma}_V &= |V'(s)| {\sigma}_s = 3s^2 {\sigma}_s \\ {\sigma}_V&= 3(1.053 \, \mathrm{cm})^2(0.010\, \mathrm{cm}) = 0.033502\, \mathrm{cm}^3 \end{align*}

After rounding we get V = 1.168(34)\, \mathrm{cm}^3.

Error propagation with multiple independent variables

Often we want to calculate some quantity that requires a series of individual measurements that must be combined. For example, if we wanted to calculate A/B we would first measure A then measure B and then we could calculate A/B. If we are doing error analysis, then to find the error in A/B we will need to apply a formula of error propagation. There is a significant simplification if the two quantities are thought to be independent like the charge and mass of an electron. The error propagation formula for multiple independent variables labeled a_1, a_2, \ldots, a_M is given by

    \[{\sigma}_f^2 = \sum_{j = 1}^M \left( \cfrac{ \partial f}{ \partial a_j}\right)^2 {\sigma}_{a_j}^2\]

We will often use the notation that a_1 = A \quad a_2 = B for simplification when we do calculations. Propagation of error for two independent variables is given by

    \[{\sigma}_f^2 = \left( \cfrac{ \partial f}{\partial A}\right)^2{\sigma}_A^2 + \left( \cfrac{ \partial f}{\partial B}\right)^2{\sigma}_B^2\]

Example. Show that {\sigma}_{A \pm B} = \sqrt{{\sigma}_A^2 + {\sigma}_B^2}.
Evaluating the partial derivatives

    \[\cfrac{ \partial (A \pm B)}{\partial A} = 1 \qquad \cfrac{\partial(A \pm B)}{\partial B} =\pm 1\]

Applying the error propagation formula we have

    \[{\sigma}_{A \pm B} = \sqrt{ (1)^2 {\sigma}_A^2 + (\pm 1)^2 {\sigma}_B^2 } = \sqrt{ {\sigma}_A^2 + {\sigma}_B^2 }\]

Example. Find the perimeter of a rectangle of l = 1.25(22) and w = 4.44(33).
The perimeter is equal to P = 2( l + w )
We can find the perimeter by plugging in the values
P = 2(1.25 + 4.44) = 11.3800\ldots
We can find the uncertainty by applying the propagation of error formula

    \[{\sigma}_P^2 = \left( \cfrac{\partial P}{\partial l}\right)^2 {\sigma}_l^2 + \left( \cfrac{\partial P}{\partial w}\right)^2 {\sigma}_w^2\]

    \[\sigma_P = \sqrt{ 4 \sigma_l^2 + 4 \sigma_w^2} = \sqrt{ 4\times 0.22^2 + 4\times 0.33^2} = 0.7932\ldots\]

    \[\sigma_P \to 0.79\]

Our final answer is P = 11.38 \pm 0.79

Example. If Q = AB, then show that

    \[{\sigma}_{AB} = |AB| \sqrt{\cfrac{{\sigma}_A^2}{A^2} + \cfrac{{\sigma}_B^2}{B^2}}\]

Evaluating the partial derivatives

    \[\cfrac{ \partial (AB)}{\partial A} = B \qquad \cfrac{\partial(AB)}{\partial B} = A\]

Applying the error propagation formula we have

    \[{\sigma}_{AB} = \sqrt{ B^2 {\sigma}_A^2 + A^2 {\sigma}_B^2 }\]

Divide both sides by |AB|.

    \[\cfrac{{\sigma}_{AB}}{|AB|} = \cfrac{1}{|AB|}\sqrt{ B^2{\sigma}_A^2 + A^2 {\sigma}_B^2 } =\sqrt{ \cfrac{{\sigma}_A^2}{A^2} + \cfrac{{\sigma}_B^2 }{B^2}}\]

Example. If Q = A/B, then show that

    \[{\sigma}_{AB} = |A/B| \sqrt{\cfrac{{\sigma}_A^2}{A^2} + \cfrac{{\sigma}_B^2}{B^2}}\]

Evaluating the partial derivatives

    \[\cfrac{ \partial (A/B)}{\partial A} = 1/B \qquad \cfrac{\partial(A/B)}{\partial B} =-A/B^2\]

Applying the error propagation formula we have

    \[{\sigma}_{A/B} = \sqrt{ (1/B)^2 {\sigma}_A^2 + (A^2/B^4) {\sigma}_B^2 }\]

Divide both sides by |A/B|.

    \[\cfrac{{\sigma}_{A/B}}{|A/B|} = \cfrac{1}{|A/B|}\sqrt{ (1/B)^2{\sigma}_A^2 + (A^2/B^4) {\sigma}_B^2 } =\sqrt{ \cfrac{{\sigma}_A^2}{A^2} + \cfrac{{\sigma}_B^2 }{B^2}}\]

Common error formulas

Q= A + B then

    \[{\sigma}_Q = \sqrt{ {\sigma}_A^2 + {\sigma}_B^2}\]

Q = A - B then

    \[{\sigma}_Q = \sqrt{ {\sigma}_A^2 + {\sigma}_B^2}\]

Q = AB then

    \[\cfrac{{\sigma}_Q}{|Q|} = \sqrt{ \cfrac{{\sigma}_A^2}{A^2} + \cfrac{{\sigma}_B^2}{B^2}}\]

Q = A/B then

    \[\cfrac{{\sigma}_Q}{|Q|} = \sqrt{ \cfrac{{\sigma}_A^2}{A^2} + \cfrac{{\sigma}_B^2}{B^2}}\]

Q = AB/C\ldots then

    \[\cfrac{{\sigma}_Q}{|Q|} =\sqrt{ \cfrac{{\sigma}_A^2}{A^2} + \cfrac{{\sigma}_B^2}{B^2} + \cfrac{{\sigma}_C^2}{C^2} + \ldots }\]

Q = A^aB^B/C^c\ldots then

    \[\cfrac{{\sigma}_Q}{|Q|} = \sqrt{ \cfrac{a^2{\sigma}_A^2}{A^2} + \cfrac{b^2{\sigma}_B^2}{B^2} +\cfrac{c^2{\sigma}_C^2}{C^2} + \ldots }\]

Many formulas in physics are of the last form. For example, F = GmM/r^2 or \omega = \sqrt{k/m}.

Error propagation step by step

Suppose we want to compute the error in the formula

    \[Q(A,B,C,D) = \cfrac{A + B}{C + D}\]

It is convenient to do it step by step. Find the uncertainty in the numerator and denominator individually then combine the results.
We can let Y = A + B and Z = C+D then find the uncertainties in Y and Z first.

    \[{\sigma}_Y = \sqrt{ {\sigma}_A^2 + {\sigma}_B^2} \qquad {\sigma}_Z = \sqrt{ {\sigma}_C^2 + {\sigma}_D^2}\]

We can then calculate the uncertainty for Y/Z which would be

    \[\cfrac{{\sigma}_Q}{|Q|} =\sqrt{ \cfrac{{\sigma}_Y^2}{Y^2} + \cfrac{{\sigma}_Z^2}{Z^2}}\]

You can check for yourself that you get the same result as if you did the calculation in one step.

If the formula was

    \[f = \cfrac{A-B}{A+B}\]

then we couldn’t do it step by step the same way because the numerator and the denominator contain the same variables that repeat. The partial derivatives of the numerator and denominator cannot be separated.

The dominant error

The error propagation formula tells you where you should focus your efforts if you want to reduce the uncertainty in a derived quantity.

Example. Suppose you are calculating g from experiments with a pendulum with small oscillations.

    \[\omega^2 =g/l \qquad g = 4\pi^2 \cfrac{l}{T^2}\]

If the fractional uncertainty in the length and period are both ten percent, then how should you proceed to improve the experimental determination of g?
The error propagation formula for this situation.
We can easily write down the error propagation formula

    \[\cfrac{{\sigma}_g}{g} = \sqrt{ \cfrac{{\sigma}_l^2}{l^2} + 4\cfrac{ {\sigma}_T^2}{T^2}}\]

If the fractional uncertainty in the length is 10 percent and the fractional uncertainty in the period is 10 percent then the expression in the square root is

    \[\sqrt{ 0.1^2 + 4\times 0.1^2 }\]

Clearly measuring the period more precisely will have the largest effect on reducing the dominant error in the uncertainty.

MATLAB examples

Example. Finding the uncertainty in e^N.
Let N = 3.2524(35) find Q(N) = e^N and the uncertainty.
We know that (e^x)' = e^x. So we easily calculate the uncertainty using

    \[{\sigma}_Q = |e^N| {\sigma}_N = e^N {\sigma}_N\]

Here is what the Matlab code looks like to calculate that.

format long;
N = 3.2524;
sigN = 0.0035;
f = exp(N)
sigf = exp(N)*sigN
>> f = 25.852311068629906
>> sigf = 0.090483088740205
We do the rounding and find f = 25.852(90)

Example. Finding the uncertainty in \sin(\theta).
What is the uncertainty in Q=\sin( \theta) when \theta = 30.0^\circ \pm 2.5 ^\circ?
First, we convert the numbers to radians. The error propagation formula is then

    \[{\sigma}_Q = | \cos \theta | {\sigma}_\theta\]

It is easy to do all these calculations in Matlab.

format long;
t = 30;
sigt = 2.5;
trad = 30 * pi/180;
sigtrad = 2.5 * pi/180;
df = cos(trad)*sigtrad
f = sin(trad)
>> 0.03778748675488
>> 0.50000000000000
So the answer is \sin \theta = 0.500(38).

Example. Finding the Stefan-Boltzmann constant and its uncertainty.
What is the value and uncertainty of the Stefan-Boltzmann constant

    \[\sigma = \cfrac{\pi^2 k_B^4}{60 \hbar^3 c^2}\]

It’s funny that the notation for the Stefan-Boltzmann constant is already \sigma, don’t get confused.
The propagation of error formula is a common one.

    \[{ {\sigma}_{\sigma}} = \sigma \sqrt{4^2\cfrac{ {\sigma}_{k_B}^2}{ k_B^2} + 3^2\cfrac{{\sigma}_{\hbar}^2}{\hbar^2}}\]

Since c is defined it has no uncertainty. Also constant factors like \pi or \sqrt{2} have no uncertainty.
A quick google for “NIST hbar”, “NIST c”, and “NIST Boltzmann’s constant” gives the necessary data.

format long;
hb = 1.054571800e-34;
shb = 0.000000013e-34;
c = 299792458;
kb = 1.38064852e-23;
skb = 0.00000079e-23;

SB = pi^2/60 * kb^4/(c^2*hb^3)
sigSB = SB*(16*skb^2/kb^2+9*shb^2/hb^2)^(0.5)
>> 5.670366818327269e-08
>> 1.297991325923970e-13

The uncertainty is 0.000013 \times 10^{-8} J m^{-2}s^{-1}K^{-4}. So the final result is

    \[\sigma = 5.670367(13) \times 10^{-8} \mathrm{Jm}^{-2}\mathrm{s}^{-1}\mathrm{K}^{-4}\]

This calculation agrees with the NIST 2016 value.

ErrorPropagationSingleAndMultipleIndependentVariables.pdf