4 ms·
Is there a shorthand for calculating how much X% of error will become when raised to the power of Y? For relatively small powers, simple multiplication seems t
by kijin 10y ago
Is there a shorthand for calculating how much X% of error will become when raised to the power of Y?
For relatively small powers, simple multiplication seems to give results that are close enough, e.g. 0.677% * 54 = 36.6%, and 2.4% * 5 = 12%. But this is obviously not going to work once you start raising numbers to even higher powers.
- ColinWright 10y agoShort answer: yes. Slightly longer answer ... For very small errors, multiplying by the power is right. You can see that because of the standard expansion: (1+e)^n ~ 1 + ne + n(n-1)e^2/2 + ... When e is small enough, e^2 is very small, so we can ignore everything that follows. When e is slightly larger we can use more terms in the expansion, and that works nicely. That happens in the post about the birthday problem, where an extra term is used from the expansion for log(n). So you don't get it for free, but it's not a lot of extra work. In the case of 1.024^5, which is in the post, we get: e=0.024 n=5 print n * e -> 0.12 So the first approximation of the error is 12% print n*e + n*(n-1)/2*e**2 -> 0.12575999999999998 So the extended approximation is 12.576%. We can compare that with the actual error: print (1+e)**5 -> 1.125899906842624 Pretty close. Even longer answer: Binomial Theorem.
- deleted 10y ago[deleted]
- psi-squared 10y agoSo, let's call the correct value of whatever 'A'. Then "Off by X%" really means that the number you used is (1 + X/100) * A. (note: if you underestimated you need to make X negative for this to work) When you raise that to the power Y, you get (1 + X/100)^Y * A^Y, when the correct result is just A^Y. So you get (1 + X/100)^Y times what you should've gotten. You can convert that back into a percentage directly if you want, but if X is small (ie, if the original value is "close enough"), you can use the binomial expansion [1] and just keep the first few terms. If you do that, you eventually end up with: Percentage the final result is out = Y * X + (1/200) * Y(Y-1) * X^2 + ... [1]: https://en.wikipedia.org/wiki/Binomial_theorem https://en.wikipedia.org/wiki/Binomial_theorem
- rprospero 10y agoA different was of thinking about it is with the log rules. Let's take 2.4% to the hundredth power, which is assuredly more than 240%. y = 1.024^100 ln y = ln (1.024^100) = 100 * ln 1.024 Now, we can approximate ln x = x-1 for values of x near one, so we get ln y = 100 * 0.024 = 2.4 y = exp 2.4 = e ^ 2.4 ~ 2.7^2.4 2.7^2.4 = (27/10)^2.4 = (3^3/10) ^ 2.4 2.7^2.4 = (3^3)^2.4 / (10^2.4) = 3^7.2 / (100 * 10^0.4) = 3*(3^6)*3^0.2 / (100 * 10^0.4) = 3*(729/100)*3^0.2/10^0.4 = 3*(7.29)*(3/100)^0.2 = 21.87*(0.03)^(1/5) Finally, (1/2)^5 = 1/32 ~ 0.03 y ~ 21.87 * 1/2 = 10.94 Pulling out Python, the actual answer is 10.72, so we're within a few percent.