math.uncertainty
measurements with a margin of error, like 5 ± 0.1 m, carried through calculations
Measurements with a margin of error. A length measured as 5 m might really be anywhere from 4.9 m to 5.1 m, written 5 ± 0.1 m. Use these values in calculations as usual, and zil works out how far off the result could be.
good to know
Section titled “good to know”Errors are taken to be independent and random, the standard way in science, so they partly cancel: adding 5 ± 0.3 and 2 ± 0.4 gives 7 ± 0.5, not 7 ± 0.7.
Tags: statistics
valuethe measured value without its error: 5 for 5 ± 0.1errorthe error alone, in the same unit: 0.1 for 5 ± 0.1rel_errorthe error as a fraction of the value, so 0.02 for 5 ± 0.1
syntax
Section titled “syntax”1# x ± e, also typed x +- e25 ± 0.1 m3# x ± n%: an error of n% of x420 ± 5%20 ± 15# adding: errors combine as sqrt(0.3² + 0.4²)6(5 ± 0.3) + (2 ± 0.4)7 ± 0.57# multiplying: percentage errors combine8(10 ± 1 m) * (2 ± 0.1 m)20 ± 2.23607 m^29# functions carry the error through10sqrt(16 ± 1)4 ± 0.12511# and so do unit conversions125 ± 0.1 km to mi3.10686 ± 0.0621371 mipretty
Section titled “pretty”1# long, the default: in the best-fitting unit2pretty(1500 ± 20 m)"1.5 ± 0.02 km"3# short: K, M, B and T for thousands up to trillions4pretty(1234567 ± 1000, "short")"1.23M ± 1K"Functions
Section titled “Functions”value(x: uncertain) -> num|quantity
the measured value without its error: 5 for 5 ± 0.1
1(5 ± 0.1 m).value5 merror(x: uncertain) -> num|quantity
the error alone, in the same unit: 0.1 for 5 ± 0.1
1(5 ± 0.1 m).error0.1 m2(20 ± 5%).error1rel_error
Section titled “rel_error”rel_error(x: uncertain) -> float
the error as a fraction of the value, so 0.02 for 5 ± 0.1
A plain number with no unit, so .percent shows it as a percentage
1(5 ± 0.1 m).rel_error0.022(20 ± 5%).rel_error.percent"5%"More examples
Section titled “More examples”uncertainty
Section titled “uncertainty”1# area of a measured rectangle2(2 ± 0.05 m) * (3 ± 0.05 m)6 ± 0.180278 m^23# a 1 m pendulum's swing time, in seconds42 * pi * sqrt((1 ± 0.01) / 9.81)2.00607 ± 0.0100303Example results generated on 2026-11-04. Ones using now, today or randomness will differ when you run them.