1

I assume that we are working on a machine with rounded four-digit decimal arithmetic, I know that we have this formula:

$\sqrt x - \sqrt y = \frac{x - y}{\sqrt x + \sqrt y}$

Since there is cancelation error in machine so it is better to use this formula for computing $fl(\sqrt x - \sqrt y)$ .But can you give me an example that computing simple difference for computing $fl(\sqrt x - \sqrt y)$ (I mean directly compute $\sqrt x - \sqrt y$) is more accurate than computing $\frac{x - y}{\sqrt x + \sqrt y}$ ?

I tried lots of examples but using formula is always more accurate or both of them have the same accuracy ,can any one help me?

haleh
  • 133
  • 9

1 Answers1

1

The advantage of the formula is mainly when $x$ and $y$ are close together. When they are not, the direct method has a fair chance of being better. For example, with $x = 6$ and $y = 1$, the direct method gives $\sqrt{x} - \sqrt{y} = 2.449 - 1.000 = 1.449$, while the formula gives $$\frac{x - y}{\sqrt{x} + \sqrt{y}} = \frac{6 - 1}{2.449 + 1.000} = \frac{5}{3.449} = 1.450$$ and it happens that $\sqrt{6} - \sqrt{1} = 1.4494897\ldots$ is closer to $1.449$ than to $1.450$.

Robert Israel
  • 448,999