1

In the Floating point number system $ \ F(10,10,-98,100) \ $ , subtract $ \ \sqrt{1001 } \ $ from $ \ \sqrt{1002} \ $ . How many significant decimal digits are lost in performing the subtraction ?

Answer: In $ F(10,10,-98,100) \ $ ,

$ \sqrt{1001}=31.63858403=0.3163858403 \times 10^2 , \\ \sqrt{1002}=31.65438358 =0.3165438358 \times 10^2 , \ $

Thus,

$ \sqrt{1002}-\sqrt{1001}=(0.3165438358-0.3163858403) \times 10^2 \ =0.0001579955 \times 10^2 \ $

Thus $ \ 3 \ $ significant digits are lost .

I need confirmation of my work .

Am I right ? If not , then how to calculate this ?

Further , how can I rearrange the calculation for better result ?

MAS
  • 10,638

1 Answers1

3

Your count is accurate.

The subtraction $$d = x - y$$ of two real numbers is ill-conditioned when $x \approx y$.

In order to improve the accuracy of your calculation you must find an expression which is mathematically equivalent, but which does not contain any steps which are ill-conditioned.

You can write $$ \sqrt{a} - \sqrt{b} = (\sqrt{a} - \sqrt{b}) \left(\frac{\sqrt{a} + \sqrt{b}}{ \sqrt{a} + \sqrt{b}}\right) = \frac{a - b}{\sqrt{a} + \sqrt{b}}, $$ which shows that the left hand side is equivalent to the right hand side in exact arithmetic.

In your case, $a=1002$ and $b = 1001$, so $$ \sqrt{1002} - \sqrt{1001} = \frac{1}{ \sqrt{1002} + \sqrt{1001}}. $$

It is of no real importance, but I believe the last digit of your value for $\sqrt{1001}$ is wrong. It should be $\sqrt{1001} \approx 31.63858404$.

Carl Christian
  • 12,583
  • 1
  • 14
  • 37