Closed joelcourtheyn closed 7 years ago
Good point. I have an article pending about this. The TL;DR version: both calculations are ok, but the first formula is incorrect, or, at least, an abuse of notation. The explanation follows.
Let's consider a shorter but more intuitive version of the issue: 2 * x
vs. x + x
. Try it yourself and then come back and continue. ;-) Well, what has happened? First of all, we need to keep in mind that numbers with errors are not mathematical variables anymore: they are physical (in a broad sense) quantities. So let's put an example in accordance with the issue.
Imagine that we want to measure a table's width, but we have a ruler that is only about half of the width. So we manage to put a mark, by the means of some method (using a string, for instance), approximately at about half of the table. Then, we have two options: 1) to measure the first half and multiply by two, or 2) to measure both halves and sum them.
Intuitively, 1), which is 2 * x
, has a larger uncertainty, because you are not measuring the second half of the table. And that is exactly what you obtained before. But in 2), even if the result of the second measurement matches the first one, x + x
is an abuse of notation: they are different measurements, so we should write x + y
.
Therefore, you can scale a certain measurement, apply any function to it... but summing/multiplying/dividing/... a measurement to itself has no physical meaning. 2 * x == x + x
is true in mathematics, but x + x
has no physical sense. You should say x + y
(even if x
is the same value as y
), and x + y != 2 * x
for the propagation of uncertainty.
Finally, my advice about how to write the formula? Check the physical meaning, not the mathematical correctness. If the same variable appears more than once in a formula, either they are conceptually different measurements with the same name and the same value, or you have to simplify the expression. The first case corresponds to the result of your z1
; the second one, to your z
.
Experimenting with the new package errors calculation I detected a difference in calculation of the error depending on the way a formula was written. Originally I tried to calculate the error for z1 <- (x^3 - 2y)/x^0.5, but this gave me a value which was different from the manual calculated error. When I transformed this formula to : z <- x^2.5 - 2y*x^(-1/2), than I came to the right results. The code I ran in R is given in attachment, the result can be read hereunder.
Below result for df
1 1.00(1) 5.0(1) 0.01 0.1 -9.0(2) 0.2076656 -9.0(2) 0.2071835 0.9976785 2 2.00(2) 5.0(1) 0.02 0.1 -1.4(2) 0.2031010 -1.4(2) 0.2210204 1.0882290 3 3.00(3) 5.0(1) 0.03 0.1 9.8(4) 0.4074821 9.8(5) 0.4841918 1.1882528 4 4.00(4) 5.0(1) 0.04 0.1 27.0(8) 0.8066133 27.0(10) 0.9745897 1.2082489 5 5.00(5) 5.0(1) 0.05 0.1 51(1) 1.4005802 51(2) 1.6990071 1.2130737 6 6.00(6) 5.0(1) 0.06 0.1 84(2) 2.2061467 84(3) 2.6799036 1.2147441 7 7.00(7) 5.0(1) 0.07 0.1 126(3) 3.2419819 126(4) 3.9405642 1.2154800 8 8.00(8) 5.0(1) 0.08 0.1 177(5) 4.5260703 177(6) 5.5030639 1.2158591 9 9.00(9) 5.0(1) 0.09 0.1 240(6) 6.0753886 240(7) 7.3881356 1.2160762 10 10.0(1) 5.0(1) 0.10 0.1 313(8) 7.9059629 313(10) 9.6153133 1.2162103
Conclusion errors(z) gives the exact results (checked with manual calculation of error and with Monte Carlo simulation in Excel). Errors for z1 are up to 20% higher than those for z. Is there any recommendation to make regarding how to set up of a formula ?
Question regarding Package errors 0.docx