# Metric System vs Imperial System: general considerations about algorithms and college math

This is probably a dumb question but i'm just curious, and since i do not lives in the USA or in Canada i want to ask that: switching from one system to another can affect the property and the reliability of an algorithm?

I know that you are probably saying that i can just convert every foots in meters and every meters in foots and i can be happy with that, but what about the property? Let's say that i found out a new algorithm, a new way of doing things, this algorithm is tested and used in Germany where peoples uses the metric system, i want to test this algorithm in the USA where the units measures are submultiple e multiple of my original measurements: in how many ways this "trip" can affect the math that i learn at the college?

I do not want that you focus your answer on this particular aspect but for "property" i mean things like http://en.wikipedia.org/wiki/Numerical_stability and everything the study of the math can produce.

Trying to answer this question by myself i find out a not-so-easy definition about the magnitude, since because some properties are related to the values and its own rapresentation, what about saying that "1000 meters is too much" when with the Imperial system 1000 meters are equally to 3280 feets, the order of magnitude can rapidly change.

I'm simply wrong with this or there is something to know about it?

EDIT: as a curious person i'd like to relate this consideration to every variation of the system measurements in use and not only to the Imperial System.

-
It is difficult to discern what you are asking. – Austin Mohr Dec 1 '11 at 8:11
@austin-mohr why? – Micro Dec 1 '11 at 8:13
@Austin I think the question is "Can changing the units of a measurement have an effect on the performance/numerical stability/convergence rate/other properties of an algorithm?" although I agree that the wording could be better. – Chris Taylor Dec 1 '11 at 8:34

It's certainly possible that a change in units could affect the performance of an algorithm. For example, the smallest representable floating point number on most computers is about $10^{-308}$, so if you were to use a system of measurement where one unit of length was $10^{308}$ metres, then any length below one metre is not representable on your computer, which will introduce significant rounding error into any calculations you do.

In practice though, you would use a system of measurement that is appropriate for the quantity you're trying to calculate. For example, physicists often use units where the speed of light $c$, the gravitational constant $G$ and Planck's constant $\hbar$ are equal to 1, rather than their values in metric units of $c=3\times 10^8$, $G=6.7\times 10^{-11}$ and $\hbar=1.05\times 10^{-34}$. For the kind of calculations a physicist might do, this might result in increased accuracy.

Another consideration where this might crop up is in optimization. Say I'm trying to fit a linear model $y_i = a + bx_i$ to some data, where e.g. $y_i$ represents height and $x_i$ represents weight. If I measured height in metres and weight in milligrams, then I would expect $y_i$ to be around 1 or 2 (so $a$ is probably around 1 or 2 as well) but $x_i$ to be around 70,000,000, which means that $b$ will be very small.

If I was fitting this model by using a numerical solver with a fixed step size (e.g. gradient descent), then a step which makes $b$ more accurate will have a much larger effect on the fit of my model than a step that makes $a$ more accurate. Therefore my optimization routine will spend most of its time making $b$ more accurate and only a tiny proportion of its time optimizing $a$, which would be very inefficient (for more examples see here.)

Even worse than that, if $b$ is sufficiently small compared to the step size, then the algorithm might not converge at all! At every stage the algorithm would 'overcorrect' and the fit of the model would be worse than it was at the previous stage.

A better thing to do would be to measure height in metres and weight in kilograms, so that $a$ and $b$ were of comparable size, which would improve the performance of the gradient descent algorithm (actually, an even more sensible thing to do would be to use a different algorithm for optimizing, e.g. gradient descent with an adaptive step size, or conjugate gradients, or...)

-
In your knowledge there is no such thing like a "dedicate discipline" like the numerical analysis for the numerical stability, there is a part of the math dedicated to this kind of problems? – Micro Dec 1 '11 at 10:11
No, it's a very small area of a much larger field. – Chris Taylor Dec 1 '11 at 10:27

There is a lot of numerical software that works better if the data are properly scaled, and poorly done changes of units may affect this. For example, say your original data representing forces are in pounds, and you want to change to metric units. If you use dynes (1 lb = 444822 dynes), the numbers may be unacceptably large. It's not the fault of the system though, it's that you didn't scale the data properly: if you used newtons = 10^5 dynes (1 lb = 4.44822 N) the numbers would still be reasonably sized.

A typical case where this kind of scaling can affect an algorithm: in the simplex algorithm for linear programming, you need to test whether some quantity is negative. But small negative values can often result from roundoff error, so in practice there is a certain "tolerance": in order to be treated as negative, the quantity must be less than $-\epsilon < 0$. An $\epsilon$ is chosen that works well most of the time for well-scaled data, but if the data are poorly scaled it may be that either values that really should be negative are ignored, or values that would be 0 except for roundoff error are treated as negative.

-
i'd like to ask to you the same thing as above about the existence of a dedicated branch studying this kind of problems. – Micro Dec 1 '11 at 10:13