0
$\begingroup$

I am struggling with a simple problem from the computer arithmetics. The goal is to find $|(fl(0.1)-0.1)/0.1|$. I have computed the binary representation of $0.1$, which is $(1.1001)_{2}\times2^{-4}$, where the $1001$ after the decimal point is periodic. I know that $fl(0.1)$ is rounding the $0.1$ up, so we get $(1.1001...101)_{2}\times2^{-4}$, where the last digit is on the $-23$rd position. But I don't know how to compute the relative error. Thank you for any help.

$\endgroup$
  • $\begingroup$ Yes, thank you, I edited $\endgroup$ – Vwann Jan 4 '19 at 20:35
0
$\begingroup$

Just plug into the formula. You have $fl(0.1)$ and $0.1$ so now subtract. Starting from the last position in your $fl(0.1)$ the true value continues $011\ 001\ 100\ldots$ so if we subtract we get (about) $001$ with the first $0$ matching the last $1$ in $fl(0.1)$. That is $22$ places to the right of the radix point, so the difference is $2^{-4}\cdot 2^{-22}\cdot 2^{-2}=2^{-28}$ where the first factor is from the exponent of $fl(0.1)$, the second is from all the places to the right of the radix point, and the third is the two places the $1$ in the error is to the right of the end of $fl(0.1)$. The relative error is then $\frac {2^{-28}}{0.1}\approx 3.7\cdot 10^{-8}$

If you want the exact answer, you need the exact value of $fl(0.1)$. I asked Alpha and got $\frac {6710885}{16\cdot4194304}$. Then the relative error is $10(\frac {6710885}{16\cdot4194304}-\frac 1{10})=-\frac 7{33554432}$

$\endgroup$
  • $\begingroup$ I have a slightly different answer $\endgroup$ – Vwann Jan 4 '19 at 21:16
  • $\begingroup$ For the absolute error I get 1/10×2^(-26) $\endgroup$ – Vwann Jan 4 '19 at 21:17
  • $\begingroup$ And relative is therefore 2^(-26) $\endgroup$ – Vwann Jan 4 '19 at 21:18
  • $\begingroup$ My computation of $fl(0.1)-0.1$ was not exact. Usually we are only interested in the magnitude of errors like this. $2^{-26}$ is not correct because that is the whole value of the last $1$ in your expression, but $0.1$ is greater than your expression with the last $1$ changed to a $0$. $\endgroup$ – Ross Millikan Jan 4 '19 at 21:18
  • $\begingroup$ Well, not in this case. The question is about the precise value. Thank you anyway $\endgroup$ – Vwann Jan 4 '19 at 21:19

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.