Relative roundoff error in the simple precision.

347 Views Asked by At

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.

1

There are 1 best solutions below

11
On

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}$