Maximum error through successive multiplications

Disclaimer: No, this isn’t my math homework. Yes, I knew how to do this back when I had math homework. Alas, that homework is now decades behind me. I recognize that using “math” as a verb is goofy but that doesn’t stop me.

Help me math!

Say that, for some reason, you had a software system that took a distance measured in kilometers, converted that distance into miles, and then passed the miles measurement to another system that converted it back into kilometers. Crazy, right? “Who would do that!?”, a reasonable person might shout at the screen. Well, calm down. It’s just a hypothetical. Maybe.

Given such an implausible system, how would you calculate the maximum error between the initial kilometers value given to the system, and the round-tripped kilometers value produced later on? To be quite specific, given these two conversions:[ol]
[li]K1 * (0.621371 miles/kilometer) = M1[/li][li]M1 * (1.609344 kilometers/mile) = K2[/li][/ol]

…And, assuming you wanted to do something like this:
AbsoluteValue(K1 - K2) = X

…What is the biggest X could possibly be as related in terms of those two conversion factors? I’ve done some empirical poking with a calculator and suspect it’s somewhere around 0.0001 but I don’t recall how to prove it.

The error in your program comes from the problem that 0.621371 is not exactly the reciprocal of 1.609344. The error is 0.0000405. Or about 0.0006%. The more accurately you represent the reciprocal the better. Up to the intrinsic accuracy of the machine you are using. So single versus double precision arithmetic will matter.

If you had written code that was of the form



k1 = 1.0
kilometersToMiles = 0.621371
milesToKilometers = 1/kilometersToMiles
truncatedMilesToKilometers = 1.609344
m1 = k1 * kilometersToMiles
k2 = m1 * milesToKilometers
k3 = m1 * truncatedMilesToKilometers
print abs(k1 - k2)
print abs(k1 - k3)


You would have an error that was down near the precision of the machine you used for k1 - k2 but yields an error of about 3.0937599993e-07 for k1 - k3.

It’s interesting to go the other way: Miles to kilometers using 1 inch = 2.54 centimeters, then back to miles using 1 meter = 39.37 inches.

This will yield an exactly correct result! … except that you’ll have replaced International Miles with Survey Miles. :eek:

Thank you! I got wrapped up in pondering significant figures and overlooked the reciprocal issue.

Also, feeling kind of dumb now because it’s not clear to me how you calculated that error figure. How did you do that? I’m trying to do something like this:
Error = (AppoximateValue - ExactValue) / ExactValue

…but, using an approximate value of 1.609344 and an exact value of (1/0.621371), I’m coming up with .00000030937. What am I doing wrong?

Well teh simple issue is there is no maximum error you might make of the form AbsoluteValue(K1 - K2) = X. There is a maximum percentage error you will make that depends on the reciprocal issue and any truncation your computer might do in carrying out the steps. But the error measured in miles (or kilometers or inches or whatever) has no upper bound. If you have a 1% error in 100 kilometers it’s an error of a kilometer, but that same 1% error in 100 billion kilometers is a billion kilometers, etc.

I used the other possibility - error relative to 0.6217 - simply because I didn’t regard either as exact. It was just for a rough feeling. I should have said which. (And I hope I got it right. No guarantees. :slight_smile: )

Ah, a light has gone on (or begun to flicker a bit, maybe).

So, given the conversion factors I specified, the error could be calculated like this:
K1 = 1
M1 = K1 * 0.621371 = 0.621371
K2 = M1 * 1.609344 = 0.999999690624
E = ((K2 - K1) / K1) = 0.000000309376

Based on that, could I claim that the error in K2 is less than or equal to K1 * E? Am I getting close?

You’ve got the right high level concept. Which is probably good enough for what you’re doing.

There are more details which depend on which computer language you’re using, the specifics of the hardware, the range of values you typically intend to convert, etc. But all of that is just going to be noise within the 0.000000309376 figure you’ve already got.

Unless your question is explicitly about other sources of error or the specifics of how it works, not just what the result roughly is. For pretty smooth values of roughly. :slight_smile:

Either you’re wanting something very different from what you seem to be saying, or else I’m not understanding what you’re trying to do.

If you want the maximum error, all you have to do is round off the conversion factors.

Example:
5 kilometers * .6 = 3 miles
3 miles * 1.6 = 4.8 kilometers

That’s an error of 4%.

Standard STEM lab calculations - error calculations…

Additive (add and subtract) the absolute errors add.
Multiplicative and divide - relative errors (or percent error) add.
So if your conversion A is off by 1% and conversion B is off by 2%, the whole calculation is only reliable to 3%
of course, this ignores systemic errors and other issues.

Perhaps I’ve just done a poor job in stating my goal but, given this:
K1 = ???
M1 = K1 * 0.621371
K2 = M1 * 1.609344

For arbitrarily large, positive values of K1, I’m trying to characterize the extent to which K1 and K2 might differ.

Pretty sure it has already been answered but K2 = K1 x 0.621371 x 1.6009344 or K2 = 0.999999690624 x K1. For rounding, I would say an error of 0.00003% This works out to an error of just over 3 Km low if K1 is 10,000,000 Km

There is a whole field of mathematics around this kind of problem, called interval arithmetic. It is overkill for this problem of course. Some people in my department were working on this when I was in grad school, and they found that the Army Corps of Engineers was moving way too much dirt as they tried to control the Mississippi River. So it is a real problem in complex calculations.

So Bush DID cause the flooding during Hurricane Katrina. Probably to distract people from his planning 9/11. Don’t tell the Dems on this board.

Ha! I think that’s it. Interval Arithmetic-- I just didn’t know what to call it.

On the wiki, I found this:
[x1, x2] * [y1, y2] = [min(x1y1, x1y2, x2y1, x2yx), max(x1y1, x1y2, x2y1, x2yx)]

So, given my conversion factors, 0.621371 and 1.609344, I came up with this:
[0.6213705, 0.6213715] * [1.6093435, 1.6093445] = [min(0.9999986, 0.9999992, 1.000000, 1.000001), min(0.9999986, 0.9999992, 1.000000, 1.000001)]

Or, really, this:
[0.6213705, 0.6213715] * [1.6093435, 1.6093445] = [0.9999986, 1.000001]

So, for some arbitrary value, I can say something like this:
K1 = 1.123456789
Emin = K1 * 0.9999986 = 1.1234552161604954
Emax = K1 * 1.000001 = 1.123457912456789
K2 = K1 * 0.621371 * 1.609344 = 1.123456441429432446336

Where (I hope) I can promise that Emin <= K2 <= Emax

…which is all I’ve ever really wanted! :smiley:

Heh. Smart guy to distract people from 9/11 after 9/11. Actually this was before either Bush. But that Mississippi wants to go places where we don’t want it to go. If I remember correctly, if no one controlled it the river would be running through the Atchafalaya basin about now, leaving New Orleans high and dry.

He had to do something after Loose Change began to gain traction.