06/11/2023

Background

When performing measurements in the real world, uncertainty always needs to be accounted for. One common simplification of error propagation is significant figures; by using a few simple rules, measurements can be reported in a way that gives a vague idea of the level of certainty in the resulting value. When a more precise way of quantifying error is required, we must turn to error propagation.

Standard Deviation Formulas

Error propagation allows us to calculate the resulting uncertainty after performing various common operations between uncertain inputs. When it is reasonable to assume the input errors follow a standard distribution, errors are calculated using standard deviations. The following are formulas used for various operations:

\[ z = x + y, \hspace{1cm} \Delta z = \sqrt{(\Delta x)^2 + (\Delta y)^2}\\ z = x \cdot y, \hspace{1cm} \Delta z = z \cdot \sqrt{(\frac{\Delta x}{x})^2 + (\frac{\Delta y}{y})^2}\\ z = x^m + y^n, \hspace{1cm} \Delta z = z \cdot \sqrt{(\frac{m\Delta x}{x})^2 + (\frac{n\Delta y}{y})^2}\\ \]

Average Errors Formulas

When it is not appropriate to assume that the input quantities are distributed on a normal distribution (for example, when there might be systemic measurement error) another method can be used. This method will result in larger error ranges. The following are formulas used for various operations:

\[ z = x + y, \hspace{1cm} \Delta z = |\Delta x| + |\Delta y|\\ z = x \cdot y, \hspace{1cm} \Delta z = z \cdot (\frac{\Delta x}{x} + \frac{\Delta y}{y})\\ z = x^m + y^n, \hspace{1cm} \Delta z = z \cdot (|m|\frac{\Delta x}{x}+|n|\frac{\Delta y}{y}) \]

Error Comparison Method Code

The goal is to compare the error in the z value of x * y for the two methods assuming x and y have an uncertainty of 0.2.

x <- y <- seq(1, 10)
xerror <- yerror <- 0.2
z_sd <- outer(x, y, FUN = function(x, y) x * y *
              sqrt((xerror/x)^2 + (yerror/y)^2))
z_avg <- outer(x, y, FUN = function(x, y) x * y * (xerror/x + yerror/y))
plotlyPlot <- plot_ly() %>%
  add_surface(x = x, y = y, z = z_sd, colorscale = "Blues", 
              name = "Standard Deviation") %>%
  add_surface(x = x, y = y, z = z_avg, colorscale = "Reds", 
              name = "Average Errors") %>%
  layout(scene = list(
    xaxis = list(title = "X-axis"),
    yaxis = list(title = "Y-axis"),
    zaxis = list(title = "Resulting +/- Error")
  ), legend = list(x = 0, y = 1, bgcolor = "rgba(0,0,0,0)"))

Error Comparison Plotly Plot

Error Accumulation Comparison (Addition) With Random Errors

Error Accumuation Comparison (Multiplication) With Random Errors