Supposing I want to divide one number into many.
a /= x;
b /= x;
c /= x;
...
Since multiplication is faster, the temptation is to do this
tmp = 1.0f / x;
a *= tmp;
b *= tmp;
c *= tmp;
...
1) Is this guaranteed to produce identical answers? I suspect not but some confirmation would be nice.
2) If x
is extremely large or extremely small I expect this could cause a significant loss of accuracy. Is there a formula which will tell me how much accuracy I will sacrifice?
3) Perhaps there's no convenient formula, but can we at least state a rule of thumb for when numerical instabilities will be an issue? Is it to do with the magnitudes of the operands, or the difference between the magnitudes of the operands perhaps?