0

So I am supposed to:

Consider a decimal machine in which floating point numbers are represented with a precision of 12 decimal places and compute the relative error for numbers (assume numbers are rounded correctly).

[ | x - fl(x) | ] / |x| <-- relative error equation

Ex) 2.3456 – 0.00000456789011234

If you normally do the subtraction, fl(x) = 2.34559543210988766‬

My problem is I'm not sure if the fl(x) should be 2.345595432109 (which is the above computation rounded to the 12th decimal place).

OR

That fl(x) = 2.3456 – 0.000004567890 = 2.34559543211‬ (numbers are rounded BEFORE the subtraction).

The relative error itself is simple since you just plug and chug, but I'm not sure which number would be correct for fl(x) or if either of the two methods I stated above are even correct.

Amai
  • 89
  • Usually the hardware implementation of floating point computes the result first with some extra bits and rounds then, so it would be reasonable to apply a compute-first-then-round approach. Or to be more realistic, round first to a common mantissa of 14 or 15 digits, compute the result, then round again to 12 digits. – Lutz Lehmann Sep 11 '19 at 16:06
  • @LutzL I see! Thank you! – Amai Sep 11 '19 at 16:34
  • This exercise seems designed to reinforce the definition of relative error, so the typical hardware implementation is not (in my opinion) relevant here. I think you are supposed to compute $x$ exactly and then compute the "error" $x -fl(x)$. So the issue is how $fl(x)$ is to be computed. I don't think it will make much difference if you round before or after the subtraction. The important point is that the relative error is a ratio of (absolute) magnitudes. – hardmath Sep 11 '19 at 17:07
  • Note that if you round $2.34559543210988766‬$ to the twelth decimal place, you will get $2.345595432110$, not the truncated value you report above. – hardmath Sep 11 '19 at 17:11
  • Also note the exercise calls for using floating point numbers, not fixed point numbers, so the meaning of twelve decimal places might include any non-zero digits in front of the radix point. – hardmath Sep 11 '19 at 17:14

0 Answers0