Let's pretend I have a five places floating-point register.

I have to represent the following numbers: $256.786$ and $256750000$.

I can represent the first number as $2.568 \cdot 10^2$. The relative error would be: $$e_r=|\frac{2.568 \cdot 10^2-256.786}{256.786}|=0.00545 \% $$

I can represent the second number as $2.568\cdot10^8$ The relative error would be: $$e_r=|\frac{2.568 \cdot 10^8-256750000}{256750000}|=0.0194 \% $$

I was told in this video that with floating point register, the order of relative error is the same with every number.

But in this case, this isn't true, is it? What's wrong?

Many thanks

  • $\begingroup$ Do your registers store decimal or binary representations? It can affect the relative error more if the leading "digit" goes from nine to one. $\endgroup$ – hardmath Dec 10 '12 at 18:50
  • $\begingroup$ @hardmath decimal representations. Could you expand a little your comment? I haven't fully understood it :) $\endgroup$ – sunrise Dec 10 '12 at 18:51

Usually a five place decimal register would store five digits, so the first would be $2.5679 \cdot 10^2$ and the second would be $2.5675 \cdot 10^8$, but we can use your four-place values. The relative error is of the same order with every number, but is not exactly the same. For values which can be represented exactly, the error is $0$, so if you were given $256.7$ to represent, you would get $2.567 \cdot 10^2$ with no error at all. In your case, the first is off by $0.114$ of the last place, while the second is off by $0.5$ of the last place, so the relative error should be about $4.4$ times larger, which it is.

The variation can get worse as hardmath points out. If you want to represent $1.0005$ the error is $5 \cdot 10^{-4}$. If you want to represent $9.9999$ the error is $10^{-6}$. But the fractional error cannot get worse than $5 \cdot 10^{-4}=0.05\%$

  • $\begingroup$ I have a doubt: in my native language "the same order" means that "the power of ten in scientific notation is the same for those numbers". Probably you don't use "same order" with this meaning, do you? Thanks $\endgroup$ – sunrise Dec 12 '12 at 14:55
  • $\begingroup$ @sunrise: In this case, you are moving through a power of $10$, but the change is only a factor $4$, so I was seeing it as the same order. It is like $9$ and $11$ are of the same order. But as I said, the error can be smaller-it could be zero, which is certainly not of that order. What they mean is you should expect errors of that order, here at worst $0.05\%$, but it could be smaller. $\endgroup$ – Ross Millikan Dec 12 '12 at 14:58
  • $\begingroup$ $9=9.0 \cdot 10^0$, $11= 1.1 \cdot 10^1$. How could they be of the same order? 0 is not equal to 1 ! :( Does in English "the same order" mean "in the same range"? $\endgroup$ – sunrise Dec 12 '12 at 15:08
  • $\begingroup$ @sunrise: it can be more flexible than that. The exact way is what you are saying. More approximate, and often more useful, would be to say it means within a factor of 3 or 4 and not worry about the exact decade. I see it both ways. In this case, you can't guarantee the error is of order $10^-4$, but it could be. It could be much smaller. $\endgroup$ – Ross Millikan Dec 12 '12 at 15:14
  • $\begingroup$ I got it! :) Thank you so much! $\endgroup$ – sunrise Dec 12 '12 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.