# Introduction

Error propagation can be a fair bit of work with a calculator, but itâ€™s easy with R. Just use R in repeated calculation with perturbed quantities, and inspect the range of results. Two methods are shown below for inspecting the range: `sd()` and `quantile()`, the latter using the fact that area under a normal distribution is 0.68 when calculated between -1 and 1 standard deviation.

# Tests

## Case 1: scale factor

In this case, the answer is simple. If `A` has uncertainty equal to 0.1, then `10A` has uncertainty 1.0.

The graph indicates that the values are symmetric, which makes sense for a linear operation.

## Case 2: squaring

Here, we expect an uncertainty of 20 percent.

## Case 3: a nonlinear function

Here, we have a hyperbolic tangent, so the expected error bar will be trickier analytically, but of course the R method remains simple. (Note that the uncertainty is increased to ensure a nonlinear range of hyperbolic tangent.)

# Conclusions

The computation is a simple matter of looping over a perturbed calculation. Here, gaussian errors are assumed, but other distributions could be used (e.g. quantities like kinetic energy that cannot be distributed in a Gaussian manner).

# Further work

1. How large should `n` be, to get results to some desired resolution?

2. If the function is highly nonlinear, perhaps the `mean(result)` should be replaced by `median(result)`, or something.

# Resources

This website is written in Jekyll, and the source is available on GitHub.